forked from MrRefactoring/jira.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkflows.ts
142 lines (134 loc) · 5.29 KB
/
workflows.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import * as Models from './models';
import * as Parameters from './parameters';
import { Callback } from '../callback';
import { Client } from '../clients';
import { paramSerializer } from '../paramSerializer';
import { RequestConfig } from '../requestConfig';
export class Workflows {
constructor(private client: Client) {}
/**
* Creates a workflow. Workflow transitions are created with the default system transition rules.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async createWorkflow<T = Models.WorkflowId>(
parameters: Parameters.CreateWorkflow,
callback: Callback<T>,
): Promise<void>;
/**
* Creates a workflow. Workflow transitions are created with the default system transition rules.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async createWorkflow<T = Models.WorkflowId>(parameters: Parameters.CreateWorkflow, callback?: never): Promise<T>;
async createWorkflow<T = Models.WorkflowId>(
parameters: Parameters.CreateWorkflow,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/rest/api/3/workflow',
method: 'POST',
data: {
name: parameters.name,
description: parameters.description,
transitions: parameters.transitions,
statuses: parameters.statuses,
},
};
return this.client.sendRequest(config, callback);
}
/**
* Returns a [paginated](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#pagination) list of
* published classic workflows. When workflow names are specified, details of those workflows are returned. Otherwise,
* all published classic workflows are returned.
*
* This operation does not return next-gen workflows.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async getWorkflowsPaginated<T = Models.PageWorkflow>(
parameters: Parameters.GetWorkflowsPaginated | undefined,
callback: Callback<T>,
): Promise<void>;
/**
* Returns a [paginated](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#pagination) list of
* published classic workflows. When workflow names are specified, details of those workflows are returned. Otherwise,
* all published classic workflows are returned.
*
* This operation does not return next-gen workflows.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async getWorkflowsPaginated<T = Models.PageWorkflow>(
parameters?: Parameters.GetWorkflowsPaginated,
callback?: never,
): Promise<T>;
async getWorkflowsPaginated<T = Models.PageWorkflow>(
parameters?: Parameters.GetWorkflowsPaginated,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/rest/api/3/workflow/search',
method: 'GET',
params: {
startAt: parameters?.startAt,
maxResults: parameters?.maxResults,
workflowName: paramSerializer('workflowName', parameters?.workflowName),
expand: parameters?.expand,
queryString: parameters?.queryString,
orderBy: parameters?.orderBy,
isActive: parameters?.isActive,
},
};
return this.client.sendRequest(config, callback);
}
/**
* Deletes a workflow.
*
* The workflow cannot be deleted if it is:
*
* - An active workflow.
* - A system workflow.
* - Associated with any workflow scheme.
* - Associated with any draft workflow scheme.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async deleteInactiveWorkflow<T = void>(
parameters: Parameters.DeleteInactiveWorkflow | string,
callback: Callback<T>,
): Promise<void>;
/**
* Deletes a workflow.
*
* The workflow cannot be deleted if it is:
*
* - An active workflow.
* - A system workflow.
* - Associated with any workflow scheme.
* - Associated with any draft workflow scheme.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async deleteInactiveWorkflow<T = void>(
parameters: Parameters.DeleteInactiveWorkflow | string,
callback?: never,
): Promise<T>;
async deleteInactiveWorkflow<T = void>(
parameters: Parameters.DeleteInactiveWorkflow | string,
callback?: Callback<T>,
): Promise<void | T> {
const entityId = typeof parameters === 'string' ? parameters : parameters.entityId;
const config: RequestConfig = {
url: `/rest/api/3/workflow/${entityId}`,
method: 'DELETE',
};
return this.client.sendRequest(config, callback);
}
}