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

tylernathanreed / jira-client-php / 13678007438

05 Mar 2025 02:15PM UTC coverage: 2.081% (+0.01%) from 2.067%
13678007438

push

github

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

141 of 6775 relevant lines covered (2.08%)

0.03 hits per line

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

0.0
/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(
×
22
        ?int $startAt = 0,
23
        ?int $maxResults = 50,
24
    ): Schema\PageBeanWorkflowScheme {
25
        return $this->call(
×
26
            uri: '/rest/api/3/workflowscheme',
×
27
            method: 'get',
×
28
            query: compact('startAt', 'maxResults'),
×
29
            success: 200,
×
30
            schema: Schema\PageBeanWorkflowScheme::class,
×
31
        );
×
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(
×
42
        Schema\WorkflowScheme $request,
43
    ): Schema\WorkflowScheme {
44
        return $this->call(
×
45
            uri: '/rest/api/3/workflowscheme',
×
46
            method: 'post',
×
47
            body: $request,
×
48
            success: 201,
×
49
            schema: Schema\WorkflowScheme::class,
×
50
        );
×
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(
×
72
        Schema\WorkflowSchemeReadRequest $request,
73
        ?string $expand = null,
74
    ): array {
75
        return $this->call(
×
76
            uri: '/rest/api/3/workflowscheme/read',
×
77
            method: 'post',
×
78
            body: $request,
×
79
            query: compact('expand'),
×
80
            success: 200,
×
81
            schema: [Schema\WorkflowSchemeReadResponse::class],
×
82
        );
×
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(
×
118
        Schema\WorkflowSchemeUpdateRequiredMappingsRequest $request,
119
    ): Schema\WorkflowSchemeUpdateRequiredMappingsResponse {
120
        return $this->call(
×
121
            uri: '/rest/api/3/workflowscheme/update/mappings',
×
122
            method: 'post',
×
123
            body: $request,
×
124
            success: 200,
×
125
            schema: Schema\WorkflowSchemeUpdateRequiredMappingsResponse::class,
×
126
        );
×
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(
×
144
        int $id,
145
        ?bool $returnDraftIfExists = false,
146
    ): Schema\WorkflowScheme {
147
        return $this->call(
×
148
            uri: '/rest/api/3/workflowscheme/{id}',
×
149
            method: 'get',
×
150
            query: compact('returnDraftIfExists'),
×
151
            path: compact('id'),
×
152
            success: 200,
×
153
            schema: Schema\WorkflowScheme::class,
×
154
        );
×
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(
×
171
        Schema\WorkflowScheme $request,
172
        int $id,
173
    ): Schema\WorkflowScheme {
174
        return $this->call(
×
175
            uri: '/rest/api/3/workflowscheme/{id}',
×
176
            method: 'put',
×
177
            body: $request,
×
178
            path: compact('id'),
×
179
            success: 200,
×
180
            schema: Schema\WorkflowScheme::class,
×
181
        );
×
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(
×
198
        int $id,
199
    ): true {
200
        return $this->call(
×
201
            uri: '/rest/api/3/workflowscheme/{id}',
×
202
            method: 'delete',
×
203
            path: compact('id'),
×
204
            success: 204,
×
205
            schema: true,
×
206
        );
×
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(
×
223
        int $id,
224
        ?bool $returnDraftIfExists = false,
225
    ): Schema\DefaultWorkflow {
226
        return $this->call(
×
227
            uri: '/rest/api/3/workflowscheme/{id}/default',
×
228
            method: 'get',
×
229
            query: compact('returnDraftIfExists'),
×
230
            path: compact('id'),
×
231
            success: 200,
×
232
            schema: Schema\DefaultWorkflow::class,
×
233
        );
×
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(
×
250
        Schema\DefaultWorkflow $request,
251
        int $id,
252
    ): Schema\WorkflowScheme {
253
        return $this->call(
×
254
            uri: '/rest/api/3/workflowscheme/{id}/default',
×
255
            method: 'put',
×
256
            body: $request,
×
257
            path: compact('id'),
×
258
            success: 200,
×
259
            schema: Schema\WorkflowScheme::class,
×
260
        );
×
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(
×
280
        int $id,
281
        ?bool $updateDraftIfNeeded = null,
282
    ): Schema\WorkflowScheme {
283
        return $this->call(
×
284
            uri: '/rest/api/3/workflowscheme/{id}/default',
×
285
            method: 'delete',
×
286
            query: compact('updateDraftIfNeeded'),
×
287
            path: compact('id'),
×
288
            success: 200,
×
289
            schema: Schema\WorkflowScheme::class,
×
290
        );
×
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(
×
306
        int $id,
307
        string $issueType,
308
        ?bool $returnDraftIfExists = false,
309
    ): Schema\IssueTypeWorkflowMapping {
310
        return $this->call(
×
311
            uri: '/rest/api/3/workflowscheme/{id}/issuetype/{issueType}',
×
312
            method: 'get',
×
313
            query: compact('returnDraftIfExists'),
×
314
            path: compact('id', 'issueType'),
×
315
            success: 200,
×
316
            schema: Schema\IssueTypeWorkflowMapping::class,
×
317
        );
×
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(
×
335
        Schema\IssueTypeWorkflowMapping $request,
336
        int $id,
337
        string $issueType,
338
    ): Schema\WorkflowScheme {
339
        return $this->call(
×
340
            uri: '/rest/api/3/workflowscheme/{id}/issuetype/{issueType}',
×
341
            method: 'put',
×
342
            body: $request,
×
343
            path: compact('id', 'issueType'),
×
344
            success: 200,
×
345
            schema: Schema\WorkflowScheme::class,
×
346
        );
×
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(
×
366
        int $id,
367
        string $issueType,
368
        ?bool $updateDraftIfNeeded = false,
369
    ): Schema\WorkflowScheme {
370
        return $this->call(
×
371
            uri: '/rest/api/3/workflowscheme/{id}/issuetype/{issueType}',
×
372
            method: 'delete',
×
373
            query: compact('updateDraftIfNeeded'),
×
374
            path: compact('id', 'issueType'),
×
375
            success: 200,
×
376
            schema: Schema\WorkflowScheme::class,
×
377
        );
×
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(
×
394
        int $id,
395
        ?string $workflowName = null,
396
        ?bool $returnDraftIfExists = false,
397
    ): Schema\IssueTypesWorkflowMapping {
398
        return $this->call(
×
399
            uri: '/rest/api/3/workflowscheme/{id}/workflow',
×
400
            method: 'get',
×
401
            query: compact('workflowName', 'returnDraftIfExists'),
×
402
            path: compact('id'),
×
403
            success: 200,
×
404
            schema: Schema\IssueTypesWorkflowMapping::class,
×
405
        );
×
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(
×
425
        Schema\IssueTypesWorkflowMapping $request,
426
        int $id,
427
        string $workflowName,
428
    ): Schema\WorkflowScheme {
429
        return $this->call(
×
430
            uri: '/rest/api/3/workflowscheme/{id}/workflow',
×
431
            method: 'put',
×
432
            body: $request,
×
433
            query: compact('workflowName'),
×
434
            path: compact('id'),
×
435
            success: 200,
×
436
            schema: Schema\WorkflowScheme::class,
×
437
        );
×
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(
×
480
        string $workflowSchemeId,
481
        ?string $nextPageToken = null,
482
        ?int $maxResults = 50,
483
    ): Schema\WorkflowSchemeProjectUsageDTO {
484
        return $this->call(
×
485
            uri: '/rest/api/3/workflowscheme/{workflowSchemeId}/projectUsages',
×
486
            method: 'get',
×
487
            query: compact('nextPageToken', 'maxResults'),
×
488
            path: compact('workflowSchemeId'),
×
489
            success: 200,
×
490
            schema: Schema\WorkflowSchemeProjectUsageDTO::class,
×
491
        );
×
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