• 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/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
     * @return list<Schema\Version>
81
     */
82
    public function getProjectVersions(
×
83
        string $projectIdOrKey,
84
        ?string $expand = null,
85
    ): array {
86
        return $this->call(
×
87
            uri: '/rest/api/3/project/{projectIdOrKey}/versions',
×
88
            method: 'get',
×
89
            query: compact('expand'),
×
90
            path: compact('projectIdOrKey'),
×
91
            success: 200,
×
92
            schema: [Schema\Version::class],
×
93
        );
×
94
    }
95

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

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

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

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

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

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

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

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

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

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

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

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

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