• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tylernathanreed / jira-client-php / 13834920235

13 Mar 2025 12:45PM UTC coverage: 71.089% (-2.2%) from 73.289%
13834920235

push

github

tylernathanreed
Merge branch 'master' of github.com:tylernathanreed/jira-client-php

3976 of 5593 relevant lines covered (71.09%)

9.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.24
/src/Operations/WorkflowSchemes.php
1
<?php
2

3
namespace Jira\Client\Operations;
4

5
use Jira\Client\Client;
6
use Jira\Client\Schema;
7

8
/** @phpstan-require-extends Client */
9
trait WorkflowSchemes
10
{
11
    /**
12
     * Returns a "paginated" list of all workflow schemes, not including draft workflow schemes
13
     * 
14
     * **"Permissions" required:** *Administer Jira* "global permission".
15
     * 
16
     * @link https://confluence.atlassian.com/x/x4dKLg
17
     * 
18
     * @param int $startAt The index of the first item to return in a page of results (page offset).
19
     * @param int $maxResults The maximum number of items to return per page.
20
     */
21
    public function getAllWorkflowSchemes(
1✔
22
        ?int $startAt = 0,
23
        ?int $maxResults = 50,
24
    ): Schema\PageBeanWorkflowScheme {
25
        return $this->call(
1✔
26
            uri: '/rest/api/3/workflowscheme',
1✔
27
            method: 'get',
1✔
28
            query: compact('startAt', 'maxResults'),
1✔
29
            success: 200,
1✔
30
            schema: Schema\PageBeanWorkflowScheme::class,
1✔
31
        );
1✔
32
    }
33

34
    /**
35
     * Creates a workflow scheme
36
     * 
37
     * **"Permissions" required:** *Administer Jira* "global permission".
38
     * 
39
     * @link https://confluence.atlassian.com/x/x4dKLg
40
     */
41
    public function createWorkflowScheme(
1✔
42
        Schema\WorkflowScheme $request,
43
    ): Schema\WorkflowScheme {
44
        return $this->call(
1✔
45
            uri: '/rest/api/3/workflowscheme',
1✔
46
            method: 'post',
1✔
47
            body: $request,
1✔
48
            success: 201,
1✔
49
            schema: Schema\WorkflowScheme::class,
1✔
50
        );
1✔
51
    }
52

53
    /**
54
     * Returns a list of workflow schemes by providing workflow scheme IDs or project IDs
55
     * 
56
     * **"Permissions" required:**
57
     * 
58
     *  - *Administer Jira* global permission to access all, including project-scoped, workflow schemes
59
     *  - *Administer projects* project permissions to access project-scoped workflow schemes
60
     * 
61
     * @param string $expand Deprecated.
62
     *                       See the "deprecation notice" for details
63
     *                       Use "expand" to include additional information in the response.
64
     *                       This parameter accepts a comma-separated list.
65
     *                       Expand options include:
66
     *                        - `workflows.usages` Returns the project and issue types that each workflow in the workflow scheme is associated with.
67
     *                       @link https://developer.atlassian.com/cloud/jira/platform/changelog/#CHANGE-2298
68
     * 
69
     * @return list<Schema\WorkflowSchemeReadResponse>
70
     */
71
    public function readWorkflowSchemes(
1✔
72
        Schema\WorkflowSchemeReadRequest $request,
73
        ?string $expand = null,
74
    ): array {
75
        return $this->call(
1✔
76
            uri: '/rest/api/3/workflowscheme/read',
1✔
77
            method: 'post',
1✔
78
            body: $request,
1✔
79
            query: compact('expand'),
1✔
80
            success: 200,
1✔
81
            schema: [Schema\WorkflowSchemeReadResponse::class],
1✔
82
        );
1✔
83
    }
84

85
    /**
86
     * Updates company-managed and team-managed project workflow schemes.
87
     * This API doesn't have a concept of draft, so any changes made to a workflow scheme are immediately available.
88
     * When changing the available statuses for issue types, an "asynchronous task" migrates the issues as defined in the provided mappings
89
     * 
90
     * **"Permissions" required:**
91
     * 
92
     *  - *Administer Jira* project permission to update all, including global-scoped, workflow schemes
93
     *  - *Administer projects* project permission to update project-scoped workflow schemes.
94
     */
95
    public function updateSchemes(
×
96
        Schema\WorkflowSchemeUpdateRequest $request,
97
    ): true {
98
        return $this->call(
×
99
            uri: '/rest/api/3/workflowscheme/update',
×
100
            method: 'post',
×
101
            body: $request,
×
102
            success: 200,
×
103
            schema: true,
×
104
        );
×
105
    }
106

107
    /**
108
     * Gets the required status mappings for the desired changes to a workflow scheme.
109
     * The results are provided per issue type and workflow.
110
     * When updating a workflow scheme, status mappings can be provided per issue type, per workflow, or both
111
     * 
112
     * **"Permissions" required:**
113
     * 
114
     *  - *Administer Jira* permission to update all, including global-scoped, workflow schemes
115
     *  - *Administer projects* project permission to update project-scoped workflow schemes.
116
     */
117
    public function updateWorkflowSchemeMappings(
1✔
118
        Schema\WorkflowSchemeUpdateRequiredMappingsRequest $request,
119
    ): Schema\WorkflowSchemeUpdateRequiredMappingsResponse {
120
        return $this->call(
1✔
121
            uri: '/rest/api/3/workflowscheme/update/mappings',
1✔
122
            method: 'post',
1✔
123
            body: $request,
1✔
124
            success: 200,
1✔
125
            schema: Schema\WorkflowSchemeUpdateRequiredMappingsResponse::class,
1✔
126
        );
1✔
127
    }
128

129
    /**
130
     * Returns a workflow scheme
131
     * 
132
     * **"Permissions" required:** *Administer Jira* "global permission".
133
     * 
134
     * @link https://confluence.atlassian.com/x/x4dKLg
135
     * 
136
     * @param int $id The ID of the workflow scheme.
137
     *                Find this ID by editing the desired workflow scheme in Jira.
138
     *                The ID is shown in the URL as `schemeId`.
139
     *                For example, *schemeId=10301*.
140
     * @param bool $returnDraftIfExists Returns the workflow scheme's draft rather than scheme itself, if set to true.
141
     *                                  If the workflow scheme does not have a draft, then the workflow scheme is returned.
142
     */
143
    public function getWorkflowScheme(
1✔
144
        int $id,
145
        ?bool $returnDraftIfExists = false,
146
    ): Schema\WorkflowScheme {
147
        return $this->call(
1✔
148
            uri: '/rest/api/3/workflowscheme/{id}',
1✔
149
            method: 'get',
1✔
150
            query: compact('returnDraftIfExists'),
1✔
151
            path: compact('id'),
1✔
152
            success: 200,
1✔
153
            schema: Schema\WorkflowScheme::class,
1✔
154
        );
1✔
155
    }
156

157
    /**
158
     * Updates a company-manged project workflow scheme, including the name, default workflow, issue type to project mappings, and more.
159
     * If the workflow scheme is active (that is, being used by at least one project), then a draft workflow scheme is created or updated instead, provided that `updateDraftIfNeeded` is set to `true`
160
     * 
161
     * **"Permissions" required:** *Administer Jira* "global permission".
162
     * 
163
     * @link https://confluence.atlassian.com/x/x4dKLg
164
     * 
165
     * @param int $id The ID of the workflow scheme.
166
     *                Find this ID by editing the desired workflow scheme in Jira.
167
     *                The ID is shown in the URL as `schemeId`.
168
     *                For example, *schemeId=10301*.
169
     */
170
    public function updateWorkflowScheme(
1✔
171
        Schema\WorkflowScheme $request,
172
        int $id,
173
    ): Schema\WorkflowScheme {
174
        return $this->call(
1✔
175
            uri: '/rest/api/3/workflowscheme/{id}',
1✔
176
            method: 'put',
1✔
177
            body: $request,
1✔
178
            path: compact('id'),
1✔
179
            success: 200,
1✔
180
            schema: Schema\WorkflowScheme::class,
1✔
181
        );
1✔
182
    }
183

184
    /**
185
     * Deletes a workflow scheme.
186
     * Note that a workflow scheme cannot be deleted if it is active (that is, being used by at least one project)
187
     * 
188
     * **"Permissions" required:** *Administer Jira* "global permission".
189
     * 
190
     * @link https://confluence.atlassian.com/x/x4dKLg
191
     * 
192
     * @param int $id The ID of the workflow scheme.
193
     *                Find this ID by editing the desired workflow scheme in Jira.
194
     *                The ID is shown in the URL as `schemeId`.
195
     *                For example, *schemeId=10301*.
196
     */
197
    public function deleteWorkflowScheme(
1✔
198
        int $id,
199
    ): true {
200
        return $this->call(
1✔
201
            uri: '/rest/api/3/workflowscheme/{id}',
1✔
202
            method: 'delete',
1✔
203
            path: compact('id'),
1✔
204
            success: 204,
1✔
205
            schema: true,
1✔
206
        );
1✔
207
    }
208

209
    /**
210
     * Returns the default workflow for a workflow scheme.
211
     * The default workflow is the workflow that is assigned any issue types that have not been mapped to any other workflow.
212
     * The default workflow has *All Unassigned Issue Types* listed in its issue types for the workflow scheme in Jira
213
     * 
214
     * **"Permissions" required:** *Administer Jira* "global permission".
215
     * 
216
     * @link https://confluence.atlassian.com/x/x4dKLg
217
     * 
218
     * @param int $id The ID of the workflow scheme.
219
     * @param bool $returnDraftIfExists Set to `true` to return the default workflow for the workflow scheme's draft rather than scheme itself.
220
     *                                  If the workflow scheme does not have a draft, then the default workflow for the workflow scheme is returned.
221
     */
222
    public function getDefaultWorkflow(
1✔
223
        int $id,
224
        ?bool $returnDraftIfExists = false,
225
    ): Schema\DefaultWorkflow {
226
        return $this->call(
1✔
227
            uri: '/rest/api/3/workflowscheme/{id}/default',
1✔
228
            method: 'get',
1✔
229
            query: compact('returnDraftIfExists'),
1✔
230
            path: compact('id'),
1✔
231
            success: 200,
1✔
232
            schema: Schema\DefaultWorkflow::class,
1✔
233
        );
1✔
234
    }
235

236
    /**
237
     * Sets the default workflow for a workflow scheme
238
     * 
239
     * Note that active workflow schemes cannot be edited.
240
     * If the workflow scheme is active, set `updateDraftIfNeeded` to `true` in the request object and a draft workflow scheme is created or updated with the new default workflow.
241
     * The draft workflow scheme can be published in Jira
242
     * 
243
     * **"Permissions" required:** *Administer Jira* "global permission".
244
     * 
245
     * @link https://confluence.atlassian.com/x/x4dKLg
246
     * 
247
     * @param int $id The ID of the workflow scheme.
248
     */
249
    public function updateDefaultWorkflow(
1✔
250
        Schema\DefaultWorkflow $request,
251
        int $id,
252
    ): Schema\WorkflowScheme {
253
        return $this->call(
1✔
254
            uri: '/rest/api/3/workflowscheme/{id}/default',
1✔
255
            method: 'put',
1✔
256
            body: $request,
1✔
257
            path: compact('id'),
1✔
258
            success: 200,
1✔
259
            schema: Schema\WorkflowScheme::class,
1✔
260
        );
1✔
261
    }
262

263
    /**
264
     * Resets the default workflow for a workflow scheme.
265
     * That is, the default workflow is set to Jira's system workflow (the *jira* workflow)
266
     * 
267
     * Note that active workflow schemes cannot be edited.
268
     * If the workflow scheme is active, set `updateDraftIfNeeded` to `true` and a draft workflow scheme is created or updated with the default workflow reset.
269
     * The draft workflow scheme can be published in Jira
270
     * 
271
     * **"Permissions" required:** *Administer Jira* "global permission".
272
     * 
273
     * @link https://confluence.atlassian.com/x/x4dKLg
274
     * 
275
     * @param int $id The ID of the workflow scheme.
276
     * @param bool $updateDraftIfNeeded Set to true to create or update the draft of a workflow scheme and delete the mapping from the draft, when the workflow scheme cannot be edited.
277
     *                                  Defaults to `false`.
278
     */
279
    public function deleteDefaultWorkflow(
1✔
280
        int $id,
281
        ?bool $updateDraftIfNeeded = null,
282
    ): Schema\WorkflowScheme {
283
        return $this->call(
1✔
284
            uri: '/rest/api/3/workflowscheme/{id}/default',
1✔
285
            method: 'delete',
1✔
286
            query: compact('updateDraftIfNeeded'),
1✔
287
            path: compact('id'),
1✔
288
            success: 200,
1✔
289
            schema: Schema\WorkflowScheme::class,
1✔
290
        );
1✔
291
    }
292

293
    /**
294
     * Returns the issue type-workflow mapping for an issue type in a workflow scheme
295
     * 
296
     * **"Permissions" required:** *Administer Jira* "global permission".
297
     * 
298
     * @link https://confluence.atlassian.com/x/x4dKLg
299
     * 
300
     * @param int $id The ID of the workflow scheme.
301
     * @param string $issueType The ID of the issue type.
302
     * @param bool $returnDraftIfExists Returns the mapping from the workflow scheme's draft rather than the workflow scheme, if set to true.
303
     *                                  If no draft exists, the mapping from the workflow scheme is returned.
304
     */
305
    public function getWorkflowSchemeIssueType(
1✔
306
        int $id,
307
        string $issueType,
308
        ?bool $returnDraftIfExists = false,
309
    ): Schema\IssueTypeWorkflowMapping {
310
        return $this->call(
1✔
311
            uri: '/rest/api/3/workflowscheme/{id}/issuetype/{issueType}',
1✔
312
            method: 'get',
1✔
313
            query: compact('returnDraftIfExists'),
1✔
314
            path: compact('id', 'issueType'),
1✔
315
            success: 200,
1✔
316
            schema: Schema\IssueTypeWorkflowMapping::class,
1✔
317
        );
1✔
318
    }
319

320
    /**
321
     * Sets the workflow for an issue type in a workflow scheme
322
     * 
323
     * Note that active workflow schemes cannot be edited.
324
     * If the workflow scheme is active, set `updateDraftIfNeeded` to `true` in the request body and a draft workflow scheme is created or updated with the new issue type-workflow mapping.
325
     * The draft workflow scheme can be published in Jira
326
     * 
327
     * **"Permissions" required:** *Administer Jira* "global permission".
328
     * 
329
     * @link https://confluence.atlassian.com/x/x4dKLg
330
     * 
331
     * @param int $id The ID of the workflow scheme.
332
     * @param string $issueType The ID of the issue type.
333
     */
334
    public function setWorkflowSchemeIssueType(
1✔
335
        Schema\IssueTypeWorkflowMapping $request,
336
        int $id,
337
        string $issueType,
338
    ): Schema\WorkflowScheme {
339
        return $this->call(
1✔
340
            uri: '/rest/api/3/workflowscheme/{id}/issuetype/{issueType}',
1✔
341
            method: 'put',
1✔
342
            body: $request,
1✔
343
            path: compact('id', 'issueType'),
1✔
344
            success: 200,
1✔
345
            schema: Schema\WorkflowScheme::class,
1✔
346
        );
1✔
347
    }
348

349
    /**
350
     * Deletes the issue type-workflow mapping for an issue type in a workflow scheme
351
     * 
352
     * Note that active workflow schemes cannot be edited.
353
     * If the workflow scheme is active, set `updateDraftIfNeeded` to `true` and a draft workflow scheme is created or updated with the issue type-workflow mapping deleted.
354
     * The draft workflow scheme can be published in Jira
355
     * 
356
     * **"Permissions" required:** *Administer Jira* "global permission".
357
     * 
358
     * @link https://confluence.atlassian.com/x/x4dKLg
359
     * 
360
     * @param int $id The ID of the workflow scheme.
361
     * @param string $issueType The ID of the issue type.
362
     * @param bool $updateDraftIfNeeded Set to true to create or update the draft of a workflow scheme and update the mapping in the draft, when the workflow scheme cannot be edited.
363
     *                                  Defaults to `false`.
364
     */
365
    public function deleteWorkflowSchemeIssueType(
1✔
366
        int $id,
367
        string $issueType,
368
        ?bool $updateDraftIfNeeded = false,
369
    ): Schema\WorkflowScheme {
370
        return $this->call(
1✔
371
            uri: '/rest/api/3/workflowscheme/{id}/issuetype/{issueType}',
1✔
372
            method: 'delete',
1✔
373
            query: compact('updateDraftIfNeeded'),
1✔
374
            path: compact('id', 'issueType'),
1✔
375
            success: 200,
1✔
376
            schema: Schema\WorkflowScheme::class,
1✔
377
        );
1✔
378
    }
379

380
    /**
381
     * Returns the workflow-issue type mappings for a workflow scheme
382
     * 
383
     * **"Permissions" required:** *Administer Jira* "global permission".
384
     * 
385
     * @link https://confluence.atlassian.com/x/x4dKLg
386
     * 
387
     * @param int $id The ID of the workflow scheme.
388
     * @param string $workflowName The name of a workflow in the scheme.
389
     *                             Limits the results to the workflow-issue type mapping for the specified workflow.
390
     * @param bool $returnDraftIfExists Returns the mapping from the workflow scheme's draft rather than the workflow scheme, if set to true.
391
     *                                  If no draft exists, the mapping from the workflow scheme is returned.
392
     */
393
    public function getWorkflow(
1✔
394
        int $id,
395
        ?string $workflowName = null,
396
        ?bool $returnDraftIfExists = false,
397
    ): Schema\IssueTypesWorkflowMapping {
398
        return $this->call(
1✔
399
            uri: '/rest/api/3/workflowscheme/{id}/workflow',
1✔
400
            method: 'get',
1✔
401
            query: compact('workflowName', 'returnDraftIfExists'),
1✔
402
            path: compact('id'),
1✔
403
            success: 200,
1✔
404
            schema: Schema\IssueTypesWorkflowMapping::class,
1✔
405
        );
1✔
406
    }
407

408
    /**
409
     * Sets the issue types for a workflow in a workflow scheme.
410
     * The workflow can also be set as the default workflow for the workflow scheme.
411
     * Unmapped issues types are mapped to the default workflow
412
     * 
413
     * Note that active workflow schemes cannot be edited.
414
     * If the workflow scheme is active, set `updateDraftIfNeeded` to `true` in the request body and a draft workflow scheme is created or updated with the new workflow-issue types mappings.
415
     * The draft workflow scheme can be published in Jira
416
     * 
417
     * **"Permissions" required:** *Administer Jira* "global permission".
418
     * 
419
     * @link https://confluence.atlassian.com/x/x4dKLg
420
     * 
421
     * @param int $id The ID of the workflow scheme.
422
     * @param string $workflowName The name of the workflow.
423
     */
424
    public function updateWorkflowMapping(
1✔
425
        Schema\IssueTypesWorkflowMapping $request,
426
        int $id,
427
        string $workflowName,
428
    ): Schema\WorkflowScheme {
429
        return $this->call(
1✔
430
            uri: '/rest/api/3/workflowscheme/{id}/workflow',
1✔
431
            method: 'put',
1✔
432
            body: $request,
1✔
433
            query: compact('workflowName'),
1✔
434
            path: compact('id'),
1✔
435
            success: 200,
1✔
436
            schema: Schema\WorkflowScheme::class,
1✔
437
        );
1✔
438
    }
439

440
    /**
441
     * Deletes the workflow-issue type mapping for a workflow in a workflow scheme
442
     * 
443
     * Note that active workflow schemes cannot be edited.
444
     * If the workflow scheme is active, set `updateDraftIfNeeded` to `true` and a draft workflow scheme is created or updated with the workflow-issue type mapping deleted.
445
     * The draft workflow scheme can be published in Jira
446
     * 
447
     * **"Permissions" required:** *Administer Jira* "global permission".
448
     * 
449
     * @link https://confluence.atlassian.com/x/x4dKLg
450
     * 
451
     * @param int $id The ID of the workflow scheme.
452
     * @param string $workflowName The name of the workflow.
453
     * @param bool $updateDraftIfNeeded Set to true to create or update the draft of a workflow scheme and delete the mapping from the draft, when the workflow scheme cannot be edited.
454
     *                                  Defaults to `false`.
455
     */
456
    public function deleteWorkflowMapping(
×
457
        int $id,
458
        string $workflowName,
459
        ?bool $updateDraftIfNeeded = false,
460
    ): true {
461
        return $this->call(
×
462
            uri: '/rest/api/3/workflowscheme/{id}/workflow',
×
463
            method: 'delete',
×
464
            query: compact('workflowName', 'updateDraftIfNeeded'),
×
465
            path: compact('id'),
×
466
            success: 200,
×
467
            schema: true,
×
468
        );
×
469
    }
470

471
    /**
472
     * Returns a page of projects using a given workflow scheme.
473
     * 
474
     * @param string $workflowSchemeId The workflow scheme ID
475
     * @param string $nextPageToken The cursor for pagination
476
     * @param int $maxResults The maximum number of results to return.
477
     *                        Must be an integer between 1 and 200.
478
     */
479
    public function getProjectUsagesForWorkflowScheme(
1✔
480
        string $workflowSchemeId,
481
        ?string $nextPageToken = null,
482
        ?int $maxResults = 50,
483
    ): Schema\WorkflowSchemeProjectUsageDTO {
484
        return $this->call(
1✔
485
            uri: '/rest/api/3/workflowscheme/{workflowSchemeId}/projectUsages',
1✔
486
            method: 'get',
1✔
487
            query: compact('nextPageToken', 'maxResults'),
1✔
488
            path: compact('workflowSchemeId'),
1✔
489
            success: 200,
1✔
490
            schema: Schema\WorkflowSchemeProjectUsageDTO::class,
1✔
491
        );
1✔
492
    }
493
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc