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

tylernathanreed / jira-client-php / 13634794100

03 Mar 2025 03:19PM UTC coverage: 2.067% (-0.1%) from 2.21%
13634794100

push

github

web-flow
~ Try coveralls action

140 of 6773 relevant lines covered (2.07%)

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
    public function readWorkflowSchemes(
×
70
        Schema\WorkflowSchemeReadRequest $request,
71
        ?string $expand = null,
72
    ): true {
73
        return $this->call(
×
74
            uri: '/rest/api/3/workflowscheme/read',
×
75
            method: 'post',
×
76
            body: $request,
×
77
            query: compact('expand'),
×
78
            success: 200,
×
79
            schema: true,
×
80
        );
×
81
    }
82

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

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

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

155
    /**
156
     * Updates a company-manged project workflow scheme, including the name, default workflow, issue type to project mappings, and more.
157
     * 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`
158
     * 
159
     * **"Permissions" required:** *Administer Jira* "global permission".
160
     * 
161
     * @link https://confluence.atlassian.com/x/x4dKLg
162
     * 
163
     * @param int $id The ID of the workflow scheme.
164
     *                Find this ID by editing the desired workflow scheme in Jira.
165
     *                The ID is shown in the URL as `schemeId`.
166
     *                For example, *schemeId=10301*.
167
     */
168
    public function updateWorkflowScheme(
×
169
        Schema\WorkflowScheme $request,
170
        int $id,
171
    ): Schema\WorkflowScheme {
172
        return $this->call(
×
173
            uri: '/rest/api/3/workflowscheme/{id}',
×
174
            method: 'put',
×
175
            body: $request,
×
176
            path: compact('id'),
×
177
            success: 200,
×
178
            schema: Schema\WorkflowScheme::class,
×
179
        );
×
180
    }
181

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

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

234
    /**
235
     * Sets the default workflow for a workflow scheme
236
     * 
237
     * Note that active workflow schemes cannot be edited.
238
     * 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.
239
     * The draft workflow scheme can be published in Jira
240
     * 
241
     * **"Permissions" required:** *Administer Jira* "global permission".
242
     * 
243
     * @link https://confluence.atlassian.com/x/x4dKLg
244
     * 
245
     * @param int $id The ID of the workflow scheme.
246
     */
247
    public function updateDefaultWorkflow(
×
248
        Schema\DefaultWorkflow $request,
249
        int $id,
250
    ): Schema\WorkflowScheme {
251
        return $this->call(
×
252
            uri: '/rest/api/3/workflowscheme/{id}/default',
×
253
            method: 'put',
×
254
            body: $request,
×
255
            path: compact('id'),
×
256
            success: 200,
×
257
            schema: Schema\WorkflowScheme::class,
×
258
        );
×
259
    }
260

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

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

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

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

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

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

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

469
    /**
470
     * Returns a page of projects using a given workflow scheme.
471
     * 
472
     * @param string $workflowSchemeId The workflow scheme ID
473
     * @param string $nextPageToken The cursor for pagination
474
     * @param int $maxResults The maximum number of results to return.
475
     *                        Must be an integer between 1 and 200.
476
     */
477
    public function getProjectUsagesForWorkflowScheme(
×
478
        string $workflowSchemeId,
479
        ?string $nextPageToken = null,
480
        ?int $maxResults = 50,
481
    ): Schema\WorkflowSchemeProjectUsageDTO {
482
        return $this->call(
×
483
            uri: '/rest/api/3/workflowscheme/{workflowSchemeId}/projectUsages',
×
484
            method: 'get',
×
485
            query: compact('nextPageToken', 'maxResults'),
×
486
            path: compact('workflowSchemeId'),
×
487
            success: 200,
×
488
            schema: Schema\WorkflowSchemeProjectUsageDTO::class,
×
489
        );
×
490
    }
491
}
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