Skip to content

Commit f9f9008

Browse files
authored
fix(orchestrator): implementation of getWorkflowById (v2) (#1233)
fix: implementation of getWorkflowById (v2) Signed-off-by: Gloria Ciavarrini <[email protected]>
1 parent ec8b1c2 commit f9f9008

File tree

5 files changed

+187
-4
lines changed

5 files changed

+187
-4
lines changed

plugins/orchestrator-backend/src/service/router.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,22 @@ function setupInternalRoutes(
198198
});
199199
});
200200

201-
router.get('/workflows', async (_, res) => {
202-
await V1.getWorkflows(services.sonataFlowService, services.dataIndexService)
201+
router.get('/workflows/:workflowId', async (req, res) => {
202+
const {
203+
params: { workflowId },
204+
} = req;
205+
await V1.getWorkflowById(services.sonataFlowService, workflowId)
203206
.then(result => res.status(200).json(result))
204207
.catch(error => {
205208
res.status(500).send(error.message || 'Internal Server Error');
206209
});
207210
});
208211

209212
// v2
210-
api.register('getWorkflows', async (_c, _req, res, next) => {
211-
await V2.getWorkflows(services.sonataFlowService, services.dataIndexService)
213+
api.register('getWorkflowById', async (c, _req, res, next) => {
214+
const workflowId = c.request.params.workflowId as string;
215+
216+
await V2.getWorkflowById(services.sonataFlowService, workflowId)
212217
.then(result => res.json(result))
213218
.catch(error => {
214219
res.status(500).send(error.message || 'Internal Server Error');

plugins/orchestrator-common/src/auto-generated/api/definition.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,45 @@ const OPENAPI = `
174174
}
175175
}
176176
},
177+
"/v2/workflows/{workflowId}": {
178+
"get": {
179+
"operationId": "getWorkflowById",
180+
"description": "Get a workflow by ID",
181+
"parameters": [
182+
{
183+
"name": "workflowId",
184+
"in": "path",
185+
"description": "ID of the workflow to execute",
186+
"required": true,
187+
"schema": {
188+
"type": "string"
189+
}
190+
}
191+
],
192+
"responses": {
193+
"200": {
194+
"description": "Success",
195+
"content": {
196+
"application/json": {
197+
"schema": {
198+
"$ref": "#/components/schemas/WorkflowDTO"
199+
}
200+
}
201+
}
202+
},
203+
"500": {
204+
"description": "Error workflow by id",
205+
"content": {
206+
"text/plain": {
207+
"schema": {
208+
"type": "string"
209+
}
210+
}
211+
}
212+
}
213+
}
214+
}
215+
},
177216
"/v2/workflows/instances": {
178217
"get": {
179218
"operationId": "getInstances",

plugins/orchestrator-common/src/auto-generated/api/models/schema.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export interface paths {
1818
/** Create or update a workflow */
1919
post: operations['createWorkflow'];
2020
};
21+
'/v2/workflows/{workflowId}': {
22+
/** @description Get a workflow by ID */
23+
get: operations['getWorkflowById'];
24+
};
2125
'/v2/workflows/instances': {
2226
/**
2327
* Get instances
@@ -301,6 +305,29 @@ export interface operations {
301305
};
302306
};
303307
};
308+
/** @description Get a workflow by ID */
309+
getWorkflowById: {
310+
parameters: {
311+
path: {
312+
/** @description ID of the workflow to execute */
313+
workflowId: string;
314+
};
315+
};
316+
responses: {
317+
/** @description Success */
318+
200: {
319+
content: {
320+
'application/json': components['schemas']['WorkflowDTO'];
321+
};
322+
};
323+
/** @description Error workflow by id */
324+
500: {
325+
content: {
326+
'text/plain': string;
327+
};
328+
};
329+
};
330+
};
304331
/**
305332
* Get instances
306333
* @description Retrieve an array of instances

plugins/orchestrator-common/src/auto-generated/docs/index.adoc/index.adoc

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,94 @@ ifdef::internal-generation[]
481481
endif::internal-generation[]
482482

483483

484+
[.getWorkflowById]
485+
==== getWorkflowById
486+
487+
`GET /v2/workflows/{workflowId}`
488+
489+
490+
491+
===== Description
492+
493+
Get a workflow by ID
494+
495+
496+
// markup not found, no include::{specDir}v2/workflows/\{workflowId\}/GET/spec.adoc[opts=optional]
497+
498+
499+
500+
===== Parameters
501+
502+
====== Path Parameters
503+
504+
[cols="2,3,1,1,1"]
505+
|===
506+
|Name| Description| Required| Default| Pattern
507+
508+
| workflowId
509+
| ID of the workflow to execute
510+
| X
511+
| null
512+
|
513+
514+
|===
515+
516+
517+
518+
519+
520+
521+
===== Return Type
522+
523+
<<WorkflowDTO>>
524+
525+
526+
===== Content Type
527+
528+
* application/json
529+
* text/plain
530+
531+
===== Responses
532+
533+
.HTTP Response Codes
534+
[cols="2,3,1"]
535+
|===
536+
| Code | Message | Datatype
537+
538+
539+
| 200
540+
| Success
541+
| <<WorkflowDTO>>
542+
543+
544+
| 500
545+
| Error workflow by id
546+
| <<String>>
547+
548+
|===
549+
550+
===== Samples
551+
552+
553+
// markup not found, no include::{snippetDir}v2/workflows/\{workflowId\}/GET/http-request.adoc[opts=optional]
554+
555+
556+
// markup not found, no include::{snippetDir}v2/workflows/\{workflowId\}/GET/http-response.adoc[opts=optional]
557+
558+
559+
560+
// file not found, no * wiremock data link :v2/workflows/{workflowId}/GET/GET.json[]
561+
562+
563+
ifdef::internal-generation[]
564+
===== Implementation
565+
566+
// markup not found, no include::{specDir}v2/workflows/\{workflowId\}/GET/implementation.adoc[opts=optional]
567+
568+
569+
endif::internal-generation[]
570+
571+
484572
[.getWorkflowOverviewById]
485573
==== getWorkflowOverviewById
486574

plugins/orchestrator-common/src/openapi/openapi.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ paths:
105105
text/plain:
106106
schema:
107107
type: string
108+
/v2/workflows/{workflowId}:
109+
get:
110+
operationId: getWorkflowById
111+
description: Get a workflow by ID
112+
parameters:
113+
- name: workflowId
114+
in: path
115+
description: ID of the workflow to execute
116+
required: true
117+
schema:
118+
type: string
119+
responses:
120+
'200':
121+
description: Success
122+
content:
123+
application/json:
124+
schema:
125+
$ref: '#/components/schemas/WorkflowDTO'
126+
'500':
127+
description: Error workflow by id
128+
content:
129+
text/plain:
130+
schema:
131+
type: string
108132
/v2/workflows/instances:
109133
get:
110134
operationId: getInstances

0 commit comments

Comments
 (0)