diff --git a/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/configuration/ActionConfiguration.java b/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/configuration/ActionConfiguration.java index 96519fceaa..0f9db9984e 100644 --- a/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/configuration/ActionConfiguration.java +++ b/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/configuration/ActionConfiguration.java @@ -12,6 +12,14 @@ public class ActionConfiguration { @JsonProperty("type") private OpenSearchBulkActions type; + @AssertTrue(message = "type must be one of index, create, update, upsert, delete") + boolean isTypeValid() { + if (type == null) { //type will be null if the string doesnt match one of the enums + return true; + } + return false; + } + public String getType() { return type.toString(); } diff --git a/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/configuration/OpenSearchSinkConfig.java b/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/configuration/OpenSearchSinkConfig.java index a14fb38cd7..ee424da181 100644 --- a/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/configuration/OpenSearchSinkConfig.java +++ b/data-prepper-plugins/opensearch/src/main/java/org/opensearch/dataprepper/plugins/sink/opensearch/configuration/OpenSearchSinkConfig.java @@ -139,6 +139,14 @@ public boolean getEnableRequestCompression() { @JsonProperty("action") private OpenSearchBulkActions action = OpenSearchBulkActions.INDEX; + @AssertTrue(message = "action must be one of index, create, update, upsert, delete") + boolean isActionValid() { + if (action == null) { //action will be null if the string doesn't match one of the enums + return true; + } + return false; + } + public String getAction() { return action.toString(); }