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

filter: Statementstmt 0.0% 0 / 18 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 / 29 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::FlagType
3 # ABSTRACT: The API for creating, changing, and getting info on Flags
4  
5 use strict;
6 use warnings 'all';
7  
8 package BZ::Client::FlagType;
9 $BZ::Client::FlagType::VERSION = '4.4001';
10  
11 use parent qw( BZ::Client::API );
12  
13 # See https://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/FlagType.html
14  
15 ## functions
16  
17 sub get {
18 my($class, $client, $params) = @_;
19 my $result = $class->api_call($client, 'FlagType.get', $params);
20 return wantarray ? %$result : $result
21 }
22  
23 sub create {
24 my($class, $client, $params) = @_;
25 return $class->_create($client, 'FlagType.create', $params, 'flag_id');
26 }
27  
28 sub update {
29 my($class, $client, $params) = @_;
30 return $class->_returns_array($client, 'FlagType.update', $params, 'flagtypes');
31 }
32  
33 1;
34  
35 __END__
36  
37 =pod
38  
39 =encoding UTF-8
40  
41 =head1 NAME
42  
43 BZ::Client::FlagType - The API for creating, changing, and getting info on Flags
44  
45 =head1 VERSION
46  
47 version 4.4001
48  
49 =head1 SYNOPSIS
50  
51 This class provides methods for accessing and managing Flags in Bugzilla.
52  
53 my $client = BZ::Client->new( url => $url,
54 user => $user,
55 password => $password );
56  
57 my %results = BZ::Client::FlagType->get( $client, \%params );
58 my $id = BZ::Client::FlagType->create( $client, \%params );
59 my @updates = BZ::Client::FlagType->update( $client, \%params );
60  
61 =head1 CLASS METHODS
62  
63 This section lists the class methods, which are available in this module.
64  
65 =head2 get
66  
67 $id = BZ::Client::FlagType->get( $client, \%params );
68  
69 Get information about valid flag types that can be set for bugs and attachments.
70  
71 =head3 History
72  
73 Added in Bugzilla 5.0.
74  
75 =head3 Parameters
76  
77 You must pass a product L</name> and an optional L</component> name.
78  
79 =over 4
80  
81 =item product
82  
83 I<product> (string) The name of a valid product.
84  
85 =item component
86  
87 I<component> (string) An optional valid component name associated with the product.
88  
89 =back
90  
91 =head3 Returns
92  
93 A hash containing two keys, bug and attachment. Each key value is an array of hashes, containing the following keys:
94  
95 =over 4
96  
97 =item id
98  
99 I<id> (int) An integer ID uniquely identifying this flag type.
100  
101 =item name
102  
103 I<name> (string) The name for the flag type.
104  
105 =item type
106  
107 I<type> (string) The target of the flag type which is either bug or attachment.
108  
109 =item description
110  
111 I<description> (string) The description of the flag type.
112  
113 =item values
114  
115 I<values> (array) An array of string values that the user can set on the flag type.
116  
117 =item is_requesteeble
118  
119 I<is_requesteeble> (boolean) Users can ask specific other users to set flags of this type.
120  
121 =item is_multiplicable
122  
123 I<is_multiplicable> (boolean) Multiple flags of this type can be set for the same bug or attachment.
124  
125 =back
126  
127 =head3 Errors
128  
129 =over 4
130  
131 =item 106 - Product Access Denied
132  
133 Either the product does not exist or you don't have access to it.
134  
135 =item 51 - Invalid Component
136  
137 The component provided does not exist in the product.
138  
139 =back
140  
141 =head2 create
142  
143 $id = BZ::Client::FlagType->create( $client, \%params );
144  
145 This allows you to create a new Flag Type in Bugzilla.
146  
147 Marked as unstable as of Bugzilla 5.0.
148  
149 Added in Bugzilla 5.0.
150  
151 =head3 Parameters
152  
153 Some params must be set, or an error will be thrown. These params are noted as Required.
154  
155 =over 4
156  
157 =item name
158  
159 I<name> (string) A short name identifying this type.
160  
161 Required.
162  
163 =item description
164  
165 I<description> (string) A comprehensive description of this type.
166  
167 Required.
168  
169 =item inclusions
170  
171 I<inclusions> (array) An array of strings or a hash containing product names,
172 and optionally component names. If you provide a string, the flag type will be shown on all
173 bugs in that product. If you provide a hash, the key represents the product name, and the
174 value is the components of the product to be included.
175  
176 For example:
177  
178 [ 'FooProduct',
179 {
180 BarProduct => [ 'C1', 'C3' ],
181 BazProduct => [ 'C7' ]
182 }
183 ]
184  
185 This flag will be added to All components of FooProduct, components C1 and C3 of BarProduct,
186 and C7 of BazProduct.
187  
188 =item exclusions
189  
190 I<exclusions> (array) An array of strings or hashes containing product names. This uses the same format
191 as inclusions.
192  
193 This will exclude the flag from all products and components specified.
194  
195 =item sortkey
196  
197 I<sortkey> (int) A number between 1 and 32767 by which this type will be sorted when displayed
198 to users in a list; ignore if you don't care what order the types appear in or if you want them
199 to appear in alphabetical order.
200  
201 =item is_active
202  
203 I<is_active> (boolean) Flag of this type appear in the UI and can be set.
204  
205 Default is true.
206  
207 =item is_requestable
208  
209 I<is_requestable> (boolean) Users can ask for flags of this type to be set.
210  
211 Default is true.
212  
213 =item cc_list
214  
215 I<cc_list> (array) An array of strings. If the flag type is requestable, who should receive e-mail
216 notification of requests. This is an array of e-mail addresses which do not need to be Bugzilla logins.
217  
218 =item is_specifically_requestable
219  
220 I<is_specifically_requestable> (boolean) Users can ask specific other users to set flags of this
221 type as opposed to just asking the wind.
222  
223 Default is true.
224  
225 =item is_multiplicable
226  
227 I<is_multiplicable> (boolean) Multiple flags of this type can be set on the same bug.
228  
229 Default is true.
230  
231 =item grant_group
232  
233 I<grant_group> (string) The group allowed to grant/deny flags of this type (to allow all users to
234 grant/deny these flags, select no group).
235  
236 Default is no group.
237  
238 =item request_group
239  
240 I<request_group> (string) If flags of this type are requestable, the group allowed to request them
241 (to allow all users to request these flags, select no group). Note that the request group alone has
242 no effect if the grant group is not defined!
243  
244 Default is no group.
245  
246 =back
247  
248 =head3 Returns
249  
250 The ID of the newly-created group.
251  
252 =head3 Errors
253  
254 =over 4
255  
256 =item 51 - Group Does Not Exist
257  
258 The group name you entered does not exist, or you do not have access to it.
259  
260 =item 105 - Unknown component
261  
262 The component does not exist for this product.
263  
264 =item 106 - Product Access Denied
265  
266 Either the product does not exist or you don't have editcomponents privileges to it.
267  
268 =item 501 - Illegal Email Address
269  
270 One of the e-mail address in the CC list is invalid. An e-mail in the CC list does NOT need to be a
271 valid Bugzilla user.
272  
273 =item 1101 - Flag Type Name invalid
274  
275 You must specify a non-blank name for this flag type. It must no contain spaces or commas, and must
276 be 50 characters or less.
277  
278 =item 1102 - Flag type must have description
279  
280 You must specify a description for this flag type.
281  
282 =item 1103 - Flag type CC list is invalid
283  
284 The CC list must be 200 characters or less.
285  
286 =item 1104 - Flag Type Sort Key Not Valid
287  
288 The sort key is not a valid number.
289  
290 =item 1105 - Flag Type Not Editable
291  
292 This flag type is not available for the products you can administer. Therefore you can not edit
293 attributes of the flag type, other than the inclusion and exclusion list.
294  
295 =back
296  
297 =head2 update
298  
299 @results = BZ::Client::FlagType->update( $client, \%params );
300 $results = BZ::Client::FlagType->update( $client, \%params );
301  
302 This allows you to update a flag type in Bugzilla.
303  
304 =head3 History
305  
306 Added in Bugzilla 5.0.
307  
308 =head3 Parameters
309  
310 Note: The following parameters specify which products you are updating. You must set one or both of these parameters.
311  
312 =over 4
313  
314 =item ids
315  
316 I<ids> (array of ints) Numeric ids of the flag types that you wish to update.
317  
318 =item names
319  
320 I<names> (array of strings) Names of the flag types that you wish to update. If many flag types have the same name, this will change ALL of them.
321  
322 =back
323  
324 Note: The following parameters specify the new values you want to set for the products you are updating.
325  
326 =over 4
327  
328 =item name
329  
330 I<name> (string) A short name identifying this type.
331  
332 =item description
333  
334 I<description> (string) A comprehensive description of this type.
335  
336 =item inclusions
337  
338 An array of strings or a hash containing product names, and optionally component names.
339  
340 If you provide a string, the flag type will be shown on all bugs in that product.
341  
342 If you provide a hash, the key represents the product name, and the value is the components of the product to be included.
343  
344 For example:
345  
346 [ 'FooProduct',
347 {
348 BarProduct => [ 'C1', 'C3' ],
349 BazProduct => [ 'C7' ]
350 }
351 ]
352  
353 This flag will be added to B<all> components of C<FooProduct>, components C<C1> and C<C3> of C<BarProduct>, and C<C7> of C<BazProduct>.
354  
355 =item exclusions
356  
357 An array of strings or hashes containing product names.
358  
359 This uses the same fromat as L</inclusions>.
360  
361 This will exclude the flag from all products and components specified.
362  
363 =item sortkey
364  
365 I<sortkey> (int) A number between 1 and 32767 by which this type will be sorted when displayed to users in a list; ignore if you don't care what order the types appear in or if you want them to appear in alphabetical order.
366  
367 =item is_active
368  
369 I<is_active> (boolean) Flag of this type appear in the UI and can be set.
370  
371 =item is_requestable
372  
373 I<is_requestable> (boolean) Users can ask for flags of this type to be set.
374  
375 =item cc_list
376  
377 I<cc_list> (array) An array of strings. If the flag type is requestable, who should receive e-mail notification of requests. This is an array of e-mail addresses which do not need to be Bugzilla logins.
378  
379 =item is_specifically_requestable
380  
381 I<is_specifically_requestable> (boolean) Users can ask specific other users to set flags of this type as opposed to just asking the wind.
382  
383 =item is_multiplicable
384  
385 I<is_multiplicable> (boolean) Multiple flags of this type can be set on the same bug.
386  
387 =item grant_group
388  
389 I<grant_group> (string) The group allowed to grant/deny flags of this type (to allow all users to grant/deny these flags, select no group).
390  
391 =item request_group
392  
393 I<request_group> (string) If flags of this type are requestable, the group allowed to request them (to allow all users to request these flags, select no group).
394  
395 Note that the request group alone has no effect if the grant group is not defined!
396  
397 =back
398  
399 =head2 Returns
400  
401 An array of hashes with the following fields:
402  
403 =over 4
404  
405 =item id
406  
407 I<id> (int) The ID of the product that was updated.
408  
409 =item name
410  
411 I<name> (string) The name of the product that was updated.
412  
413 =item changes
414  
415 I<changes> (hash) The changes that were actually done on this product.
416  
417 The keys are the names of the fields that were changed, and the values are a hash with two keys:
418  
419 =over 4
420  
421 =item added
422  
423 I<added> (string) The value that this field was changed to.
424  
425 =item removed
426  
427 I<removed> (string) The value that was previously set in this field.
428  
429 =back
430  
431 Note that booleans will be represented with the strings C<1> and C<0>.
432  
433 Here's an example of what a return value might look like:
434  
435 [
436 {
437 id => 123,
438 changes => {
439 name => {
440 removed => 'FooFlagType',
441 added => 'BarFlagType'
442 },
443 is_requestable => {
444 removed => '1',
445 added => '0',
446 }
447 }
448 }
449 ]
450  
451 =back
452  
453 =head3 Errors
454  
455 =over 4
456  
457 =item 51 - Group Does Not Exist
458  
459 The group name you entered does not exist, or you do not have access to it.
460  
461 =item 105 - Unknown component
462  
463 The component does not exist for this product.
464  
465 =item 106 - Product Access Denied
466  
467 Either the product does not exist or you don't have editcomponents privileges to it.
468  
469 =item 501 - Illegal Email Address
470  
471 One of the e-mail address in the CC list is invalid. An e-mail in the CC list does NOT need to be a valid Bugzilla user.
472  
473 =item 1101 - Flag Type Name invalid
474  
475 You must specify a non-blank name for this flag type. It must no contain spaces or commas, and must be 50 characters or less.
476  
477 =item 1102 - Flag type must have description
478  
479 You must specify a description for this flag type.
480  
481 =item 1103 - Flag type CC list is invalid
482  
483 The CC list must be 200 characters or less.
484  
485 =item 1104 - Flag Type Sort Key Not Valid
486  
487 The sort key is not a valid number.
488  
489 =item 1105 - Flag Type Not Editable
490  
491 This flag type is not available for the products you can administer. Therefore you can not edit attributes of the flag type, other than the inclusion and exclusion list.
492  
493 =back
494  
495 =head1 INSTANCE METHODS
496  
497 FIXME Not yet implemented
498  
499 =head1 EXCEPTION HANDLING
500  
501 See L<BZ::Client::Exception>
502  
503 =head1 SEE ALSO
504  
505 L<BZ::Client>, L<BZ::Client::API>, L<Bugzilla API|https://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/FlagType.html>
506  
507 =head1 AUTHORS
508  
509 =over 4
510  
511 =item *
512  
513 Dean Hamstead <dean@bytefoundry.com.au>
514  
515 =item *
516  
517 Jochen Wiedmann <jochen.wiedmann@gmail.com>
518  
519 =back
520  
521 =head1 COPYRIGHT AND LICENSE
522  
523 This software is copyright (c) 2017 by Dean Hamstad.
524  
525 This is free software; you can redistribute it and/or modify it under
526 the same terms as the Perl 5 programming language system itself.
527  
528 =cut