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

tylernathanreed / jira-client-php / 13834920235

13 Mar 2025 12:45PM UTC coverage: 71.089% (-2.2%) from 73.289%
13834920235

push

github

tylernathanreed
Merge branch 'master' of github.com:tylernathanreed/jira-client-php

3976 of 5593 relevant lines covered (71.09%)

9.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

36.92
/src/Operations/Groups.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 Groups
10
{
11
    /**
12
     * This operation is deprecated, use "`group/member`"
13
     * 
14
     * Returns all users in a group
15
     * 
16
     * **"Permissions" required:** either of:
17
     * 
18
     *  - *Browse users and groups* "global permission"
19
     *  - *Administer Jira* "global permission".
20
     * 
21
     * @link https://confluence.atlassian.com/x/x4dKLg
22
     * 
23
     * @param string $groupname As a group's name can change, use of `groupId` is recommended to identify a group.
24
     *                           
25
     *                          The name of the group.
26
     *                          This parameter cannot be used with the `groupId` parameter.
27
     * @param string $groupId The ID of the group.
28
     *                        This parameter cannot be used with the `groupName` parameter.
29
     * @param string $expand List of fields to expand.
30
     */
31
    public function getGroup(
×
32
        ?string $groupname = null,
33
        ?string $groupId = null,
34
        ?string $expand = null,
35
    ): Schema\Group {
36
        return $this->call(
×
37
            uri: '/rest/api/3/group',
×
38
            method: 'get',
×
39
            query: compact('groupname', 'groupId', 'expand'),
×
40
            success: 200,
×
41
            schema: Schema\Group::class,
×
42
        );
×
43
    }
44

45
    /**
46
     * Creates a group
47
     * 
48
     * **"Permissions" required:** Site administration (that is, member of the *site-admin* "group").
49
     * 
50
     * @link https://confluence.atlassian.com/x/24xjL
51
     */
52
    public function createGroup(
1✔
53
        Schema\AddGroupBean $request,
54
    ): Schema\Group {
55
        return $this->call(
1✔
56
            uri: '/rest/api/3/group',
1✔
57
            method: 'post',
1✔
58
            body: $request,
1✔
59
            success: 201,
1✔
60
            schema: Schema\Group::class,
1✔
61
        );
1✔
62
    }
63

64
    /**
65
     * Deletes a group
66
     * 
67
     * **"Permissions" required:** Site administration (that is, member of the *site-admin* strategic "group").
68
     * 
69
     * @link https://confluence.atlassian.com/x/24xjL
70
     * 
71
     * @param string $groupname 
72
     * @param string $groupId The ID of the group.
73
     *                        This parameter cannot be used with the `groupname` parameter.
74
     * @param string $swapGroup As a group's name can change, use of `swapGroupId` is recommended to identify a group.
75
     *                           
76
     *                          The group to transfer restrictions to.
77
     *                          Only comments and worklogs are transferred.
78
     *                          If restrictions are not transferred, comments and worklogs are inaccessible after the deletion.
79
     *                          This parameter cannot be used with the `swapGroupId` parameter.
80
     * @param string $swapGroupId The ID of the group to transfer restrictions to.
81
     *                            Only comments and worklogs are transferred.
82
     *                            If restrictions are not transferred, comments and worklogs are inaccessible after the deletion.
83
     *                            This parameter cannot be used with the `swapGroup` parameter.
84
     */
85
    public function removeGroup(
×
86
        ?string $groupname = null,
87
        ?string $groupId = null,
88
        ?string $swapGroup = null,
89
        ?string $swapGroupId = null,
90
    ): true {
91
        return $this->call(
×
92
            uri: '/rest/api/3/group',
×
93
            method: 'delete',
×
94
            query: compact('groupname', 'groupId', 'swapGroup', 'swapGroupId'),
×
95
            success: 200,
×
96
            schema: true,
×
97
        );
×
98
    }
99

100
    /**
101
     * Returns a "paginated" list of groups
102
     * 
103
     * **"Permissions" required:** *Browse users and groups* "global permission".
104
     * 
105
     * @link https://confluence.atlassian.com/x/x4dKLg
106
     * 
107
     * @param int $startAt The index of the first item to return in a page of results (page offset).
108
     * @param int $maxResults The maximum number of items to return per page.
109
     * @param ?list<string> $groupId The ID of a group.
110
     *                               To specify multiple IDs, pass multiple `groupId` parameters.
111
     *                               For example, `groupId=5b10a2844c20165700ede21g&groupId=5b10ac8d82e05b22cc7d4ef5`.
112
     * @param ?list<string> $groupName The name of a group.
113
     *                                 To specify multiple names, pass multiple `groupName` parameters.
114
     *                                 For example, `groupName=administrators&groupName=jira-software-users`.
115
     * @param string $accessType The access level of a group.
116
     *                           Valid values: 'site-admin', 'admin', 'user'.
117
     * @param string $applicationKey The application key of the product user groups to search for.
118
     *                               Valid values: 'jira-servicedesk', 'jira-software', 'jira-product-discovery', 'jira-core'.
119
     */
120
    public function bulkGetGroups(
×
121
        ?int $startAt = 0,
122
        ?int $maxResults = 50,
123
        ?array $groupId = null,
124
        ?array $groupName = null,
125
        ?string $accessType = null,
126
        ?string $applicationKey = null,
127
    ): Schema\PageBeanGroupDetails {
128
        return $this->call(
×
129
            uri: '/rest/api/3/group/bulk',
×
130
            method: 'get',
×
131
            query: compact('startAt', 'maxResults', 'groupId', 'groupName', 'accessType', 'applicationKey'),
×
132
            success: 200,
×
133
            schema: Schema\PageBeanGroupDetails::class,
×
134
        );
×
135
    }
136

137
    /**
138
     * Returns a "paginated" list of all users in a group
139
     * 
140
     * Note that users are ordered by username, however the username is not returned in the results due to privacy reasons
141
     * 
142
     * **"Permissions" required:** either of:
143
     * 
144
     *  - *Browse users and groups* "global permission"
145
     *  - *Administer Jira* "global permission".
146
     * 
147
     * @link https://confluence.atlassian.com/x/x4dKLg
148
     * 
149
     * @param string $groupname As a group's name can change, use of `groupId` is recommended to identify a group.
150
     *                           
151
     *                          The name of the group.
152
     *                          This parameter cannot be used with the `groupId` parameter.
153
     * @param string $groupId The ID of the group.
154
     *                        This parameter cannot be used with the `groupName` parameter.
155
     * @param bool $includeInactiveUsers Include inactive users.
156
     * @param int $startAt The index of the first item to return in a page of results (page offset).
157
     * @param int $maxResults The maximum number of items to return per page (number should be between 1 and 50).
158
     */
159
    public function getUsersFromGroup(
1✔
160
        ?string $groupname = null,
161
        ?string $groupId = null,
162
        ?bool $includeInactiveUsers = false,
163
        ?int $startAt = 0,
164
        ?int $maxResults = 50,
165
    ): Schema\PageBeanUserDetails {
166
        return $this->call(
1✔
167
            uri: '/rest/api/3/group/member',
1✔
168
            method: 'get',
1✔
169
            query: compact('groupname', 'groupId', 'includeInactiveUsers', 'startAt', 'maxResults'),
1✔
170
            success: 200,
1✔
171
            schema: Schema\PageBeanUserDetails::class,
1✔
172
        );
1✔
173
    }
174

175
    /**
176
     * Adds a user to a group
177
     * 
178
     * **"Permissions" required:** Site administration (that is, member of the *site-admin* "group").
179
     * 
180
     * @link https://confluence.atlassian.com/x/24xjL
181
     * 
182
     * @param string $groupname As a group's name can change, use of `groupId` is recommended to identify a group.
183
     *                           
184
     *                          The name of the group.
185
     *                          This parameter cannot be used with the `groupId` parameter.
186
     * @param string $groupId The ID of the group.
187
     *                        This parameter cannot be used with the `groupName` parameter.
188
     */
189
    public function addUserToGroup(
×
190
        Schema\UpdateUserToGroupBean $request,
191
        ?string $groupname = null,
192
        ?string $groupId = null,
193
    ): Schema\Group {
194
        return $this->call(
×
195
            uri: '/rest/api/3/group/user',
×
196
            method: 'post',
×
197
            body: $request,
×
198
            query: compact('groupname', 'groupId'),
×
199
            success: 201,
×
200
            schema: Schema\Group::class,
×
201
        );
×
202
    }
203

204
    /**
205
     * Removes a user from a group
206
     * 
207
     * **"Permissions" required:** Site administration (that is, member of the *site-admin* "group").
208
     * 
209
     * @link https://confluence.atlassian.com/x/24xjL
210
     * 
211
     * @param string $accountId The account ID of the user, which uniquely identifies the user across all Atlassian products.
212
     *                          For example, *5b10ac8d82e05b22cc7d4ef5*.
213
     * @param string $groupname As a group's name can change, use of `groupId` is recommended to identify a group.
214
     *                           
215
     *                          The name of the group.
216
     *                          This parameter cannot be used with the `groupId` parameter.
217
     * @param string $groupId The ID of the group.
218
     *                        This parameter cannot be used with the `groupName` parameter.
219
     * @param string $username This parameter is no longer available.
220
     *                         See the "deprecation notice" for details.
221
     *                         @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
222
     */
223
    public function removeUserFromGroup(
×
224
        string $accountId,
225
        ?string $groupname = null,
226
        ?string $groupId = null,
227
        ?string $username = null,
228
    ): true {
229
        return $this->call(
×
230
            uri: '/rest/api/3/group/user',
×
231
            method: 'delete',
×
232
            query: compact('accountId', 'groupname', 'groupId', 'username'),
×
233
            success: 200,
×
234
            schema: true,
×
235
        );
×
236
    }
237

238
    /**
239
     * Returns a list of groups whose names contain a query string.
240
     * A list of group names can be provided to exclude groups from the results
241
     * 
242
     * The primary use case for this resource is to populate a group picker suggestions list.
243
     * To this end, the returned object includes the `html` field where the matched query term is highlighted in the group name with the HTML strong tag.
244
     * Also, the groups list is wrapped in a response object that contains a header for use in the picker, specifically *Showing X of Y matching groups*
245
     * 
246
     * The list returns with the groups sorted.
247
     * If no groups match the list criteria, an empty list is returned
248
     * 
249
     * This operation can be accessed anonymously
250
     * 
251
     * **"Permissions" required:** *Browse projects* "project permission".
252
     * Anonymous calls and calls by users without the required permission return an empty list
253
     * 
254
     * *Browse users and groups* "global permission".
255
     * Without this permission, calls where query is not an exact match to an existing group will return an empty list.
256
     * 
257
     * @link https://confluence.atlassian.com/x/yodKLg
258
     * @link https://confluence.atlassian.com/x/x4dKLg
259
     * 
260
     * @param string $accountId This parameter is deprecated, setting it does not affect the results.
261
     *                          To find groups containing a particular user, use "Get user groups".
262
     * @param string $query The string to find in group names.
263
     * @param ?list<string> $exclude As a group's name can change, use of `excludeGroupIds` is recommended to identify a group.
264
     *                                
265
     *                               A group to exclude from the result.
266
     *                               To exclude multiple groups, provide an ampersand-separated list.
267
     *                               For example, `exclude=group1&exclude=group2`.
268
     *                               This parameter cannot be used with the `excludeGroupIds` parameter.
269
     * @param ?list<string> $excludeId A group ID to exclude from the result.
270
     *                                 To exclude multiple groups, provide an ampersand-separated list.
271
     *                                 For example, `excludeId=group1-id&excludeId=group2-id`.
272
     *                                 This parameter cannot be used with the `excludeGroups` parameter.
273
     * @param int $maxResults The maximum number of groups to return.
274
     *                        The maximum number of groups that can be returned is limited by the system property `jira.ajax.autocomplete.limit`.
275
     * @param bool $caseInsensitive Whether the search for groups should be case insensitive.
276
     * @param string $userName This parameter is no longer available.
277
     *                         See the "deprecation notice" for details.
278
     *                         @link https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide
279
     */
280
    public function findGroups(
1✔
281
        ?string $accountId = null,
282
        ?string $query = null,
283
        ?array $exclude = null,
284
        ?array $excludeId = null,
285
        ?int $maxResults = null,
286
        ?bool $caseInsensitive = false,
287
        ?string $userName = null,
288
    ): Schema\FoundGroups {
289
        return $this->call(
1✔
290
            uri: '/rest/api/3/groups/picker',
1✔
291
            method: 'get',
1✔
292
            query: compact('accountId', 'query', 'exclude', 'excludeId', 'maxResults', 'caseInsensitive', 'userName'),
1✔
293
            success: 200,
1✔
294
            schema: Schema\FoundGroups::class,
1✔
295
        );
1✔
296
    }
297
}
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