forked from opensearch-project/dashboards-flow-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflow_framework_plugin.ts
88 lines (79 loc) · 2.17 KB
/
flow_framework_plugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import {
FLOW_FRAMEWORK_SEARCH_WORKFLOWS_ROUTE,
FLOW_FRAMEWORK_SEARCH_WORKFLOW_STATE_ROUTE,
FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX,
} from '../../common';
/**
* Used during the plugin's setup() lifecycle phase to register various client actions
* representing Flow Framework plugin APIs. These are then exposed and used on the
* server-side when processing node APIs - see server/routes/flow_framework_routes_service
* for examples.
*/
export function flowFrameworkPlugin(Client: any, config: any, components: any) {
const ca = components.clientAction.factory;
Client.prototype.flowFramework = components.clientAction.namespaceFactory();
const flowFramework = Client.prototype.flowFramework.prototype;
flowFramework.getWorkflow = ca({
url: {
fmt: `${FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX}/<%=workflow_id%>`,
req: {
workflow_id: {
type: 'string',
required: true,
},
},
},
method: 'GET',
});
flowFramework.searchWorkflows = ca({
url: {
fmt: FLOW_FRAMEWORK_SEARCH_WORKFLOWS_ROUTE,
},
needBody: true,
// Exposed client rejects making GET requests with a body. So, we use POST
method: 'POST',
});
flowFramework.getWorkflowState = ca({
url: {
fmt: `${FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX}/<%=workflow_id%>/_status`,
req: {
workflow_id: {
type: 'string',
required: true,
},
},
},
method: 'GET',
});
flowFramework.searchWorkflowState = ca({
url: {
fmt: FLOW_FRAMEWORK_SEARCH_WORKFLOW_STATE_ROUTE,
},
needBody: true,
// Exposed client rejects making GET requests with a body. So, we use POST
method: 'POST',
});
flowFramework.createWorkflow = ca({
url: {
fmt: FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX,
},
needBody: true,
method: 'POST',
});
flowFramework.deleteWorkflow = ca({
url: {
fmt: `${FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX}/<%=workflow_id%>`,
req: {
workflow_id: {
type: 'string',
required: true,
},
},
},
method: 'DELETE',
});
}