diff --git a/plugins/orchestrator-backend/src/service/router.ts b/plugins/orchestrator-backend/src/service/router.ts index a7b8ae38a2..966823e68a 100644 --- a/plugins/orchestrator-backend/src/service/router.ts +++ b/plugins/orchestrator-backend/src/service/router.ts @@ -198,8 +198,11 @@ function setupInternalRoutes( }); }); - router.get('/workflows', async (_, res) => { - await V1.getWorkflows(services.sonataFlowService, services.dataIndexService) + router.get('/workflows/:workflowId', async (req, res) => { + const { + params: { workflowId }, + } = req; + await V1.getWorkflowById(services.sonataFlowService, workflowId) .then(result => res.status(200).json(result)) .catch(error => { res.status(500).send(error.message || 'Internal Server Error'); @@ -207,8 +210,10 @@ function setupInternalRoutes( }); // v2 - api.register('getWorkflows', async (_c, _req, res, next) => { - await V2.getWorkflows(services.sonataFlowService, services.dataIndexService) + api.register('getWorkflowById', async (c, _req, res, next) => { + const workflowId = c.request.params.workflowId as string; + + await V2.getWorkflowById(services.sonataFlowService, workflowId) .then(result => res.json(result)) .catch(error => { res.status(500).send(error.message || 'Internal Server Error'); diff --git a/plugins/orchestrator-common/src/auto-generated/api/definition.ts b/plugins/orchestrator-common/src/auto-generated/api/definition.ts index f5f31ab19e..29ff4c17a0 100644 --- a/plugins/orchestrator-common/src/auto-generated/api/definition.ts +++ b/plugins/orchestrator-common/src/auto-generated/api/definition.ts @@ -174,6 +174,45 @@ const OPENAPI = ` } } }, + "/v2/workflows/{workflowId}": { + "get": { + "operationId": "getWorkflowById", + "description": "Get a workflow by ID", + "parameters": [ + { + "name": "workflowId", + "in": "path", + "description": "ID of the workflow to execute", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkflowDTO" + } + } + } + }, + "500": { + "description": "Error workflow by id", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, "/v2/workflows/instances": { "get": { "operationId": "getInstances", diff --git a/plugins/orchestrator-common/src/auto-generated/api/models/schema.ts b/plugins/orchestrator-common/src/auto-generated/api/models/schema.ts index 2cff9cdf12..76fb852d31 100644 --- a/plugins/orchestrator-common/src/auto-generated/api/models/schema.ts +++ b/plugins/orchestrator-common/src/auto-generated/api/models/schema.ts @@ -18,6 +18,10 @@ export interface paths { /** Create or update a workflow */ post: operations['createWorkflow']; }; + '/v2/workflows/{workflowId}': { + /** @description Get a workflow by ID */ + get: operations['getWorkflowById']; + }; '/v2/workflows/instances': { /** * Get instances @@ -301,6 +305,29 @@ export interface operations { }; }; }; + /** @description Get a workflow by ID */ + getWorkflowById: { + parameters: { + path: { + /** @description ID of the workflow to execute */ + workflowId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + 'application/json': components['schemas']['WorkflowDTO']; + }; + }; + /** @description Error workflow by id */ + 500: { + content: { + 'text/plain': string; + }; + }; + }; + }; /** * Get instances * @description Retrieve an array of instances diff --git a/plugins/orchestrator-common/src/auto-generated/docs/index.adoc/index.adoc b/plugins/orchestrator-common/src/auto-generated/docs/index.adoc/index.adoc index e3ec6b6c07..fdf00a2fdb 100644 --- a/plugins/orchestrator-common/src/auto-generated/docs/index.adoc/index.adoc +++ b/plugins/orchestrator-common/src/auto-generated/docs/index.adoc/index.adoc @@ -481,6 +481,94 @@ ifdef::internal-generation[] endif::internal-generation[] +[.getWorkflowById] +==== getWorkflowById + +`GET /v2/workflows/{workflowId}` + + + +===== Description + +Get a workflow by ID + + +// markup not found, no include::{specDir}v2/workflows/\{workflowId\}/GET/spec.adoc[opts=optional] + + + +===== Parameters + +====== Path Parameters + +[cols="2,3,1,1,1"] +|=== +|Name| Description| Required| Default| Pattern + +| workflowId +| ID of the workflow to execute +| X +| null +| + +|=== + + + + + + +===== Return Type + +<> + + +===== Content Type + +* application/json +* text/plain + +===== Responses + +.HTTP Response Codes +[cols="2,3,1"] +|=== +| Code | Message | Datatype + + +| 200 +| Success +| <> + + +| 500 +| Error workflow by id +| <> + +|=== + +===== Samples + + +// markup not found, no include::{snippetDir}v2/workflows/\{workflowId\}/GET/http-request.adoc[opts=optional] + + +// markup not found, no include::{snippetDir}v2/workflows/\{workflowId\}/GET/http-response.adoc[opts=optional] + + + +// file not found, no * wiremock data link :v2/workflows/{workflowId}/GET/GET.json[] + + +ifdef::internal-generation[] +===== Implementation + +// markup not found, no include::{specDir}v2/workflows/\{workflowId\}/GET/implementation.adoc[opts=optional] + + +endif::internal-generation[] + + [.getWorkflowOverviewById] ==== getWorkflowOverviewById diff --git a/plugins/orchestrator-common/src/openapi/openapi.yaml b/plugins/orchestrator-common/src/openapi/openapi.yaml index ec87f248cd..cf30857821 100644 --- a/plugins/orchestrator-common/src/openapi/openapi.yaml +++ b/plugins/orchestrator-common/src/openapi/openapi.yaml @@ -105,6 +105,30 @@ paths: text/plain: schema: type: string + /v2/workflows/{workflowId}: + get: + operationId: getWorkflowById + description: Get a workflow by ID + parameters: + - name: workflowId + in: path + description: ID of the workflow to execute + required: true + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/WorkflowDTO' + '500': + description: Error workflow by id + content: + text/plain: + schema: + type: string /v2/workflows/instances: get: operationId: getInstances