• 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/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
    public function bulkGetUsersMigration(
×
162
        ?int $startAt = 0,
163
        ?int $maxResults = 10,
164
        ?array $username = null,
165
        ?array $key = null,
166
    ): true {
167
        return $this->call(
×
168
            uri: '/rest/api/3/user/bulk/migration',
×
169
            method: 'get',
×
170
            query: compact('startAt', 'maxResults', 'username', 'key'),
×
171
            success: 200,
×
172
            schema: true,
×
173
        );
×
174
    }
175

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

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

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

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

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

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

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

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