• 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/Users.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 Users
10
{
11
    /**
12
     * Returns a user
13
     * 
14
     * Privacy controls are applied to the response based on the user's preferences.
15
     * This could mean, for example, that the user's email address is hidden.
16
     * See the "Profile visibility overview" for more details
17
     * 
18
     * **"Permissions" required:** *Browse users and groups* "global permission".
19
     * 
20
     * @link https://developer.atlassian.com/cloud/jira/platform/profile-visibility/
21
     * @link https://confluence.atlassian.com/x/x4dKLg
22
     * 
23
     * @param string $accountId The account ID of the user, which uniquely identifies the user across all Atlassian products.
24
     *                          For example, *5b10ac8d82e05b22cc7d4ef5*.
25
     *                          Required.
26
     * @param string $username This parameter is no longer available.
27
     *                         See the "deprecation notice" for details.
28
     *                         @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
29
     * @param string $key This parameter is no longer available.
30
     *                    See the "deprecation notice" for details.
31
     *                    @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
32
     * @param string $expand Use "expand" to include additional information about users in the response.
33
     *                       This parameter accepts a comma-separated list.
34
     *                       Expand options include:
35
     *                        - `groups` includes all groups and nested groups to which the user belongs
36
     *                        - `applicationRoles` includes details of all the applications to which the user has access.
37
     */
38
    public function getUser(
×
39
        ?string $accountId = null,
40
        ?string $username = null,
41
        ?string $key = null,
42
        ?string $expand = null,
43
    ): Schema\User {
44
        return $this->call(
×
45
            uri: '/rest/api/3/user',
×
46
            method: 'get',
×
47
            query: compact('accountId', 'username', 'key', 'expand'),
×
48
            success: 200,
×
49
            schema: Schema\User::class,
×
50
        );
×
51
    }
52

53
    /**
54
     * Creates a user.
55
     * This resource is retained for legacy compatibility.
56
     * As soon as a more suitable alternative is available this resource will be deprecated
57
     * 
58
     * If the user exists and has access to Jira, the operation returns a 201 status.
59
     * If the user exists but does not have access to Jira, the operation returns a 400 status
60
     * 
61
     * **"Permissions" required:** *Administer Jira* "global permission".
62
     * 
63
     * @link https://confluence.atlassian.com/x/x4dKLg
64
     */
65
    public function createUser(
×
66
        Schema\NewUserDetails $request,
67
    ): Schema\User {
68
        return $this->call(
×
69
            uri: '/rest/api/3/user',
×
70
            method: 'post',
×
71
            body: $request,
×
72
            success: 201,
×
73
            schema: Schema\User::class,
×
74
        );
×
75
    }
76

77
    /**
78
     * Deletes a user.
79
     * If the operation completes successfully then the user is removed from Jira's user base.
80
     * This operation does not delete the user's Atlassian account
81
     * 
82
     * **"Permissions" required:** Site administration (that is, membership of the *site-admin* "group").
83
     * 
84
     * @link https://confluence.atlassian.com/x/24xjL
85
     * 
86
     * @param string $accountId The account ID of the user, which uniquely identifies the user across all Atlassian products.
87
     *                          For example, *5b10ac8d82e05b22cc7d4ef5*.
88
     * @param string $username This parameter is no longer available.
89
     *                         See the "deprecation notice" for details.
90
     *                         @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
91
     * @param string $key This parameter is no longer available.
92
     *                    See the "deprecation notice" for details.
93
     *                    @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
94
     */
95
    public function removeUser(
×
96
        string $accountId,
97
        ?string $username = null,
98
        ?string $key = null,
99
    ): true {
100
        return $this->call(
×
101
            uri: '/rest/api/3/user',
×
102
            method: 'delete',
×
103
            query: compact('accountId', 'username', 'key'),
×
104
            success: 204,
×
105
            schema: true,
×
106
        );
×
107
    }
108

109
    /**
110
     * Returns a "paginated" list of the users specified by one or more account IDs
111
     * 
112
     * **"Permissions" required:** Permission to access Jira.
113
     * 
114
     * @param list<string> $accountId The account ID of a user.
115
     *                                To specify multiple users, pass multiple `accountId` parameters.
116
     *                                For example, `accountId=5b10a2844c20165700ede21g&accountId=5b10ac8d82e05b22cc7d4ef5`.
117
     * @param int $startAt The index of the first item to return in a page of results (page offset).
118
     * @param int $maxResults The maximum number of items to return per page.
119
     * @param ?list<string> $username This parameter is no longer available and will be removed from the documentation soon.
120
     *                                See the "deprecation notice" for details.
121
     *                                @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
122
     * @param ?list<string> $key This parameter is no longer available and will be removed from the documentation soon.
123
     *                           See the "deprecation notice" for details.
124
     *                           @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
125
     */
126
    public function bulkGetUsers(
×
127
        array $accountId,
128
        ?int $startAt = 0,
129
        ?int $maxResults = 10,
130
        ?array $username = null,
131
        ?array $key = null,
132
    ): Schema\PageBeanUser {
133
        return $this->call(
×
134
            uri: '/rest/api/3/user/bulk',
×
135
            method: 'get',
×
136
            query: compact('accountId', 'startAt', 'maxResults', 'username', 'key'),
×
137
            success: 200,
×
138
            schema: Schema\PageBeanUser::class,
×
139
        );
×
140
    }
141

142
    /**
143
     * Returns the account IDs for the users specified in the `key` or `username` parameters.
144
     * Note that multiple `key` or `username` parameters can be specified
145
     * 
146
     * **"Permissions" required:** Permission to access Jira.
147
     * 
148
     * @param int $startAt The index of the first item to return in a page of results (page offset).
149
     * @param int $maxResults The maximum number of items to return per page.
150
     * @param ?list<string> $username Username of a user.
151
     *                                To specify multiple users, pass multiple copies of this parameter.
152
     *                                For example, `username=fred&username=barney`.
153
     *                                Required if `key` isn't provided.
154
     *                                Cannot be provided if `key` is present.
155
     * @param ?list<string> $key Key of a user.
156
     *                           To specify multiple users, pass multiple copies of this parameter.
157
     *                           For example, `key=fred&key=barney`.
158
     *                           Required if `username` isn't provided.
159
     *                           Cannot be provided if `username` is present.
160
     * 
161
     * @return list<Schema\UserMigrationBean>
162
     */
163
    public function bulkGetUsersMigration(
×
164
        ?int $startAt = 0,
165
        ?int $maxResults = 10,
166
        ?array $username = null,
167
        ?array $key = null,
168
    ): array {
169
        return $this->call(
×
170
            uri: '/rest/api/3/user/bulk/migration',
×
171
            method: 'get',
×
172
            query: compact('startAt', 'maxResults', 'username', 'key'),
×
173
            success: 200,
×
174
            schema: [Schema\UserMigrationBean::class],
×
175
        );
×
176
    }
177

178
    /**
179
     * Returns the default "issue table columns" for the user.
180
     * If `accountId` is not passed in the request, the calling user's details are returned
181
     * 
182
     * **"Permissions" required:**
183
     * 
184
     *  - *Administer Jira* "global permission", to get the column details for any user
185
     *  - Permission to access Jira, to get the calling user's column details.
186
     * 
187
     * @link https://confluence.atlassian.com/x/XYdKLg
188
     * @link https://confluence.atlassian.com/x/x4dKLgl
189
     * 
190
     * @param string $accountId The account ID of the user, which uniquely identifies the user across all Atlassian products.
191
     *                          For example, *5b10ac8d82e05b22cc7d4ef5*.
192
     * @param string $username This parameter is no longer available See the "deprecation notice" for details.
193
     *                         @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
194
     * 
195
     * @return list<Schema\ColumnItem>
196
     */
197
    public function getUserDefaultColumns(
×
198
        ?string $accountId = null,
199
        ?string $username = null,
200
    ): array {
201
        return $this->call(
×
202
            uri: '/rest/api/3/user/columns',
×
203
            method: 'get',
×
204
            query: compact('accountId', 'username'),
×
205
            success: 200,
×
206
            schema: [Schema\ColumnItem::class],
×
207
        );
×
208
    }
209

210
    /**
211
     * Sets the default " issue table columns" for the user.
212
     * If an account ID is not passed, the calling user's default columns are set.
213
     * If no column details are sent, then all default columns are removed
214
     * 
215
     * The parameters for this resource are expressed as HTML form data.
216
     * For example, in curl:
217
     * 
218
     * `curl -X PUT -d columns=summary -d columns=description https://your-domain.atlassian.net/rest/api/3/user/columns?accountId=5b10ac8d82e05b22cc7d4ef5'`
219
     * 
220
     * **"Permissions" required:**
221
     * 
222
     *  - *Administer Jira* "global permission", to set the columns on any user
223
     *  - Permission to access Jira, to set the calling user's columns.
224
     * 
225
     * @link https://confluence.atlassian.com/x/XYdKLg
226
     * @link https://confluence.atlassian.com/x/x4dKLg
227
     * 
228
     * @param string $accountId The account ID of the user, which uniquely identifies the user across all Atlassian products.
229
     *                          For example, *5b10ac8d82e05b22cc7d4ef5*.
230
     */
231
    public function setUserColumns(
×
232
        ?string $accountId = null,
233
    ): true {
234
        return $this->call(
×
235
            uri: '/rest/api/3/user/columns',
×
236
            method: 'put',
×
237
            query: compact('accountId'),
×
238
            success: 200,
×
239
            schema: true,
×
240
        );
×
241
    }
242

243
    /**
244
     * Resets the default " issue table columns" for the user to the system default.
245
     * If `accountId` is not passed, the calling user's default columns are reset
246
     * 
247
     * **"Permissions" required:**
248
     * 
249
     *  - *Administer Jira* "global permission", to set the columns on any user
250
     *  - Permission to access Jira, to set the calling user's columns.
251
     * 
252
     * @link https://confluence.atlassian.com/x/XYdKLg
253
     * @link https://confluence.atlassian.com/x/x4dKLg
254
     * 
255
     * @param string $accountId The account ID of the user, which uniquely identifies the user across all Atlassian products.
256
     *                          For example, *5b10ac8d82e05b22cc7d4ef5*.
257
     * @param string $username This parameter is no longer available.
258
     *                         See the "deprecation notice" for details.
259
     *                         @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
260
     */
261
    public function resetUserColumns(
×
262
        ?string $accountId = null,
263
        ?string $username = null,
264
    ): true {
265
        return $this->call(
×
266
            uri: '/rest/api/3/user/columns',
×
267
            method: 'delete',
×
268
            query: compact('accountId', 'username'),
×
269
            success: 204,
×
270
            schema: true,
×
271
        );
×
272
    }
273

274
    /**
275
     * Returns a user's email address regardless of the user's profile visibility settings.
276
     * For Connect apps, this API is only available to apps approved by Atlassian, according to these "guidelines".
277
     * For Forge apps, this API only supports access via asApp() requests.
278
     * 
279
     * @link https://community.developer.atlassian.com/t/guidelines-for-requesting-access-to-email-address/27603
280
     * 
281
     * @param string $accountId The account ID of the user, which uniquely identifies the user across all Atlassian products.
282
     *                          For example, `5b10ac8d82e05b22cc7d4ef5`.
283
     */
284
    public function getUserEmail(
×
285
        string $accountId,
286
    ): Schema\UnrestrictedUserEmail {
287
        return $this->call(
×
288
            uri: '/rest/api/3/user/email',
×
289
            method: 'get',
×
290
            query: compact('accountId'),
×
291
            success: 200,
×
292
            schema: Schema\UnrestrictedUserEmail::class,
×
293
        );
×
294
    }
295

296
    /**
297
     * Returns a user's email address regardless of the user's profile visibility settings.
298
     * For Connect apps, this API is only available to apps approved by Atlassian, according to these "guidelines".
299
     * For Forge apps, this API only supports access via asApp() requests.
300
     * 
301
     * @link https://community.developer.atlassian.com/t/guidelines-for-requesting-access-to-email-address/27603
302
     * 
303
     * @param list<string> $accountId The account IDs of the users for which emails are required.
304
     *                                An `accountId` is an identifier that uniquely identifies the user across all Atlassian products.
305
     *                                For example, `5b10ac8d82e05b22cc7d4ef5`.
306
     *                                Note, this should be treated as an opaque identifier (that is, do not assume any structure in the value).
307
     */
308
    public function getUserEmailBulk(
×
309
        array $accountId,
310
    ): Schema\UnrestrictedUserEmail {
311
        return $this->call(
×
312
            uri: '/rest/api/3/user/email/bulk',
×
313
            method: 'get',
×
314
            query: compact('accountId'),
×
315
            success: 200,
×
316
            schema: Schema\UnrestrictedUserEmail::class,
×
317
        );
×
318
    }
319

320
    /**
321
     * Returns the groups to which a user belongs
322
     * 
323
     * **"Permissions" required:** *Browse users and groups* "global permission".
324
     * 
325
     * @link https://confluence.atlassian.com/x/x4dKLg
326
     * 
327
     * @param string $accountId The account ID of the user, which uniquely identifies the user across all Atlassian products.
328
     *                          For example, *5b10ac8d82e05b22cc7d4ef5*.
329
     * @param string $username This parameter is no longer available.
330
     *                         See the "deprecation notice" for details.
331
     *                         @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
332
     * @param string $key This parameter is no longer available.
333
     *                    See the "deprecation notice" for details.
334
     *                    @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
335
     * 
336
     * @return list<Schema\GroupName>
337
     */
338
    public function getUserGroups(
×
339
        string $accountId,
340
        ?string $username = null,
341
        ?string $key = null,
342
    ): array {
343
        return $this->call(
×
344
            uri: '/rest/api/3/user/groups',
×
345
            method: 'get',
×
346
            query: compact('accountId', 'username', 'key'),
×
347
            success: 200,
×
348
            schema: [Schema\GroupName::class],
×
349
        );
×
350
    }
351

352
    /**
353
     * Returns a list of all users, including active users, inactive users and previously deleted users that have an Atlassian account
354
     * 
355
     * Privacy controls are applied to the response based on the users' preferences.
356
     * This could mean, for example, that the user's email address is hidden.
357
     * See the "Profile visibility overview" for more details
358
     * 
359
     * **"Permissions" required:** *Browse users and groups* "global permission".
360
     * 
361
     * @link https://developer.atlassian.com/cloud/jira/platform/profile-visibility/
362
     * @link https://confluence.atlassian.com/x/x4dKLg
363
     * 
364
     * @param int $startAt The index of the first item to return.
365
     * @param int $maxResults The maximum number of items to return.
366
     * 
367
     * @return list<Schema\User>
368
     */
369
    public function getAllUsersDefault(
×
370
        ?int $startAt = 0,
371
        ?int $maxResults = 50,
372
    ): array {
373
        return $this->call(
×
374
            uri: '/rest/api/3/users',
×
375
            method: 'get',
×
376
            query: compact('startAt', 'maxResults'),
×
377
            success: 200,
×
378
            schema: [Schema\User::class],
×
379
        );
×
380
    }
381

382
    /**
383
     * Returns a list of all users, including active users, inactive users and previously deleted users that have an Atlassian account
384
     * 
385
     * Privacy controls are applied to the response based on the users' preferences.
386
     * This could mean, for example, that the user's email address is hidden.
387
     * See the "Profile visibility overview" for more details
388
     * 
389
     * **"Permissions" required:** *Browse users and groups* "global permission".
390
     * 
391
     * @link https://developer.atlassian.com/cloud/jira/platform/profile-visibility/
392
     * @link https://confluence.atlassian.com/x/x4dKLg
393
     * 
394
     * @param int $startAt The index of the first item to return.
395
     * @param int $maxResults The maximum number of items to return.
396
     * 
397
     * @return list<Schema\User>
398
     */
399
    public function getAllUsers(
×
400
        ?int $startAt = 0,
401
        ?int $maxResults = 50,
402
    ): array {
403
        return $this->call(
×
404
            uri: '/rest/api/3/users/search',
×
405
            method: 'get',
×
406
            query: compact('startAt', 'maxResults'),
×
407
            success: 200,
×
408
            schema: [Schema\User::class],
×
409
        );
×
410
    }
411
}
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