diff --git a/CHANGELOG.md b/CHANGELOG.md index d9f1efeb5..fd1426309 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 `/_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 new file mode 100644 index 000000000..05ca612e8 --- /dev/null +++ b/spec/namespaces/flow_framework.yaml @@ -0,0 +1,294 @@ +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.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/ + 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' + 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 + 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/ + 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' + '400': + $ref: '../schemas/flow_framework._common.yaml#/components/schemas/WorkFlowIdNullError' + '403': + $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 + 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/ + 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 + '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: + name: workflow_id + in: path + required: true + schema: + type: string + flow_framework.create::query.provision: + in: query + name: provision + schema: + 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 + default: false + flow_framework.create::query.validation: + in: query + name: validation + schema: + description: 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: 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: 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: + 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. + 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: + 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 + 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. + 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 + 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..a1ef11dc7 --- /dev/null +++ b/spec/schemas/flow_framework._common.yaml @@ -0,0 +1,100 @@ +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 + # eslint-disable-next-line @cspell/spellchecker + # 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 + # eslint-disable-next-line @cspell/spellchecker + # 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 \ No newline at end of file diff --git a/tests/default/flow_framework/workflow.yaml b/tests/default/flow_framework/workflow.yaml new file mode 100644 index 000000000..3081c20ef --- /dev/null +++ b/tests/default/flow_framework/workflow.yaml @@ -0,0 +1,60 @@ +$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 + status: [200, 404] + parameters: + workflow_id: ${create_flow_framework.test_workflow_id} +chapters: + - synopsis: Create workflow. + id: create_flow_framework + path: /_plugins/_flow_framework/workflow + method: POST + request: + payload: + name: test_create_work_flow + response: + status: 201 + output: + test_workflow_id: payload.workflow_id + - synopsis: Get workflow. + id: get_flow_framework + path: /_plugins/_flow_framework/workflow/{workflow_id} + 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: 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} + method: DELETE + parameters: + workflow_id: ${create_flow_framework.test_workflow_id} + response: + status: 200 +