Skip to content

Commit

Permalink
fix(orchestrator): implementation of getWorkflowById (v2) (#1233)
Browse files Browse the repository at this point in the history
fix: implementation of getWorkflowById (v2)

Signed-off-by: Gloria Ciavarrini <[email protected]>
  • Loading branch information
gciavarrini authored Feb 20, 2024
1 parent ec8b1c2 commit f9f9008
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugins/orchestrator-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,22 @@ 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');
});
});

// 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');
Expand Down
39 changes: 39 additions & 0 deletions plugins/orchestrator-common/src/auto-generated/api/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

<<WorkflowDTO>>


===== Content Type

* application/json
* text/plain

===== Responses

.HTTP Response Codes
[cols="2,3,1"]
|===
| Code | Message | Datatype


| 200
| Success
| <<WorkflowDTO>>


| 500
| Error workflow by id
| <<String>>

|===

===== 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

Expand Down
24 changes: 24 additions & 0 deletions plugins/orchestrator-common/src/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f9f9008

Please sign in to comment.