blib/lib/BZ/Client/Group.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 30 CC 2 SCAR 11.5
CC
2
Cov
0%
get
6.0
create
2.0
update
2.0
CRAP 3.1
1 #!/bin/false
2 # PODNAME: BZ::Client::Group
3 # ABSTRACT: The API for creating, changing, and getting info on Groups
4  
5 use strict;
6 use warnings 'all';
7  
8 package BZ::Client::Group;
9 $BZ::Client::Group::VERSION = '4.9';
10  
11 use parent qw( BZ::Client::API );
12  
13 # See https://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Group.html
14  
15 ## functions
16  
17 sub create {
18 my($class, $client, $params) = @_;
19 return $class->_create($client, 'Group.create', $params);
20 }
21  
22 sub update {
23 my($class, $client, $params) = @_;
24 return $class->_returns_array($client, 'Group.update', $params, 'groups');
25 }
26  
27 sub get {
28 my($class, $client, $params) = @_;
29 my $result = $class->api_call($client, 'Group.get', $params);
30 return wantarray ? %{$result} : $result
31 }
32  
33 1;
34  
35 __END__
36  
37 =pod
38  
39 =encoding UTF-8
40  
41 =head1 NAME
42  
43 BZ::Client::Group - The API for creating, changing, and getting info on Groups
44  
45 =head1 VERSION
46  
47 version 4.9
48  
49 =head1 SYNOPSIS
50  
51 This class provides methods for accessing and managing Groups in Bugzilla.
52  
53 my $client = BZ::Client->new( url => $url,
54 user => $user,
55 password => $password );
56  
57 my $id = BZ::Client::Group->create( $client, \%params );
58  
59 =head1 CLASS METHODS
60  
61 This section lists the class methods, which are available in this module.
62  
63 =head2 create
64  
65 $id = BZ::Client::Group->create( $client, \%params );
66  
67 This allows you to create a new Group in Bugzilla.
68  
69 =head3 History
70  
71 Marked as unstable as of Bugzilla 5.0.
72  
73 =head3 Parameters
74  
75 Some params must be set, or an error will be thrown. These params are noted as Required.
76  
77 =over 4
78  
79 =item name
80  
81 I<name> (string) A short name for this group. Must be unique.
82  
83 This is infrequently displayed in the web user interface.
84  
85 B<Required>.
86  
87 =item description
88  
89 I<description> (string) A human-readable name for this group. Should be relatively short.
90  
91 This is what will normally appear in the UI as the name of the group.
92  
93 B<Required>.
94  
95 =item user_regexp
96  
97 I<user_regexp> (string) A regular expression. Any user whose Bugzilla username matches this regular expression will automatically be granted membership in this group.
98  
99 =item is_active
100  
101 I<is_active> (boolean) True if new group can be used for bugs,
102  
103 False if this is a group that will only contain users and no bugs will be restricted to it.
104  
105 =item icon_url
106  
107 I<icon_url> (boolean) A URL pointing to a small icon used to identify the group. This icon will show up next to users' names in various parts of Bugzilla if they are in this group.
108  
109 =back
110  
111 =head3 Returns
112  
113 The ID of the newly-created group.
114  
115 =head3 Errors
116  
117 =over 4
118  
119 =item 800 - Empty Group Name
120  
121 You must specify a value for the L</name> field.
122  
123 =item 801 - Group Exists
124  
125 There is already another group with the same L</name>.
126  
127 =item 802 - Group Missing Description
128  
129 You must specify a value for the L</description> field.
130  
131 =item 803 - Group Regexp Invalid
132  
133 You specified an invalid regular expression in the L</user_regexp> field.
134  
135 =back
136  
137 =head2 update
138  
139 $id = BZ::Client::Group->update( $client, \%params );
140  
141 This allows you to update a Group in Bugzilla.
142  
143 =head3 History
144  
145 As of Bugzilla 5.0. this is marked as unstable.
146  
147 =head3 Parameters
148  
149 Either L</ids> or L</names> is required to select the bugs you want to update.
150  
151 All other values change or set something in the product.
152  
153 =over 4
154  
155 =item ids
156  
157 I<ids> (array) Numeric ID's of the groups you wish to update.
158  
159 =item names
160  
161 I<names> (array) Text names of the groups that you wish to update.
162  
163 =item name
164  
165 I<name> (string) A new name for group.
166  
167 =item description
168  
169 I<description> (string) A new description for groups. This is what will appear in the UI as the name of the groups.
170  
171 =item user_regexp
172  
173 I<user_regexp> (string) A new regular expression for email. Will automatically grant membership to these groups to anyone with an email address that matches this perl regular expression.
174  
175 =item is_active
176  
177 I<is_active> (boolean) Set if groups are active and eligible to be used for bugs. True if bugs can be restricted to this group, false otherwise.
178  
179 =item icon_url
180  
181 I<icon_url> (string) A URL pointing to an icon that will appear next to the name of users who are in this group.
182  
183 =back
184  
185 =head3 Returns
186  
187 An array or arrayref of hashes containing the following:
188  
189 =over 4
190  
191 =item id
192  
193 I<id> (int) The ID of the Group that was updated.
194  
195 =item changes
196  
197 The changes that were actually done on this Group. The keys are the names of the
198 fields that were changed, and the values are a hash with two keys:
199  
200 =over 4
201  
202 =item added
203  
204 I<added> (string) The values that were added to this field, possibly a comma-and-space-separated list if multiple values were added.
205  
206 =item removed
207  
208 I<removed> (string) The values that were removed from this field, possibly a comma-and-space-separated list if multiple values were removed.
209  
210 =back
211  
212 Note that booleans will be represented with the strings C<1> and <0>.
213  
214 =back
215  
216 =head3 Errors
217  
218 =over 4
219  
220 =item 800 - Empty Group Name
221  
222 You must specify a value for the L</name> field.
223  
224 =item 801 - Group Exists
225  
226 There is already another group with the same L</name>.
227  
228 =item 802 - Group Missing Description
229  
230 You must specify a value for the L</description> field.
231  
232 =item 803 - Group Regexp Invalid
233  
234 You specified an invalid regular expression in the L</user_regexp> field.
235  
236 =back
237  
238 =head2 get
239  
240 Returns information about C<Bugzilla::Group>.
241  
242 =head3 History
243  
244 This function was added in Bugzilla 5.0.
245  
246 =head3 Parameters
247  
248 If neither L</ids> or L</names> is passed, and you are in the creategroups or editusers group, then all groups will be retrieved.
249  
250 Otherwise, only groups that you have bless privileges for will be returned.
251  
252 =over 4
253  
254 =item ids
255  
256 I<ids> (array) Contain IDs of groups to update.
257  
258 =item names
259  
260 I<names> (array) Contain names of groups to update.
261  
262 =item membership
263  
264 I<membership> (boolean) Set to C<1> then a list of members of the passed groups' names and IDs will be returned.
265  
266 =back
267  
268 =head3 Returns
269  
270 If the user is a member of the C<creategroups>" group they will receive information about all groups or groups matching the criteria that they passed. You have to be in the creategroups group unless you're requesting membership information.
271  
272 If the user is not a member of the Ccreategroups> group, but they are in the C<editusers> group or have bless privileges to the groups they require membership information for, the is_active, is_bug_group and user_regexp values are not supplied.
273  
274 The return value will be a hash containing group names as the keys, each group name will point to a hash that describes the group and has the following items:
275  
276 =over 4
277  
278 =item id
279  
280 I<id> (int) The unique integer ID that Bugzilla uses to identify this group. Even if the name of the group changes, this ID will stay the same.
281  
282 =item name
283  
284 I<name> (string) The name of the group.
285  
286 =item description
287  
288 I<description> (string) The description of the group.
289  
290 =item is_bug_group
291  
292 I<is_bug_group> (int) Whether this groups is to be used for bug reports or is only administrative specific.
293  
294 =item user_regexp
295  
296 I<user_regexp> (string) A regular expression that allows users to be added to this group if their login matches.
297  
298 =item is_active
299  
300 I<is_active> (int) Whether this group is currently active or not.
301  
302 =item users
303  
304 I<users> (array) An array of hashes, each hash contains a user object for one of the members of this group, only returned if the user sets the C<membership> parameter to C<1>, the user hash has the following items:
305  
306 =over 4
307  
308 =item id
309  
310 I<id> (int) The ID of the user.
311  
312 =item real_name
313  
314 I<real_name> (string) The actual name of the user.
315  
316 =item email
317  
318 I<emaiL> (string) The email address of the user.
319  
320 =item name
321  
322 I<name> (string) The login name of the user. Note that in some situations this is different than their email.
323  
324 =item can_login
325  
326 I<can_login> (boolean) A boolean value to indicate if the user can login into bugzilla.
327  
328 =item email_enabled
329  
330 I<email_enabled> (boolean) A boolean value to indicate if bug-related mail will be sent to the user or not.
331  
332 =item disabled_text
333  
334 I<disabled_text> (string) A text field that holds the reason for disabling a user from logging into bugzilla, if empty then the user account is enabled otherwise it is disabled/closed.
335  
336 =back
337  
338 =back
339  
340 =head3 Errors
341  
342 =over 4
343  
344 =item 51 - Invalid Object
345  
346 A non existing group name was passed to the function, as a result no group object existed for that invalid name.
347  
348 =item 805 - Cannot view groups
349  
350 Logged-in users are not authorized to edit bugzilla groups as they are not members of the creategroups group in bugzilla, or they are not authorized to access group member's information as they are not members of the "editusers" group or can bless the group.
351  
352 =back
353  
354 =head1 INSTANCE METHODS
355  
356 FIXME Not yet implemented
357  
358 =head1 EXCEPTION HANDLING
359  
360 See L<BZ::Client::Exception>
361  
362 =head1 SEE ALSO
363  
364 L<BZ::Client>, L<BZ::Client::API>, L<Bugzilla API|https://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Group.html>
365  
366 =head1 AUTHORS
367  
368 =over 4
369  
370 =item *
371  
372 Dean Hamstead <dean@bytefoundry.com.au>
373  
374 =item *
375  
376 Jochen Wiedmann <jochen.wiedmann@gmail.com>
377  
378 =back
379  
380 =head1 COPYRIGHT AND LICENSE
381  
382 This software is copyright (c) 2026 by Dean Hamstad.
383  
384 This is free software; you can redistribute it and/or modify it under
385 the same terms as the Perl 5 programming language system itself.
386  
387 =cut