• 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/ProjectVersions.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 ProjectVersions
10
{
11
    /**
12
     * Returns a "paginated" list of all versions in a project.
13
     * See the "Get project versions" resource if you want to get a full list of versions without pagination
14
     * 
15
     * This operation can be accessed anonymously
16
     * 
17
     * **"Permissions" required:** *Browse Projects* "project permission" for the project.
18
     * 
19
     * @link https://confluence.atlassian.com/x/yodKLg
20
     * 
21
     * @param string $projectIdOrKey The project ID or project key (case sensitive).
22
     * @param int $startAt The index of the first item to return in a page of results (page offset).
23
     * @param int $maxResults The maximum number of items to return per page.
24
     * @param 'description'|'-description'|'+description'|'name'|'-name'|'+name'|'releaseDate'|'-releaseDate'|'+releaseDate'|'sequence'|'-sequence'|'+sequence'|'startDate'|'-startDate'|'+startDate'|null $orderBy
25
     *        "Order" the results by a field:
26
     *         - `description` Sorts by version description
27
     *         - `name` Sorts by version name
28
     *         - `releaseDate` Sorts by release date, starting with the oldest date.
29
     *        Versions with no release date are listed last
30
     *         - `sequence` Sorts by the order of appearance in the user interface
31
     *         - `startDate` Sorts by start date, starting with the oldest date.
32
     *        Versions with no start date are listed last.
33
     * @param string $query Filter the results using a literal string.
34
     *                      Versions with matching `name` or `description` are returned (case insensitive).
35
     * @param string $status A list of status values used to filter the results by version status.
36
     *                       This parameter accepts a comma-separated list.
37
     *                       The status values are `released`, `unreleased`, and `archived`.
38
     * @param string $expand Use "expand" to include additional information in the response.
39
     *                       This parameter accepts a comma-separated list.
40
     *                       Expand options include:
41
     *                        - `issuesstatus` Returns the number of issues in each status category for each version
42
     *                        - `operations` Returns actions that can be performed on the specified version
43
     *                        - `driver` Returns the Atlassian account ID of the version driver
44
     *                        - `approvers` Returns a list containing the approvers for this version.
45
     */
46
    public function getProjectVersionsPaginated(
×
47
        string $projectIdOrKey,
48
        ?int $startAt = 0,
49
        ?int $maxResults = 50,
50
        ?string $orderBy = null,
51
        ?string $query = null,
52
        ?string $status = null,
53
        ?string $expand = null,
54
    ): Schema\PageBeanVersion {
55
        return $this->call(
×
56
            uri: '/rest/api/3/project/{projectIdOrKey}/version',
×
57
            method: 'get',
×
58
            query: compact('startAt', 'maxResults', 'orderBy', 'query', 'status', 'expand'),
×
59
            path: compact('projectIdOrKey'),
×
60
            success: 200,
×
61
            schema: Schema\PageBeanVersion::class,
×
62
        );
×
63
    }
64

65
    /**
66
     * Returns all versions in a project.
67
     * The response is not paginated.
68
     * Use "Get project versions paginated" if you want to get the versions in a project with pagination
69
     * 
70
     * This operation can be accessed anonymously
71
     * 
72
     * **"Permissions" required:** *Browse Projects* "project permission" for the project.
73
     * 
74
     * @link https://confluence.atlassian.com/x/yodKLg
75
     * 
76
     * @param string $projectIdOrKey The project ID or project key (case sensitive).
77
     * @param string $expand Use "expand" to include additional information in the response.
78
     *                       This parameter accepts `operations`, which returns actions that can be performed on the version.
79
     */
80
    public function getProjectVersions(
×
81
        string $projectIdOrKey,
82
        ?string $expand = null,
83
    ): true {
84
        return $this->call(
×
85
            uri: '/rest/api/3/project/{projectIdOrKey}/versions',
×
86
            method: 'get',
×
87
            query: compact('expand'),
×
88
            path: compact('projectIdOrKey'),
×
89
            success: 200,
×
90
            schema: true,
×
91
        );
×
92
    }
93

94
    /**
95
     * Creates a project version
96
     * 
97
     * This operation can be accessed anonymously
98
     * 
99
     * **"Permissions" required:** *Administer Jira* "global permission" or *Administer Projects* "project permission" for the project the version is added to.
100
     * 
101
     * @link https://confluence.atlassian.com/x/x4dKLg
102
     * @link https://confluence.atlassian.com/x/yodKLg
103
     */
104
    public function createVersion(
×
105
        Schema\Version $request,
106
    ): Schema\Version {
107
        return $this->call(
×
108
            uri: '/rest/api/3/version',
×
109
            method: 'post',
×
110
            body: $request,
×
111
            success: 201,
×
112
            schema: Schema\Version::class,
×
113
        );
×
114
    }
115

116
    /**
117
     * Returns a project version
118
     * 
119
     * This operation can be accessed anonymously
120
     * 
121
     * **"Permissions" required:** *Browse projects* "project permission" for the project containing the version.
122
     * 
123
     * @link https://confluence.atlassian.com/x/yodKLg
124
     * 
125
     * @param string $id The ID of the version.
126
     * @param string $expand Use "expand" to include additional information about version in the response.
127
     *                       This parameter accepts a comma-separated list.
128
     *                       Expand options include:
129
     *                        - `operations` Returns the list of operations available for this version
130
     *                        - `issuesstatus` Returns the count of issues in this version for each of the status categories *to do*, *in progress*, *done*, and *unmapped*.
131
     *                       The *unmapped* property represents the number of issues with a status other than *to do*, *in progress*, and *done*
132
     *                        - `driver` Returns the Atlassian account ID of the version driver
133
     *                        - `approvers` Returns a list containing the Atlassian account IDs of approvers for this version.
134
     */
135
    public function getVersion(
×
136
        string $id,
137
        ?string $expand = null,
138
    ): Schema\Version {
139
        return $this->call(
×
140
            uri: '/rest/api/3/version/{id}',
×
141
            method: 'get',
×
142
            query: compact('expand'),
×
143
            path: compact('id'),
×
144
            success: 200,
×
145
            schema: Schema\Version::class,
×
146
        );
×
147
    }
148

149
    /**
150
     * Updates a project version
151
     * 
152
     * This operation can be accessed anonymously
153
     * 
154
     * **"Permissions" required:** *Administer Jira* "global permission" or *Administer Projects* "project permission" for the project that contains the version.
155
     * 
156
     * @link https://confluence.atlassian.com/x/x4dKLg
157
     * @link https://confluence.atlassian.com/x/yodKLg
158
     * 
159
     * @param string $id The ID of the version.
160
     */
161
    public function updateVersion(
×
162
        Schema\Version $request,
163
        string $id,
164
    ): Schema\Version {
165
        return $this->call(
×
166
            uri: '/rest/api/3/version/{id}',
×
167
            method: 'put',
×
168
            body: $request,
×
169
            path: compact('id'),
×
170
            success: 200,
×
171
            schema: Schema\Version::class,
×
172
        );
×
173
    }
174

175
    /**
176
     * Deletes a project version
177
     * 
178
     * Deprecated, use " Delete and replace version" that supports swapping version values in custom fields, in addition to the swapping for `fixVersion` and `affectedVersion` provided in this resource
179
     * 
180
     * Alternative versions can be provided to update issues that use the deleted version in `fixVersion` or `affectedVersion`.
181
     * If alternatives are not provided, occurrences of `fixVersion` and `affectedVersion` that contain the deleted version are cleared
182
     * 
183
     * This operation can be accessed anonymously
184
     * 
185
     * **"Permissions" required:** *Administer Jira* "global permission" or *Administer Projects* "project permission" for the project that contains the version.
186
     * 
187
     * @link https://confluence.atlassian.com/x/x4dKLg
188
     * @link https://confluence.atlassian.com/x/yodKLg
189
     * 
190
     * @param string $id The ID of the version.
191
     * @param string $moveFixIssuesTo The ID of the version to update `fixVersion` to when the field contains the deleted version.
192
     *                                The replacement version must be in the same project as the version being deleted and cannot be the version being deleted.
193
     * @param string $moveAffectedIssuesTo The ID of the version to update `affectedVersion` to when the field contains the deleted version.
194
     *                                     The replacement version must be in the same project as the version being deleted and cannot be the version being deleted.
195
     */
196
    public function deleteVersion(
×
197
        string $id,
198
        ?string $moveFixIssuesTo = null,
199
        ?string $moveAffectedIssuesTo = null,
200
    ): true {
201
        return $this->call(
×
202
            uri: '/rest/api/3/version/{id}',
×
203
            method: 'delete',
×
204
            query: compact('moveFixIssuesTo', 'moveAffectedIssuesTo'),
×
205
            path: compact('id'),
×
206
            success: 204,
×
207
            schema: true,
×
208
        );
×
209
    }
210

211
    /**
212
     * Merges two project versions.
213
     * The merge is completed by deleting the version specified in `id` and replacing any occurrences of its ID in `fixVersion` with the version ID specified in `moveIssuesTo`
214
     * 
215
     * Consider using " Delete and replace version" instead.
216
     * This resource supports swapping version values in `fixVersion`, `affectedVersion`, and custom fields
217
     * 
218
     * This operation can be accessed anonymously
219
     * 
220
     * **"Permissions" required:** *Administer Jira* "global permission" or *Administer Projects* "project permission" for the project that contains the version.
221
     * 
222
     * @link https://confluence.atlassian.com/x/x4dKLg
223
     * @link https://confluence.atlassian.com/x/yodKLg
224
     * 
225
     * @param string $id The ID of the version to delete.
226
     * @param string $moveIssuesTo The ID of the version to merge into.
227
     */
228
    public function mergeVersions(
×
229
        string $id,
230
        string $moveIssuesTo,
231
    ): true {
232
        return $this->call(
×
233
            uri: '/rest/api/3/version/{id}/mergeto/{moveIssuesTo}',
×
234
            method: 'put',
×
235
            path: compact('id', 'moveIssuesTo'),
×
236
            success: 204,
×
237
            schema: true,
×
238
        );
×
239
    }
240

241
    /**
242
     * Modifies the version's sequence within the project, which affects the display order of the versions in Jira
243
     * 
244
     * This operation can be accessed anonymously
245
     * 
246
     * **"Permissions" required:** *Browse projects* project permission for the project that contains the version.
247
     * 
248
     * @param string $id The ID of the version to be moved.
249
     */
250
    public function moveVersion(
×
251
        Schema\VersionMoveBean $request,
252
        string $id,
253
    ): Schema\Version {
254
        return $this->call(
×
255
            uri: '/rest/api/3/version/{id}/move',
×
256
            method: 'post',
×
257
            body: $request,
×
258
            path: compact('id'),
×
259
            success: 200,
×
260
            schema: Schema\Version::class,
×
261
        );
×
262
    }
263

264
    /**
265
     * Returns the following counts for a version:
266
     * 
267
     *  - Number of issues where the `fixVersion` is set to the version
268
     *  - Number of issues where the `affectedVersion` is set to the version
269
     *  - Number of issues where a version custom field is set to the version
270
     * 
271
     * This operation can be accessed anonymously
272
     * 
273
     * **"Permissions" required:** *Browse projects* project permission for the project that contains the version.
274
     * 
275
     * @param string $id The ID of the version.
276
     */
277
    public function getVersionRelatedIssues(
×
278
        string $id,
279
    ): Schema\VersionIssueCounts {
280
        return $this->call(
×
281
            uri: '/rest/api/3/version/{id}/relatedIssueCounts',
×
282
            method: 'get',
×
283
            path: compact('id'),
×
284
            success: 200,
×
285
            schema: Schema\VersionIssueCounts::class,
×
286
        );
×
287
    }
288

289
    /**
290
     * Returns related work items for the given version id
291
     * 
292
     * This operation can be accessed anonymously
293
     * 
294
     * **"Permissions" required:** *Browse projects* "project permission" for the project containing the version.
295
     * 
296
     * @link https://confluence.atlassian.com/x/yodKLg
297
     * 
298
     * @param string $id The ID of the version.
299
     */
300
    public function getRelatedWork(
×
301
        string $id,
302
    ): true {
303
        return $this->call(
×
304
            uri: '/rest/api/3/version/{id}/relatedwork',
×
305
            method: 'get',
×
306
            path: compact('id'),
×
307
            success: 200,
×
308
            schema: true,
×
309
        );
×
310
    }
311

312
    /**
313
     * Updates the given related work.
314
     * You can only update generic link related works via Rest APIs.
315
     * Any archived version related works can't be edited
316
     * 
317
     * This operation can be accessed anonymously
318
     * 
319
     * **"Permissions" required:** *Resolve issues:* and *Edit issues* "Managing project permissions" for the project that contains the version.
320
     * 
321
     * @link https://confluence.atlassian.com/adminjiraserver/managing-project-permissions-938847145.html
322
     * 
323
     * @param string $id The ID of the version to update the related work on.
324
     *                   For the related work id, pass it to the input JSON.
325
     */
326
    public function updateRelatedWork(
×
327
        Schema\VersionRelatedWork $request,
328
        string $id,
329
    ): Schema\VersionRelatedWork {
330
        return $this->call(
×
331
            uri: '/rest/api/3/version/{id}/relatedwork',
×
332
            method: 'put',
×
333
            body: $request,
×
334
            path: compact('id'),
×
335
            success: 200,
×
336
            schema: Schema\VersionRelatedWork::class,
×
337
        );
×
338
    }
339

340
    /**
341
     * Creates a related work for the given version.
342
     * You can only create a generic link type of related works via this API.
343
     * relatedWorkId will be auto-generated UUID, that does not need to be provided
344
     * 
345
     * This operation can be accessed anonymously
346
     * 
347
     * **"Permissions" required:** *Resolve issues:* and *Edit issues* "Managing project permissions" for the project that contains the version.
348
     * 
349
     * @link https://confluence.atlassian.com/adminjiraserver/managing-project-permissions-938847145.html
350
     * 
351
     * @param string $id 
352
     */
353
    public function createRelatedWork(
×
354
        Schema\VersionRelatedWork $request,
355
        string $id,
356
    ): Schema\VersionRelatedWork {
357
        return $this->call(
×
358
            uri: '/rest/api/3/version/{id}/relatedwork',
×
359
            method: 'post',
×
360
            body: $request,
×
361
            path: compact('id'),
×
362
            success: 201,
×
363
            schema: Schema\VersionRelatedWork::class,
×
364
        );
×
365
    }
366

367
    /**
368
     * Deletes a project version
369
     * 
370
     * Alternative versions can be provided to update issues that use the deleted version in `fixVersion`, `affectedVersion`, or any version picker custom fields.
371
     * If alternatives are not provided, occurrences of `fixVersion`, `affectedVersion`, and any version picker custom field, that contain the deleted version, are cleared.
372
     * Any replacement version must be in the same project as the version being deleted and cannot be the version being deleted
373
     * 
374
     * This operation can be accessed anonymously
375
     * 
376
     * **"Permissions" required:** *Administer Jira* "global permission" or *Administer Projects* "project permission" for the project that contains the version.
377
     * 
378
     * @link https://confluence.atlassian.com/x/x4dKLg
379
     * @link https://confluence.atlassian.com/x/yodKLg
380
     * 
381
     * @param string $id The ID of the version.
382
     */
383
    public function deleteAndReplaceVersion(
×
384
        Schema\DeleteAndReplaceVersionBean $request,
385
        string $id,
386
    ): true {
387
        return $this->call(
×
388
            uri: '/rest/api/3/version/{id}/removeAndSwap',
×
389
            method: 'post',
×
390
            body: $request,
×
391
            path: compact('id'),
×
392
            success: 204,
×
393
            schema: true,
×
394
        );
×
395
    }
396

397
    /**
398
     * Returns counts of the issues and unresolved issues for the project version
399
     * 
400
     * This operation can be accessed anonymously
401
     * 
402
     * **"Permissions" required:** *Browse projects* project permission for the project that contains the version.
403
     * 
404
     * @param string $id The ID of the version.
405
     */
406
    public function getVersionUnresolvedIssues(
×
407
        string $id,
408
    ): Schema\VersionUnresolvedIssuesCount {
409
        return $this->call(
×
410
            uri: '/rest/api/3/version/{id}/unresolvedIssueCount',
×
411
            method: 'get',
×
412
            path: compact('id'),
×
413
            success: 200,
×
414
            schema: Schema\VersionUnresolvedIssuesCount::class,
×
415
        );
×
416
    }
417

418
    /**
419
     * Deletes the given related work for the given version
420
     * 
421
     * This operation can be accessed anonymously
422
     * 
423
     * **"Permissions" required:** *Resolve issues:* and *Edit issues* "Managing project permissions" for the project that contains the version.
424
     * 
425
     * @link https://confluence.atlassian.com/adminjiraserver/managing-project-permissions-938847145.html
426
     * 
427
     * @param string $versionId The ID of the version that the target related work belongs to.
428
     * @param string $relatedWorkId The ID of the related work to delete.
429
     */
430
    public function deleteRelatedWork(
×
431
        string $versionId,
432
        string $relatedWorkId,
433
    ): true {
434
        return $this->call(
×
435
            uri: '/rest/api/3/version/{versionId}/relatedwork/{relatedWorkId}',
×
436
            method: 'delete',
×
437
            path: compact('versionId', 'relatedWorkId'),
×
438
            success: 204,
×
439
            schema: true,
×
440
        );
×
441
    }
442
}
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