From 919ba98bf09c78f953978dcc222ab2a1eab9c68d Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Thu, 29 Aug 2024 13:06:13 -0700 Subject: [PATCH 01/10] add flow framework create Signed-off-by: Junwei Dai --- spec/namespaces/flow_framework.yaml | 94 ++++++++++++++++++++++ tests/default/flow_framework/workflow.yaml | 15 ++++ 2 files changed, 109 insertions(+) create mode 100644 spec/namespaces/flow_framework.yaml create mode 100644 tests/default/flow_framework/workflow.yaml diff --git a/spec/namespaces/flow_framework.yaml b/spec/namespaces/flow_framework.yaml new file mode 100644 index 000000000..db59eebf1 --- /dev/null +++ b/spec/namespaces/flow_framework.yaml @@ -0,0 +1,94 @@ +openapi: 3.1.0 +info: + title: OpenSearch Flow Framework API + description: OpenSearch Flow Framework API. + version: 1.0.0 +paths: + /_plugins/_flow_framework/workflow: + post: + operationId: flow_framework.create_workflow.0 + x-operation-group: flow_framework.create_workflow + description: Creates a workflow. + externalDocs: + url: https://opensearch.org/docs/latest/automating-configurations/api/create-workflow/ + parameters: + - $ref: '#/components/parameters/flow_framework.create_workflow::query.provision' + requestBody: + $ref: '#/components/requestBodies/flow_framework.create_workflow' + responses: + '201': + $ref: '#/components/responses/flow_framework.create_workflow' + + +# +# /_plugins/_flow_framework/workflow/{workflow_id}: +# delete: { } +# put: { } +# get: { } + + +components: + parameters: + flow_framework.create_workflow::query.provision: + in: query + name: provision + schema: + description: Whether to provision the workflow as part of the request + type: boolean + default: false + requestBodies: + flow_framework.create_workflow: + content: + application/json: + schema: + type: object + properties: + name: + type: string + description: The name of the workflow. + description: + type: string + description: A description of the workflow. + use_case: + type: string + description: A use case, which can be used with the Search Workflow API to find related workflows. + version: + type: object + description: A key-value map with two fields, template, which identifies the template version, and compatibility, which identifies a list of minimum required OpenSearch versions. + workflows: + type: object + description: A map of workflows. Presently, only the provision key is supported. The value for the workflow key is a key-value map that includes fields for user_params and lists of nodes and edges. + required: + - name + responses: + flow_framework.create_workflow: + content: + application/json: + schema: + type: object + properties: + workflow_id: + type: string + description: The ID of the workflow to be updated. Required for the PUT method. + required: + - workflow_id + +# below is for update query field , will change to update workflow +# flow_framework.create_workflow::query.update_fields: +# in: query +# name: update_fields +# schema: +# description: Whether to update only the fields included in the request body. +# type: boolean +# default: false +# +# +# flow_framework.create_workflow::query.validation: +# in: query +# name: validation +# schema: +# description: Whether to validate the workflow. Valid values are all (validate the template) and none (do not validate the template). Default is all. +# type: string +# default: all + + diff --git a/tests/default/flow_framework/workflow.yaml b/tests/default/flow_framework/workflow.yaml new file mode 100644 index 000000000..68cc67dbe --- /dev/null +++ b/tests/default/flow_framework/workflow.yaml @@ -0,0 +1,15 @@ +$schema: ../../../json_schemas/test_story.schema.yaml +description: Test flow_framework endpoints. + + +chapters: + - synopsis: Create workflow. + id: create_flow_framework_group + path: /_plugins/_flow_framework/workflow + method: POST + request: + payload: + name: test_create_work_flow + response: + status: 201 + From 1b79010b8bd74453f2ec045c960ee14d9bb5aeb8 Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Fri, 30 Aug 2024 10:58:05 -0700 Subject: [PATCH 02/10] add flow framework delete Signed-off-by: Junwei Dai --- spec/namespaces/flow_framework.yaml | 97 ++++++++++++++++++---- tests/default/flow_framework/workflow.yaml | 7 ++ 2 files changed, 90 insertions(+), 14 deletions(-) diff --git a/spec/namespaces/flow_framework.yaml b/spec/namespaces/flow_framework.yaml index db59eebf1..1a4ce24d5 100644 --- a/spec/namespaces/flow_framework.yaml +++ b/spec/namespaces/flow_framework.yaml @@ -6,38 +6,61 @@ info: paths: /_plugins/_flow_framework/workflow: post: - operationId: flow_framework.create_workflow.0 - x-operation-group: flow_framework.create_workflow - description: Creates a workflow. + operationId: flow_framework.create.0 + x-operation-group: flow_framework.create + description: Create a workflow. externalDocs: url: https://opensearch.org/docs/latest/automating-configurations/api/create-workflow/ parameters: - - $ref: '#/components/parameters/flow_framework.create_workflow::query.provision' + - $ref: '#/components/parameters/flow_framework.create::query.provision' requestBody: - $ref: '#/components/requestBodies/flow_framework.create_workflow' + $ref: '#/components/requestBodies/flow_framework.create' responses: '201': - $ref: '#/components/responses/flow_framework.create_workflow' + $ref: '#/components/responses/flow_framework.create' -# -# /_plugins/_flow_framework/workflow/{workflow_id}: -# delete: { } + + /_plugins/_flow_framework/workflow/{workflow_id}: + delete: + operationId: flow_framework.delete.0 + x-operation-group: flow_framework.delete + description: Delete a workflow. + externalDocs: + url: https://opensearch.org/docs/latest/automating-configurations/api/delete-workflow/ + parameters: + - $ref: '#/components/parameters/flow_framework.delete::query.clear_status' + responses: + '200': + $ref: '#/components/responses/flow_framework.delete' + '404': + description: Workflow not found. + # put: { } # get: { } components: parameters: - flow_framework.create_workflow::query.provision: + flow_framework.create::query.provision: in: query name: provision schema: description: Whether to provision the workflow as part of the request type: boolean default: false + + flow_framework.delete::query.clear_status: + in: query + name: clear_status + schema: + description: Determines whether to delete the workflow state (without deprovisioning resources) after deleting the template. OpenSearch deletes the workflow state only if the provisioning status is not IN_PROGRESS. Default is false. + type: boolean + default: false + + requestBodies: - flow_framework.create_workflow: + flow_framework.create: content: application/json: schema: @@ -61,7 +84,7 @@ components: required: - name responses: - flow_framework.create_workflow: + flow_framework.create: content: application/json: schema: @@ -72,9 +95,55 @@ components: description: The ID of the workflow to be updated. Required for the PUT method. required: - workflow_id + flow_framework.delete: + content: + application/json: + schema: + type: object + properties: + _index: + type: string + description: The name of the index where the document was stored. + _id: + type: string + description: The unique identifier of the deleted document. + _version: + type: integer + description: The version of the document after the deletion. + result: + type: string + description: The result of the deletion operation. + enum: [ "deleted", "not_found" ] + _shards: + type: object + properties: + total: + type: integer + description: The total number of shards involved in the deletion. + successful: + type: integer + description: The number of shards where the deletion was successful. + failed: + type: integer + description: The number of shards where the deletion failed. + _seq_no: + type: integer + description: The sequence number assigned to the document after the deletion. + _primary_term: + type: integer + description: The primary term assigned to the document after the deletion. + required: + - _index + - _id + - _version + - result + - _shards + - _seq_no + - _primary_term + # below is for update query field , will change to update workflow -# flow_framework.create_workflow::query.update_fields: +# flow_framework.create::query.update_fields: # in: query # name: update_fields # schema: @@ -83,7 +152,7 @@ components: # default: false # # -# flow_framework.create_workflow::query.validation: +# flow_framework.create::query.validation: # in: query # name: validation # schema: diff --git a/tests/default/flow_framework/workflow.yaml b/tests/default/flow_framework/workflow.yaml index 68cc67dbe..f8af31012 100644 --- a/tests/default/flow_framework/workflow.yaml +++ b/tests/default/flow_framework/workflow.yaml @@ -12,4 +12,11 @@ chapters: name: test_create_work_flow response: status: 201 + - synopsis: Delete workflow. + id: delete_flow_framework_group + path: /_plugins/_flow_framework/workflow/{workflow_id} + method: DELETE + response: + status: 200 + From b83b623b80d5fc4268745d4844c9a88d73e9c4e4 Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Tue, 3 Sep 2024 13:19:42 -0700 Subject: [PATCH 03/10] add flow framework put and get Signed-off-by: Junwei Dai --- spec/namespaces/flow_framework.yaml | 171 ++++++++++++++++----- tests/default/flow_framework/workflow.yaml | 33 +++- 2 files changed, 165 insertions(+), 39 deletions(-) diff --git a/spec/namespaces/flow_framework.yaml b/spec/namespaces/flow_framework.yaml index 1a4ce24d5..b05c4c3de 100644 --- a/spec/namespaces/flow_framework.yaml +++ b/spec/namespaces/flow_framework.yaml @@ -13,14 +13,13 @@ paths: url: https://opensearch.org/docs/latest/automating-configurations/api/create-workflow/ parameters: - $ref: '#/components/parameters/flow_framework.create::query.provision' + - $ref: '#/components/parameters/flow_framework.create::query.validation' + requestBody: $ref: '#/components/requestBodies/flow_framework.create' responses: '201': $ref: '#/components/responses/flow_framework.create' - - - /_plugins/_flow_framework/workflow/{workflow_id}: delete: operationId: flow_framework.delete.0 @@ -33,15 +32,42 @@ paths: responses: '200': $ref: '#/components/responses/flow_framework.delete' - '404': - description: Workflow not found. - -# put: { } -# get: { } + '403': + description: if workflow id is null. + put: + operationId: flow_framework.update.0 + x-operation-group: flow_framework.update + description: Update a workflow. You can only update a complete workflow if it has not yet been provisioned. + externalDocs: + url: https://opensearch.org/docs/latest/automating-configurations/api/create-workflow/ + parameters: + - $ref: '#/components/parameters/flow_framework.update::query.update_fields' + - $ref: '#/components/parameters/flow_framework.get::path.workflow_id' + requestBody: + $ref: '#/components/requestBodies/flow_framework.update' + responses: + '201': + $ref: '#/components/responses/flow_framework.create' + description: It returns the workflow_id + get: + operationId: flow_framework.get.0 + x-operation-group: flow_framework.get + description: Get a workflow. + parameters: + - $ref: '#/components/parameters/flow_framework.get::path.workflow_id' + responses: + '200': + $ref: '#/components/responses/flow_framework.get' components: parameters: + flow_framework.get::path.workflow_id: + name: workflow_id + in: path + required: true + schema: + type: string flow_framework.create::query.provision: in: query name: provision @@ -49,6 +75,20 @@ components: description: Whether to provision the workflow as part of the request type: boolean default: false + flow_framework.create::query.validation: + in: query + name: validation + schema: + description: Whether to validate the workflow. Valid values are all (validate the template) and none (do not validate the template). Default is all. + type: string + default: all + flow_framework.update::query.update_fields: + in: query + name: update_fields + schema: + description: Whether to update only the fields included in the request body. + type: boolean + default: false flow_framework.delete::query.clear_status: in: query @@ -78,11 +118,58 @@ components: version: type: object description: A key-value map with two fields, template, which identifies the template version, and compatibility, which identifies a list of minimum required OpenSearch versions. + properties: + template: + type: string + description: The template version of the workflow. + compatibility: + type: array + items: + type: string + description: A list of minimum required OpenSearch versions. + workflows: type: object description: A map of workflows. Presently, only the provision key is supported. The value for the workflow key is a key-value map that includes fields for user_params and lists of nodes and edges. required: - name + + flow_framework.update: + content: + application/json: + schema: + type: object + properties: + name: + type: string + description: The name of the workflow. + description: + type: string + description: A description of the workflow. + use_case: + type: string + description: A use case, which can be used with the Search Workflow API to find related workflows. + version: + type: object + description: A key-value map with two fields, template, which identifies the template version, and compatibility, which identifies a list of minimum required OpenSearch versions. + properties: + template: + type: string + description: The template version of the workflow. + compatibility: + type: array + items: + type: string + description: A list of minimum required OpenSearch versions. + + oneOf: + - required: [ "name" ] + - required: [ "description" ] + - required: [ "use_case" ] + - required: [ "version" ] + + + responses: flow_framework.create: content: @@ -132,32 +219,46 @@ components: _primary_term: type: integer description: The primary term assigned to the document after the deletion. - required: - - _index - - _id - - _version - - result - - _shards - - _seq_no - - _primary_term - - -# below is for update query field , will change to update workflow -# flow_framework.create::query.update_fields: -# in: query -# name: update_fields -# schema: -# description: Whether to update only the fields included in the request body. -# type: boolean -# default: false -# -# -# flow_framework.create::query.validation: -# in: query -# name: validation -# schema: -# description: Whether to validate the workflow. Valid values are all (validate the template) and none (do not validate the template). Default is all. -# type: string -# default: all + + flow_framework.get: + content: + application/json: + schema: + type: object + properties: + name: + type: string + description: + type: string + use_case: + type: string + workflows: + type: object + user: + type: object + properties: + name: + type: string + backend_roles: + type: array + items: + type: string + roles: + type: array + items: + type: string + custom_attribute_names: + type: array + items: + type: string + user_requested_tenant: + type: string + nullable: true + created_time: + type: integer + last_updated_time: + type: integer + + diff --git a/tests/default/flow_framework/workflow.yaml b/tests/default/flow_framework/workflow.yaml index f8af31012..c50060b6a 100644 --- a/tests/default/flow_framework/workflow.yaml +++ b/tests/default/flow_framework/workflow.yaml @@ -4,7 +4,7 @@ description: Test flow_framework endpoints. chapters: - synopsis: Create workflow. - id: create_flow_framework_group + id: create_flow_framework path: /_plugins/_flow_framework/workflow method: POST request: @@ -12,11 +12,36 @@ chapters: name: test_create_work_flow response: status: 201 - - synopsis: Delete workflow. - id: delete_flow_framework_group + output: + test_workflow_id: payload.workflow_id + + + + + - synopsis: Get workflow. + id: get_flow_framework path: /_plugins/_flow_framework/workflow/{workflow_id} - method: DELETE + method: GET + parameters: + workflow_id: ${create_flow_framework.test_workflow_id} response: status: 200 + - synopsis: Update workflow. + id: get_flow_framework + path: /_plugins/_flow_framework/workflow/{workflow_id} + method: PUT + parameters: + workflow_id: ${create_flow_framework.test_workflow_id} + request: + payload: + name: test_update_work_flow + response: + status: 201 + - synopsis: Delete workflow. + id: delete_flow_framework + path: /_plugins/_flow_framework/workflow/{workflow_id} + method: DELETE + response: + status: 200 \ No newline at end of file From 5bde07a3a329e0861e511ac70e6ceb801c10a137 Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Tue, 3 Sep 2024 13:24:09 -0700 Subject: [PATCH 04/10] add changelog info Signed-off-by: Junwei Dai --- CHANGELOG.md | 3 ++- spec/namespaces/flow_framework.yaml | 13 +++++-------- tests/default/flow_framework/workflow.yaml | 4 +--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9f1efeb5..e242c7cc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added 404 responses to `/_alias/{name}` and `/{index}/_alias/{name}` ([#519](https://github.com/opensearch-project/opensearch-api-specification/pull/519)) - Added `asynchronous_search` ([#525](https://github.com/opensearch-project/opensearch-api-specification/pull/525)) - Added `DELETE /_plugins/_ml/tasks/{task_id}` ([#530](https://github.com/opensearch-project/opensearch-api-specification/pull/530)) +- Added API spec for flow framework plugin ([#508](https://github.com/opensearch-project/opensearch-api-specification/issues/508)) ### Changed @@ -94,7 +95,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Lock testing for next release of OpenSearch to a specific SHA ([#431](https://github.com/opensearch-project/opensearch-api-specification/pull/431)) - Replace nullable with null type ([#436](https://github.com/opensearch-project/opensearch-api-specification/pull/436)) - Split test suite ([#472])(https://github.com/opensearch-project/opensearch-api-specification/pull/472) -- Changed `WriteResponseBase`'s `_primary_term`, `_seq_no` & `_version` to have `int64` format ([#530](https://github.com/opensearch-project/opensearch-api-specification/pull/530)) +- Changed `WriteResponseBase`'s `_primary_term`, `_seq_no` & `_version` to have `int64` format ([#508](https://github.com/opensearch-project/opensearch-api-specification/pull/530)) ### Deprecated diff --git a/spec/namespaces/flow_framework.yaml b/spec/namespaces/flow_framework.yaml index b05c4c3de..6befbbeb2 100644 --- a/spec/namespaces/flow_framework.yaml +++ b/spec/namespaces/flow_framework.yaml @@ -163,11 +163,10 @@ components: description: A list of minimum required OpenSearch versions. oneOf: - - required: [ "name" ] - - required: [ "description" ] - - required: [ "use_case" ] - - required: [ "version" ] - + - required: [name] + - required: [description] + - required: [use_case] + - required: [version] responses: @@ -200,7 +199,7 @@ components: result: type: string description: The result of the deletion operation. - enum: [ "deleted", "not_found" ] + enum: [deleted, not_found] _shards: type: object properties: @@ -260,5 +259,3 @@ components: type: integer - - diff --git a/tests/default/flow_framework/workflow.yaml b/tests/default/flow_framework/workflow.yaml index c50060b6a..4ad9c7f54 100644 --- a/tests/default/flow_framework/workflow.yaml +++ b/tests/default/flow_framework/workflow.yaml @@ -13,9 +13,7 @@ chapters: response: status: 201 output: - test_workflow_id: payload.workflow_id - - + test_workflow_id: payload.workflow_id - synopsis: Get workflow. From 9b58945ac643f537fd49929406b6a54d7d9641c6 Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Tue, 3 Sep 2024 13:37:57 -0700 Subject: [PATCH 05/10] fix mistype error Signed-off-by: Junwei Dai --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e242c7cc5..2a61f4ba9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,7 +95,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Lock testing for next release of OpenSearch to a specific SHA ([#431](https://github.com/opensearch-project/opensearch-api-specification/pull/431)) - Replace nullable with null type ([#436](https://github.com/opensearch-project/opensearch-api-specification/pull/436)) - Split test suite ([#472])(https://github.com/opensearch-project/opensearch-api-specification/pull/472) -- Changed `WriteResponseBase`'s `_primary_term`, `_seq_no` & `_version` to have `int64` format ([#508](https://github.com/opensearch-project/opensearch-api-specification/pull/530)) +- Changed `WriteResponseBase`'s `_primary_term`, `_seq_no` & `_version` to have `int64` format ([#530](https://github.com/opensearch-project/opensearch-api-specification/pull/530)) ### Deprecated From 6dca19de0a3e2a51baf3cd5c5abd46f0e34d9a1e Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Tue, 3 Sep 2024 15:35:07 -0700 Subject: [PATCH 06/10] fix mistype error refactor: 1.add epilogues that deletes the workflow if it was created. 2.rewrite all the 'whether' 3. remove empty lines 4. add validation enum Signed-off-by: Junwei Dai --- CHANGELOG.md | 2 +- spec/namespaces/flow_framework.yaml | 46 +++++++++++----------- tests/default/flow_framework/workflow.yaml | 12 +++--- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a61f4ba9..fd1426309 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,7 +81,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added 404 responses to `/_alias/{name}` and `/{index}/_alias/{name}` ([#519](https://github.com/opensearch-project/opensearch-api-specification/pull/519)) - Added `asynchronous_search` ([#525](https://github.com/opensearch-project/opensearch-api-specification/pull/525)) - Added `DELETE /_plugins/_ml/tasks/{task_id}` ([#530](https://github.com/opensearch-project/opensearch-api-specification/pull/530)) -- Added API spec for flow framework plugin ([#508](https://github.com/opensearch-project/opensearch-api-specification/issues/508)) +- Added `/_plugins/_flow_framework` ([#508](https://github.com/opensearch-project/opensearch-api-specification/issues/508)) ### Changed diff --git a/spec/namespaces/flow_framework.yaml b/spec/namespaces/flow_framework.yaml index 6befbbeb2..71fd6309c 100644 --- a/spec/namespaces/flow_framework.yaml +++ b/spec/namespaces/flow_framework.yaml @@ -14,7 +14,7 @@ paths: parameters: - $ref: '#/components/parameters/flow_framework.create::query.provision' - $ref: '#/components/parameters/flow_framework.create::query.validation' - + - $ref: '#/components/parameters/flow_framework.create::query.reprovision' requestBody: $ref: '#/components/requestBodies/flow_framework.create' responses: @@ -58,8 +58,6 @@ paths: responses: '200': $ref: '#/components/responses/flow_framework.get' - - components: parameters: flow_framework.get::path.workflow_id: @@ -72,33 +70,41 @@ components: in: query name: provision schema: - description: Whether to provision the workflow as part of the request + description: Provision the workflow as part of the request + type: boolean + default: false + flow_framework.create::query.reprovision: + x-version-added: 2.17 + in: query + name: reprovision + schema: + description: type: boolean default: false flow_framework.create::query.validation: in: query name: validation schema: - description: Whether to validate the workflow. Valid values are all (validate the template) and none (do not validate the template). Default is all. + description: Validate the workflow. Valid values are all (validate the template) and none (do not validate the template). Default is all. type: string + enum: + - all + - none default: all flow_framework.update::query.update_fields: in: query name: update_fields schema: - description: Whether to update only the fields included in the request body. + description: Update only the fields included in the request body. type: boolean default: false - flow_framework.delete::query.clear_status: in: query name: clear_status schema: - description: Determines whether to delete the workflow state (without deprovisioning resources) after deleting the template. OpenSearch deletes the workflow state only if the provisioning status is not IN_PROGRESS. Default is false. + description: Delete the workflow state (without deprovisioning resources) after deleting the template. OpenSearch deletes the workflow state only if the provisioning status is not IN_PROGRESS. Default is false. type: boolean default: false - - requestBodies: flow_framework.create: content: @@ -127,13 +133,11 @@ components: items: type: string description: A list of minimum required OpenSearch versions. - workflows: type: object description: A map of workflows. Presently, only the provision key is supported. The value for the workflow key is a key-value map that includes fields for user_params and lists of nodes and edges. required: - name - flow_framework.update: content: application/json: @@ -161,14 +165,11 @@ components: items: type: string description: A list of minimum required OpenSearch versions. - oneOf: - - required: [name] - - required: [description] - - required: [use_case] - - required: [version] - - + - required: [ name ] + - required: [ description ] + - required: [ use_case ] + - required: [ version ] responses: flow_framework.create: content: @@ -199,7 +200,7 @@ components: result: type: string description: The result of the deletion operation. - enum: [deleted, not_found] + enum: [ deleted, not_found ] _shards: type: object properties: @@ -218,7 +219,6 @@ components: _primary_term: type: integer description: The primary term assigned to the document after the deletion. - flow_framework.get: content: application/json: @@ -256,6 +256,4 @@ components: created_time: type: integer last_updated_time: - type: integer - - + type: integer \ No newline at end of file diff --git a/tests/default/flow_framework/workflow.yaml b/tests/default/flow_framework/workflow.yaml index 4ad9c7f54..f29068317 100644 --- a/tests/default/flow_framework/workflow.yaml +++ b/tests/default/flow_framework/workflow.yaml @@ -1,7 +1,11 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test flow_framework endpoints. - - +epilogues: + - path: /_plugins/_flow_framework/workflow/{workflow_id} + method: DELETE + status: [200, 404] + parameters: + workflow_id: ${create_flow_framework.test_workflow_id} chapters: - synopsis: Create workflow. id: create_flow_framework @@ -14,8 +18,6 @@ chapters: status: 201 output: test_workflow_id: payload.workflow_id - - - synopsis: Get workflow. id: get_flow_framework path: /_plugins/_flow_framework/workflow/{workflow_id} @@ -24,7 +26,6 @@ chapters: workflow_id: ${create_flow_framework.test_workflow_id} response: status: 200 - - synopsis: Update workflow. id: get_flow_framework path: /_plugins/_flow_framework/workflow/{workflow_id} @@ -36,7 +37,6 @@ chapters: name: test_update_work_flow response: status: 201 - - synopsis: Delete workflow. id: delete_flow_framework path: /_plugins/_flow_framework/workflow/{workflow_id} From df64fc88082714fcfa2ccc61a00520a9a0bc13e9 Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Tue, 3 Sep 2024 21:23:49 -0700 Subject: [PATCH 07/10] refactor: add version to flow framework and test Signed-off-by: Junwei Dai --- spec/namespaces/flow_framework.yaml | 19 ++++++++++--------- tests/default/flow_framework/workflow.yaml | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/spec/namespaces/flow_framework.yaml b/spec/namespaces/flow_framework.yaml index 71fd6309c..a1a96a7c5 100644 --- a/spec/namespaces/flow_framework.yaml +++ b/spec/namespaces/flow_framework.yaml @@ -8,6 +8,7 @@ paths: post: operationId: flow_framework.create.0 x-operation-group: flow_framework.create + x-version-added: '2.12' description: Create a workflow. externalDocs: url: https://opensearch.org/docs/latest/automating-configurations/api/create-workflow/ @@ -24,6 +25,7 @@ paths: delete: operationId: flow_framework.delete.0 x-operation-group: flow_framework.delete + x-version-added: '2.12' description: Delete a workflow. externalDocs: url: https://opensearch.org/docs/latest/automating-configurations/api/delete-workflow/ @@ -37,6 +39,7 @@ paths: put: operationId: flow_framework.update.0 x-operation-group: flow_framework.update + x-version-added: '2.12' description: Update a workflow. You can only update a complete workflow if it has not yet been provisioned. externalDocs: url: https://opensearch.org/docs/latest/automating-configurations/api/create-workflow/ @@ -52,6 +55,7 @@ paths: get: operationId: flow_framework.get.0 x-operation-group: flow_framework.get + x-version-added: '2.12' description: Get a workflow. parameters: - $ref: '#/components/parameters/flow_framework.get::path.workflow_id' @@ -74,7 +78,7 @@ components: type: boolean default: false flow_framework.create::query.reprovision: - x-version-added: 2.17 + x-version-added: '2.17' in: query name: reprovision schema: @@ -87,9 +91,6 @@ components: schema: description: Validate the workflow. Valid values are all (validate the template) and none (do not validate the template). Default is all. type: string - enum: - - all - - none default: all flow_framework.update::query.update_fields: in: query @@ -166,10 +167,10 @@ components: type: string description: A list of minimum required OpenSearch versions. oneOf: - - required: [ name ] - - required: [ description ] - - required: [ use_case ] - - required: [ version ] + - required: [name] + - required: [description] + - required: [use_case] + - required: [version] responses: flow_framework.create: content: @@ -200,7 +201,7 @@ components: result: type: string description: The result of the deletion operation. - enum: [ deleted, not_found ] + enum: [deleted, not_found] _shards: type: object properties: diff --git a/tests/default/flow_framework/workflow.yaml b/tests/default/flow_framework/workflow.yaml index f29068317..0e9383a5b 100644 --- a/tests/default/flow_framework/workflow.yaml +++ b/tests/default/flow_framework/workflow.yaml @@ -1,5 +1,6 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test flow_framework endpoints. +version: '>=2.12' epilogues: - path: /_plugins/_flow_framework/workflow/{workflow_id} method: DELETE From cb8533689da95b765b722c85094a50fd4dd801a6 Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Tue, 3 Sep 2024 21:32:03 -0700 Subject: [PATCH 08/10] refactor: add delete path param, add delete test, would also delete the workflow previously created Signed-off-by: Junwei Dai --- spec/namespaces/flow_framework.yaml | 1 + tests/default/flow_framework/workflow.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/spec/namespaces/flow_framework.yaml b/spec/namespaces/flow_framework.yaml index a1a96a7c5..c04dd5988 100644 --- a/spec/namespaces/flow_framework.yaml +++ b/spec/namespaces/flow_framework.yaml @@ -31,6 +31,7 @@ paths: url: https://opensearch.org/docs/latest/automating-configurations/api/delete-workflow/ parameters: - $ref: '#/components/parameters/flow_framework.delete::query.clear_status' + - $ref: '#/components/parameters/flow_framework.get::path.workflow_id' responses: '200': $ref: '#/components/responses/flow_framework.delete' diff --git a/tests/default/flow_framework/workflow.yaml b/tests/default/flow_framework/workflow.yaml index 0e9383a5b..f0d33525e 100644 --- a/tests/default/flow_framework/workflow.yaml +++ b/tests/default/flow_framework/workflow.yaml @@ -42,5 +42,7 @@ chapters: id: delete_flow_framework path: /_plugins/_flow_framework/workflow/{workflow_id} method: DELETE + parameters: + workflow_id: ${create_flow_framework.test_workflow_id} response: status: 200 \ No newline at end of file From c749e79ce915ea5191f219a6d14e757abf48f138 Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Wed, 4 Sep 2024 13:40:57 -0700 Subject: [PATCH 09/10] refactor: Add schema for 4xx response Signed-off-by: Junwei Dai --- spec/namespaces/flow_framework.yaml | 36 +++++++- spec/schemas/flow_framework._common.yaml | 98 ++++++++++++++++++++++ tests/default/flow_framework/workflow.yaml | 14 +++- 3 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 spec/schemas/flow_framework._common.yaml diff --git a/spec/namespaces/flow_framework.yaml b/spec/namespaces/flow_framework.yaml index c04dd5988..ee57891b7 100644 --- a/spec/namespaces/flow_framework.yaml +++ b/spec/namespaces/flow_framework.yaml @@ -21,6 +21,17 @@ paths: responses: '201': $ref: '#/components/responses/flow_framework.create' + '403': + $ref: '../schemas/flow_framework._common.yaml#/components/schemas/FlowFrameworkException' + '400': + description: Bad Request - Multiple possible reasons + oneOf: + - $ref: '../schemas/flow_framework._common.yaml#/components/schemas/BadRequestError' + - $ref: '../schemas/flow_framework._common.yaml#/components/schemas/ConflictError' + - $ref: '../schemas/flow_framework._common.yaml#/components/schemas/MissingParameterError' + - $ref: '../schemas/flow_framework._common.yaml#/components/schemas/ParameterConflictError' + - $ref: '../schemas/flow_framework._common.yaml#/components/schemas/MaxWorkflowsLimitError' + - $ref: '../schemas/flow_framework._common.yaml#/components/schemas/WorkflowSaveError' /_plugins/_flow_framework/workflow/{workflow_id}: delete: operationId: flow_framework.delete.0 @@ -35,8 +46,12 @@ paths: responses: '200': $ref: '#/components/responses/flow_framework.delete' + '400': + $ref: '../schemas/flow_framework._common.yaml#/components/schemas/WorkFlowIdNullError' '403': - description: if workflow id is null. + $ref: '../schemas/flow_framework._common.yaml#/components/schemas/FlowFrameworkException' + '404': + $ref: '../schemas/flow_framework._common.yaml#/components/schemas/TemplateNotFoundError' put: operationId: flow_framework.update.0 x-operation-group: flow_framework.update @@ -53,16 +68,22 @@ paths: '201': $ref: '#/components/responses/flow_framework.create' description: It returns the workflow_id + '404': + $ref: '../schemas/flow_framework._common.yaml#/components/schemas/TemplateNotFoundError' get: operationId: flow_framework.get.0 x-operation-group: flow_framework.get x-version-added: '2.12' + externalDocs: + url: https://opensearch.org/docs/latest/automating-configurations/api/get-workflow/ description: Get a workflow. parameters: - $ref: '#/components/parameters/flow_framework.get::path.workflow_id' responses: '200': $ref: '#/components/responses/flow_framework.get' + '404': + $ref: '../schemas/flow_framework._common.yaml#/components/schemas/TemplateNotFoundError' components: parameters: flow_framework.get::path.workflow_id: @@ -83,7 +104,6 @@ components: in: query name: reprovision schema: - description: type: boolean default: false flow_framework.create::query.validation: @@ -258,4 +278,14 @@ components: created_time: type: integer last_updated_time: - type: integer \ No newline at end of file + type: integer + flow_framework.update@404: + content: + application/json: { } + flow_framework.create@400: + content: + application/json: { } + flow_framework.delete@400: + content: + description: Workflow ID can not be null + application/json: { } \ No newline at end of file diff --git a/spec/schemas/flow_framework._common.yaml b/spec/schemas/flow_framework._common.yaml new file mode 100644 index 000000000..2ba8a54a7 --- /dev/null +++ b/spec/schemas/flow_framework._common.yaml @@ -0,0 +1,98 @@ +openapi: 3.1.0 +info: + title: Schemas of flow_framework._common category + description: Schemas of flow_framework._common category + version: 1.0.0 +paths: { } +components: + schemas: + FlowFrameworkException: + content: + application/json: + type: object + properties: + message: + type: string + # example: "This API is disabled. To enable it, set [flow_framework.enabled] to true." + status: + type: integer + BadRequestError: + content: + application/json: + type: object + properties: + message: + type: string + # example: "Only the parameters [param1, param2] are permitted unless the provision parameter is set to true." + status: + type: integer + ConflictError: + content: + application/json: + type: object + properties: + message: + type: string + # example: "You cannot use both the 'provision_workflow' and 'update_workflow_fields' parameters in the same request." + status: + type: integer + MissingParameterError: + content: + application/json: + type: object + properties: + message: + type: string + # example: "You cannot use the 'reprovision_workflow' parameter to create a new template." + status: + type: integer + ParameterConflictError: + content: + application/json: + type: object + properties: + message: + type: string + # example: "You cannot use the 'reprovision_workflow' and 'use_case' parameters in the same request." + status: + type: integer + WorkFlowIdNullError: + content: + application/json: + type: object + properties: + message: + type: string + # example: "Workflow ID can not be null" + status: + type: integer + WorkflowSaveError: + content: + application/json: + type: object + properties: + message: + type: string + # example: "Failed to save workflow state" + status: + type: integer + MaxWorkflowsLimitError: + content: + application/json: + type: object + properties: + message: + type: string + # example: "Maximum workflows limit reached: 50" + code: + type: integer + TemplateNotFoundError: + content: + application/json: + type: object + properties: + message: + type: string + # example: "Failed to retrieve template (12345) from global context." + code: + type: integer diff --git a/tests/default/flow_framework/workflow.yaml b/tests/default/flow_framework/workflow.yaml index f0d33525e..3081c20ef 100644 --- a/tests/default/flow_framework/workflow.yaml +++ b/tests/default/flow_framework/workflow.yaml @@ -38,6 +38,17 @@ chapters: name: test_update_work_flow response: status: 201 + - synopsis: Update workflow with a non-existent workflow ID. + id: get_flow_framework + path: /_plugins/_flow_framework/workflow/{workflow_id} + method: PUT + parameters: + workflow_id: test + request: + payload: + name: test_update_work_flow + response: + status: 404 - synopsis: Delete workflow. id: delete_flow_framework path: /_plugins/_flow_framework/workflow/{workflow_id} @@ -45,4 +56,5 @@ chapters: parameters: workflow_id: ${create_flow_framework.test_workflow_id} response: - status: 200 \ No newline at end of file + status: 200 + From 94f158d8fba0cdee5c4fb315a1d61e23e1cb75cf Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Wed, 4 Sep 2024 13:57:19 -0700 Subject: [PATCH 10/10] refactor: Add eslint ignore 'reprovision' Signed-off-by: Junwei Dai --- spec/namespaces/flow_framework.yaml | 3 +++ spec/schemas/flow_framework._common.yaml | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/namespaces/flow_framework.yaml b/spec/namespaces/flow_framework.yaml index ee57891b7..05ca612e8 100644 --- a/spec/namespaces/flow_framework.yaml +++ b/spec/namespaces/flow_framework.yaml @@ -15,6 +15,7 @@ paths: parameters: - $ref: '#/components/parameters/flow_framework.create::query.provision' - $ref: '#/components/parameters/flow_framework.create::query.validation' + # eslint-disable-next-line @cspell/spellchecker - $ref: '#/components/parameters/flow_framework.create::query.reprovision' requestBody: $ref: '#/components/requestBodies/flow_framework.create' @@ -99,9 +100,11 @@ components: description: Provision the workflow as part of the request type: boolean default: false + # eslint-disable-next-line @cspell/spellchecker flow_framework.create::query.reprovision: x-version-added: '2.17' in: query + # eslint-disable-next-line @cspell/spellchecker name: reprovision schema: type: boolean diff --git a/spec/schemas/flow_framework._common.yaml b/spec/schemas/flow_framework._common.yaml index 2ba8a54a7..a1ef11dc7 100644 --- a/spec/schemas/flow_framework._common.yaml +++ b/spec/schemas/flow_framework._common.yaml @@ -3,7 +3,7 @@ info: title: Schemas of flow_framework._common category description: Schemas of flow_framework._common category version: 1.0.0 -paths: { } +paths: {} components: schemas: FlowFrameworkException: @@ -43,6 +43,7 @@ components: properties: message: type: string + # eslint-disable-next-line @cspell/spellchecker # example: "You cannot use the 'reprovision_workflow' parameter to create a new template." status: type: integer @@ -53,6 +54,7 @@ components: properties: message: type: string + # eslint-disable-next-line @cspell/spellchecker # example: "You cannot use the 'reprovision_workflow' and 'use_case' parameters in the same request." status: type: integer @@ -95,4 +97,4 @@ components: type: string # example: "Failed to retrieve template (12345) from global context." code: - type: integer + type: integer \ No newline at end of file