diff --git a/src/main/java/org/opensearch/flowframework/common/CommonValue.java b/src/main/java/org/opensearch/flowframework/common/CommonValue.java index 496eb4858..94668a24c 100644 --- a/src/main/java/org/opensearch/flowframework/common/CommonValue.java +++ b/src/main/java/org/opensearch/flowframework/common/CommonValue.java @@ -27,6 +27,14 @@ private CommonValue() {} public static final String GLOBAL_CONTEXT_INDEX_MAPPING = "mappings/global-context.json"; /** Global Context index mapping version */ public static final Integer GLOBAL_CONTEXT_INDEX_VERSION = 1; + /** The template field name for template use case */ + public static final String USE_CASE_FIELD = "use_case"; + /** The template field name for template version */ + public static final String TEMPLATE_FIELD = "template"; + /** The template field name for template compatibility with OpenSearch versions */ + public static final String COMPATIBILITY_FIELD = "compatibility"; + /** The template field name for template workflows */ + public static final String WORKFLOWS_FIELD = "workflows"; /** The transport action name prefix */ public static final String TRANSPORT_ACION_NAME_PREFIX = "cluster:admin/opensearch/flow_framework/"; @@ -55,7 +63,7 @@ private CommonValue() {} /** Model Group Id field */ public static final String MODEL_GROUP_ID = "model_group_id"; /** Description field */ - public static final String DESCRIPTION = "description"; + public static final String DESCRIPTION_FIELD = "description"; /** Connector Id field */ public static final String CONNECTOR_ID = "connector_id"; /** Model format field */ diff --git a/src/main/java/org/opensearch/flowframework/model/Template.java b/src/main/java/org/opensearch/flowframework/model/Template.java index 72599e25e..6dedb5db7 100644 --- a/src/main/java/org/opensearch/flowframework/model/Template.java +++ b/src/main/java/org/opensearch/flowframework/model/Template.java @@ -25,27 +25,19 @@ import java.util.Map.Entry; import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; +import static org.opensearch.flowframework.common.CommonValue.COMPATIBILITY_FIELD; +import static org.opensearch.flowframework.common.CommonValue.DESCRIPTION_FIELD; +import static org.opensearch.flowframework.common.CommonValue.NAME_FIELD; +import static org.opensearch.flowframework.common.CommonValue.TEMPLATE_FIELD; +import static org.opensearch.flowframework.common.CommonValue.USE_CASE_FIELD; +import static org.opensearch.flowframework.common.CommonValue.VERSION_FIELD; +import static org.opensearch.flowframework.common.CommonValue.WORKFLOWS_FIELD; /** * The Template is the central data structure which configures workflows. This object is used to parse JSON communicated via REST API. */ public class Template implements ToXContentObject { - /** The template field name for template name */ - private static final String NAME_FIELD = "name"; - /** The template field name for template description */ - private static final String DESCRIPTION_FIELD = "description"; - /** The template field name for template use case */ - private static final String USE_CASE_FIELD = "use_case"; - /** The template field name for template version information */ - private static final String VERSION_FIELD = "version"; - /** The template field name for template version */ - private static final String TEMPLATE_FIELD = "template"; - /** The template field name for template compatibility with OpenSearch versions */ - private static final String COMPATIBILITY_FIELD = "compatibility"; - /** The template field name for template workflows */ - private static final String WORKFLOWS_FIELD = "workflows"; - private final String name; private final String description; private final String useCase; // probably an ENUM actually diff --git a/src/main/java/org/opensearch/flowframework/workflow/CreateConnectorStep.java b/src/main/java/org/opensearch/flowframework/workflow/CreateConnectorStep.java index 498057b0b..e17bf2aa0 100644 --- a/src/main/java/org/opensearch/flowframework/workflow/CreateConnectorStep.java +++ b/src/main/java/org/opensearch/flowframework/workflow/CreateConnectorStep.java @@ -33,7 +33,7 @@ import static org.opensearch.flowframework.common.CommonValue.ACTIONS_FIELD; import static org.opensearch.flowframework.common.CommonValue.CREDENTIALS_FIELD; -import static org.opensearch.flowframework.common.CommonValue.DESCRIPTION; +import static org.opensearch.flowframework.common.CommonValue.DESCRIPTION_FIELD; import static org.opensearch.flowframework.common.CommonValue.NAME_FIELD; import static org.opensearch.flowframework.common.CommonValue.PARAMETERS_FIELD; import static org.opensearch.flowframework.common.CommonValue.PROTOCOL_FIELD; @@ -96,8 +96,8 @@ public void onFailure(Exception e) { case NAME_FIELD: name = (String) content.get(NAME_FIELD); break; - case DESCRIPTION: - description = (String) content.get(DESCRIPTION); + case DESCRIPTION_FIELD: + description = (String) content.get(DESCRIPTION_FIELD); break; case VERSION_FIELD: version = (String) content.get(VERSION_FIELD); diff --git a/src/main/java/org/opensearch/flowframework/workflow/ModelGroupStep.java b/src/main/java/org/opensearch/flowframework/workflow/ModelGroupStep.java index c43411543..9e1010ec1 100644 --- a/src/main/java/org/opensearch/flowframework/workflow/ModelGroupStep.java +++ b/src/main/java/org/opensearch/flowframework/workflow/ModelGroupStep.java @@ -29,7 +29,7 @@ import static org.opensearch.flowframework.common.CommonValue.ADD_ALL_BACKEND_ROLES; import static org.opensearch.flowframework.common.CommonValue.BACKEND_ROLES_FIELD; -import static org.opensearch.flowframework.common.CommonValue.DESCRIPTION; +import static org.opensearch.flowframework.common.CommonValue.DESCRIPTION_FIELD; import static org.opensearch.flowframework.common.CommonValue.MODEL_ACCESS_MODE; import static org.opensearch.flowframework.common.CommonValue.NAME_FIELD; @@ -92,8 +92,8 @@ public void onFailure(Exception e) { case NAME_FIELD: modelGroupName = (String) content.get(NAME_FIELD); break; - case DESCRIPTION: - description = (String) content.get(DESCRIPTION); + case DESCRIPTION_FIELD: + description = (String) content.get(DESCRIPTION_FIELD); break; case BACKEND_ROLES_FIELD: backendRoles = getBackendRoles(content); diff --git a/src/main/java/org/opensearch/flowframework/workflow/RegisterModelStep.java b/src/main/java/org/opensearch/flowframework/workflow/RegisterModelStep.java index df14d6c54..b6ae176d3 100644 --- a/src/main/java/org/opensearch/flowframework/workflow/RegisterModelStep.java +++ b/src/main/java/org/opensearch/flowframework/workflow/RegisterModelStep.java @@ -29,7 +29,7 @@ import java.util.stream.Stream; import static org.opensearch.flowframework.common.CommonValue.CONNECTOR_ID; -import static org.opensearch.flowframework.common.CommonValue.DESCRIPTION; +import static org.opensearch.flowframework.common.CommonValue.DESCRIPTION_FIELD; import static org.opensearch.flowframework.common.CommonValue.FUNCTION_NAME; import static org.opensearch.flowframework.common.CommonValue.MODEL_CONFIG; import static org.opensearch.flowframework.common.CommonValue.MODEL_FORMAT; @@ -114,8 +114,8 @@ public void onFailure(Exception e) { case MODEL_CONFIG: modelConfig = (MLModelConfig) content.get(MODEL_CONFIG); break; - case DESCRIPTION: - description = (String) content.get(DESCRIPTION); + case DESCRIPTION_FIELD: + description = (String) content.get(DESCRIPTION_FIELD); break; case CONNECTOR_ID: connectorId = (String) content.get(CONNECTOR_ID);