forked from opensearch-project/common-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add method type in CustomWebhook data model (opensearch-project#39)
Signed-off-by: Zhongnan Su <[email protected]>
- Loading branch information
1 parent
248c15d
commit d36cd8b
Showing
3 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/org/opensearch/commons/notifications/model/HttpMethodType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.opensearch.commons.notifications.model | ||
|
||
import org.opensearch.commons.utils.EnumParser | ||
|
||
enum class HttpMethodType(val tag: String) { | ||
POST("POST") { | ||
override fun toString(): String { | ||
return tag | ||
} | ||
}, | ||
PUT("PUT") { | ||
override fun toString(): String { | ||
return tag | ||
} | ||
}, | ||
PATCH("PATCH") { | ||
override fun toString(): String { | ||
return tag | ||
} | ||
}; | ||
|
||
companion object { | ||
private val tagMap = values().associateBy { it.tag } | ||
|
||
val enumParser = EnumParser { fromTagOrDefault(it) } | ||
|
||
/** | ||
* Get HttpMethodType from tag or POST if not found | ||
* @param tag the tag | ||
* @return MethodType corresponding to tag. POST if invalid tag. | ||
*/ | ||
fun fromTagOrDefault(tag: String): HttpMethodType { | ||
return tagMap[tag] ?: POST | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters