forked from MrRefactoring/jira.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissueTypes.ts
351 lines (331 loc) · 14.3 KB
/
issueTypes.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
import * as Models from './models';
import * as Parameters from './parameters';
import { Callback } from '../callback';
import { Client } from '../clients';
import { RequestConfig } from '../requestConfig';
export class IssueTypes {
constructor(private client: Client) {}
/**
* Returns all issue types.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** Issue
* types are only returned as follows:
*
* - If the user has the _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg), all issue
* types are returned.
* - If the user has the _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for one or
* more projects, the issue types associated with the projects the user has permission to browse are returned.
*/
async getIssueAllTypes<T = Models.IssueTypeDetails[]>(callback: Callback<T>): Promise<void>;
/**
* Returns all issue types.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** Issue
* types are only returned as follows:
*
* - If the user has the _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg), all issue
* types are returned.
* - If the user has the _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for one or
* more projects, the issue types associated with the projects the user has permission to browse are returned.
*/
async getIssueAllTypes<T = Models.IssueTypeDetails[]>(callback?: never): Promise<T>;
async getIssueAllTypes<T = Models.IssueTypeDetails[]>(callback?: Callback<T>): Promise<void | T> {
const config: RequestConfig = {
url: '/rest/api/2/issuetype',
method: 'GET',
};
return this.client.sendRequest(config, callback);
}
/**
* Creates an issue type and adds it to the default issue type scheme.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async createIssueType<T = Models.IssueTypeDetails>(
parameters: Parameters.CreateIssueType | undefined,
callback: Callback<T>,
): Promise<void>;
/**
* Creates an issue type and adds it to the default issue type scheme.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async createIssueType<T = Models.IssueTypeDetails>(
parameters?: Parameters.CreateIssueType,
callback?: never,
): Promise<T>;
async createIssueType<T = Models.IssueTypeDetails>(
parameters?: Parameters.CreateIssueType,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/rest/api/2/issuetype',
method: 'POST',
data: {
name: parameters?.name,
description: parameters?.description,
hierarchyLevel: parameters?.hierarchyLevel,
},
};
return this.client.sendRequest(config, callback);
}
/**
* Returns issue types for a project.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** _Browse
* projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) in the relevant project or _Administer
* Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async getIssueTypesForProject<T = Models.IssueTypeDetails[]>(
parameters: Parameters.GetIssueTypesForProject,
callback: Callback<T>,
): Promise<void>;
/**
* Returns issue types for a project.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** _Browse
* projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) in the relevant project or _Administer
* Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async getIssueTypesForProject<T = Models.IssueTypeDetails[]>(
parameters: Parameters.GetIssueTypesForProject,
callback?: never,
): Promise<T>;
async getIssueTypesForProject<T = Models.IssueTypeDetails[]>(
parameters: Parameters.GetIssueTypesForProject,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/rest/api/2/issuetype/project',
method: 'GET',
params: {
projectId: parameters.projectId,
level: parameters.level,
},
};
return this.client.sendRequest(config, callback);
}
/**
* Returns an issue type.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** _Browse
* projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) in a project the issue type is associated
* with or _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async getIssueType<T = Models.IssueTypeDetails>(
parameters: Parameters.GetIssueType | string,
callback: Callback<T>,
): Promise<void>;
/**
* Returns an issue type.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** _Browse
* projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) in a project the issue type is associated
* with or _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async getIssueType<T = Models.IssueTypeDetails>(
parameters: Parameters.GetIssueType | string,
callback?: never,
): Promise<T>;
async getIssueType<T = Models.IssueTypeDetails>(
parameters: Parameters.GetIssueType | string,
callback?: Callback<T>,
): Promise<void | T> {
const id = typeof parameters === 'string' ? parameters : parameters.id;
const config: RequestConfig = {
url: `/rest/api/2/issuetype/${id}`,
method: 'GET',
};
return this.client.sendRequest(config, callback);
}
/**
* Updates the issue type.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async updateIssueType<T = Models.IssueTypeDetails>(
parameters: Parameters.UpdateIssueType,
callback: Callback<T>,
): Promise<void>;
/**
* Updates the issue type.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async updateIssueType<T = Models.IssueTypeDetails>(
parameters: Parameters.UpdateIssueType,
callback?: never,
): Promise<T>;
async updateIssueType<T = Models.IssueTypeDetails>(
parameters: Parameters.UpdateIssueType,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: `/rest/api/2/issuetype/${parameters.id}`,
method: 'PUT',
data: {
name: parameters.name,
description: parameters.description,
avatarId: parameters.avatarId,
},
};
return this.client.sendRequest(config, callback);
}
/**
* Deletes the issue type. If the issue type is in use, all uses are updated with the alternative issue type
* (`alternativeIssueTypeId`). A list of alternative issue types are obtained from the [Get alternative issue
* types](#api-rest-api-2-issuetype-id-alternatives-get) resource.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async deleteIssueType<T = void>(
parameters: Parameters.DeleteIssueType | string,
callback: Callback<T>,
): Promise<void>;
/**
* Deletes the issue type. If the issue type is in use, all uses are updated with the alternative issue type
* (`alternativeIssueTypeId`). A list of alternative issue types are obtained from the [Get alternative issue
* types](#api-rest-api-2-issuetype-id-alternatives-get) resource.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async deleteIssueType<T = void>(parameters: Parameters.DeleteIssueType | string, callback?: never): Promise<T>;
async deleteIssueType<T = void>(
parameters: Parameters.DeleteIssueType | string,
callback?: Callback<T>,
): Promise<void | T> {
const id = typeof parameters === 'string' ? parameters : parameters.id;
const config: RequestConfig = {
url: `/rest/api/2/issuetype/${id}`,
method: 'DELETE',
params: {
alternativeIssueTypeId: typeof parameters !== 'string' && parameters.alternativeIssueTypeId,
},
};
return this.client.sendRequest(config, callback);
}
/**
* Returns a list of issue types that can be used to replace the issue type. The alternative issue types are those
* assigned to the same workflow scheme, field configuration scheme, and screen scheme.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None.
*/
async getAlternativeIssueTypes<T = Models.IssueTypeDetails[]>(
parameters: Parameters.GetAlternativeIssueTypes | string,
callback: Callback<T>,
): Promise<void>;
/**
* Returns a list of issue types that can be used to replace the issue type. The alternative issue types are those
* assigned to the same workflow scheme, field configuration scheme, and screen scheme.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None.
*/
async getAlternativeIssueTypes<T = Models.IssueTypeDetails[]>(
parameters: Parameters.GetAlternativeIssueTypes | string,
callback?: never,
): Promise<T>;
async getAlternativeIssueTypes<T = Models.IssueTypeDetails[]>(
parameters: Parameters.GetAlternativeIssueTypes | string,
callback?: Callback<T>,
): Promise<void | T> {
const id = typeof parameters === 'string' ? parameters : parameters.id;
const config: RequestConfig = {
url: `/rest/api/2/issuetype/${id}/alternatives`,
method: 'GET',
};
return this.client.sendRequest(config, callback);
}
/**
* Loads an avatar for the issue type.
*
* Specify the avatar's local file location in the body of the request. Also, include the following headers:
*
* - `X-Atlassian-Token: no-check` To prevent XSRF protection blocking the request, for more information see [Special
* Headers](#special-request-headers).
* - `Content-Type: image/image type` Valid image types are JPEG, GIF, or PNG.
*
* For example: `curl --request POST \ --user email@example.com:<api_token> \ --header 'X-Atlassian-Token: no-check'\
* --header 'Content-Type: image/< image_type>' \ --data-binary "<@/path/to/file/with/your/avatar>" \ --url
* 'https://your-domain.atlassian.net/rest/api/2/issuetype/{issueTypeId}'This`
*
* The avatar is cropped to a square. If no crop parameters are specified, the square originates at the top left of
* the image. The length of the square's sides is set to the smaller of the height or width of the image.
*
* The cropped image is then used to create avatars of 16x16, 24x24, 32x32, and 48x48 in size.
*
* After creating the avatar, use [ Update issue type](#api-rest-api-2-issuetype-id-put) to set it as the issue type's
* displayed avatar.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async createIssueTypeAvatar<T = Models.Avatar>(
parameters: Parameters.CreateIssueTypeAvatar,
callback: Callback<T>,
): Promise<void>;
/**
* Loads an avatar for the issue type.
*
* Specify the avatar's local file location in the body of the request. Also, include the following headers:
*
* - `X-Atlassian-Token: no-check` To prevent XSRF protection blocking the request, for more information see [Special
* Headers](#special-request-headers).
* - `Content-Type: image/image type` Valid image types are JPEG, GIF, or PNG.
*
* For example: `curl --request POST \ --user email@example.com:<api_token> \ --header 'X-Atlassian-Token: no-check'\
* --header 'Content-Type: image/< image_type>' \ --data-binary "<@/path/to/file/with/your/avatar>" \ --url
* 'https://your-domain.atlassian.net/rest/api/2/issuetype/{issueTypeId}'This`
*
* The avatar is cropped to a square. If no crop parameters are specified, the square originates at the top left of
* the image. The length of the square's sides is set to the smaller of the height or width of the image.
*
* The cropped image is then used to create avatars of 16x16, 24x24, 32x32, and 48x48 in size.
*
* After creating the avatar, use [ Update issue type](#api-rest-api-2-issuetype-id-put) to set it as the issue type's
* displayed avatar.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
async createIssueTypeAvatar<T = Models.Avatar>(
parameters: Parameters.CreateIssueTypeAvatar,
callback?: never,
): Promise<T>;
async createIssueTypeAvatar<T = Models.Avatar>(
parameters: Parameters.CreateIssueTypeAvatar,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: `/rest/api/2/issuetype/${parameters.id}/avatar2`,
method: 'POST',
params: {
x: parameters.x,
y: parameters.y,
size: parameters.size,
},
};
return this.client.sendRequest(config, callback);
}
}