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

filter: Statementstmt 0.0% 0 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 26 CC 1 SCAR 6.9
CC
1
Cov
0%
create
2.0
update
2.0
delete
2.0
CRAP 2.0
1 #!/bin/false
2 # PODNAME: BZ::Client::Component
3 # ABSTRACT: Client side representation of Product Components in Bugzilla
4  
5 use strict;
6 use warnings 'all';
7  
8 package BZ::Client::Component;
9 $BZ::Client::Component::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/Component.html
14 # These are in order as per the above
15  
16 ## functions
17  
18 sub create {
19 my($class, $client, $params) = @_;
20 return $class->_create($client, 'Component.create', $params);
21 }
22  
23 sub update {
24 my($class, $client, $params) = @_;
25 return $class->_returns_array($client, 'Component.update', $params, 'components');
26 }
27  
28 sub delete {
29 my($class, $client, $params) = @_;
30 return $class->_returns_array($client, 'Component.delete', $params, 'components');
31 }
32  
33 1;
34  
35 __END__
36  
37 =pod
38  
39 =encoding UTF-8
40  
41 =head1 NAME
42  
43 BZ::Client::Component - Client side representation of Product Components in Bugzilla
44  
45 =head1 VERSION
46  
47 version 4.9
48  
49 =head1 SYNOPSIS
50  
51 This class provides methods for accessing Product Component information in
52 the Bugzilla server.
53  
54 my $client = BZ::Client->new( url => $url,
55 user => $user,
56 password => $password );
57  
58 my $id = BZ::Client::Component->create( $client, \%params );
59 my $changes = BZ::Client::Component->update( $client, \%params );
60 my $ids = BZ::Client::Component->delete( $client, \%params );
61  
62 =head1 CLASS METHODS
63  
64 This section lists the class methods, which are available in this module.
65  
66 =head2 create
67  
68 $id = BZ::Client::Component->create( $client, \%params );
69  
70 Returns the ID of the newly created Component.
71  
72 =head3 History
73  
74 Added in Bugzilla 5.0.
75  
76 Marked experiemental as of Bugzilla 5.0.
77  
78 =head3 Parameters
79  
80 Some params must be set, or an error will be thrown. These params are marked "Required".
81  
82 =over 4
83  
84 =item name
85  
86 I<name> (string) The name of the new component.
87  
88 B<Required>.
89  
90 =item product
91  
92 I<product> (string) The name of the product that the component must be added to. This
93 product must already exist, and the user have the necessary permissions to edit components
94 for it.
95  
96 B<Required>.
97  
98 =item description
99  
100 I<description> (string) The description of the new component.
101  
102 B<Required>.
103  
104 =item default_assignee
105  
106 I<default_assignee> (string) The login name of the default assignee of the component.
107  
108 B<Required>.
109  
110 =item default_cc
111  
112 I<default_cc> (array) An array of strings with each element representing one login name of
113 the default CC list.
114  
115 =item default_qa_contact
116  
117 I<default_qa_contact> (string) The login name of the default QA contact for the component.
118  
119 =item is_open
120  
121 I<is_open> (boolean) C<1> if you want to enable the component for bug creations.
122 C<0> otherwise. Default is C<1>.
123  
124 =back
125  
126 =head3 Returns
127  
128 The ID of the newly-added component.
129  
130 =head3 Errors
131  
132 =over 4
133  
134 =item 304 - Authorization Failure
135  
136 You are not authorized to create a new component.
137  
138 =item 1200 - Component already exists
139  
140 The name that you specified for the new component already exists in the specified product.
141  
142 =back
143  
144 =head2 update
145  
146 $changes = BZ::Client::Component->update( $client, \%params );
147 @changes = BZ::Client::Component->update( $client, \%params );
148  
149 This allows you to update one or more components in Bugzilla.
150  
151 =head3 History
152  
153 Added in Bugzilla 5.0.
154  
155 =head3 Parameters
156  
157 You must set one or both of L</ids> or L</names> to select the Component to update.
158  
159 Other parameters set or update values of the Component
160  
161 =over 4
162  
163 =item ids
164  
165 I<ids> (array) Numeric ID's of the components that you wish to update.
166  
167 =item names
168  
169 I<names> (array of hashes) Names of the components that you wish to update. The hash keys
170 are C<product> and C<component>, representing the name of the product and the component
171 you wish to change.
172  
173 =item name
174  
175 I<name> (string) A new name for this component. If you try to set this while updating
176 more than one component for a product, an error will occur, as component names must be
177 unique per product.
178  
179 =item description
180  
181 I<description> (string) The description of the new component.
182  
183 Required.
184  
185 =item default_assignee
186  
187 I<default_assignee> (string) The login name of the default assignee of the component.
188  
189 Required.
190  
191 =item default_cc
192  
193 I<default_cc> (array) An array of strings with each element representing one login name of
194 the default CC list.
195  
196 =item default_qa_contact
197  
198 I<default_qa_contact> (string) The login name of the default QA contact for the component.
199  
200 =item is_open
201  
202 I<is_open> (boolean) C<1> if you want to enable the component for bug creations.
203 C<0> otherwise.
204  
205 =back
206  
207 =head3 Returns
208  
209 An array of hashes with the following fields:
210  
211 =over 4
212  
213 =item id
214  
215 I<id> (int) The ID of the component that was updated.
216  
217 =item changes
218  
219 The changes that were actually done on this component. The keys are the names of the fields
220 that were changed, and the values are a hash with two keys:
221  
222 =over 4
223  
224 =item added
225  
226 I<added> (string) The value that this field was changed to.
227  
228 =item removed
229  
230 I<removed> (string) The value that was previously set in this field.
231  
232 Note that booleans will be represented with the strings C<1> and C<0>.
233  
234 =back
235  
236 =back
237  
238 Here's an example of what a return value might look like:
239  
240 [
241 {
242 id => 123,
243 changes => {
244 name => {
245 removed => 'FooName',
246 added => 'BarName'
247 },
248 default_assignee => {
249 removed => 'foo@company.com',
250 added => 'bar@company.com',
251 }
252 }
253 }
254 ]
255  
256 =head3 Errors
257  
258 =over 4
259  
260 =item 51 - User does not exist
261  
262 One of the contact e-mail addresses is not a valid Bugzilla user.
263  
264 =item 106 - Product access denied
265  
266 The product you are trying to modify does not exist or you don't have access to it.
267  
268 =item 706 - Product admin denied
269  
270 You do not have the permission to change components for this product.
271  
272 =item 105 - Component name too long
273  
274 The name specified for this component was longer than the maximum allowed length.
275  
276 =item 1200 - Component name already exists
277  
278 You specified the name of a component that already exists. (Component names must be unique per
279 product in Bugzilla.)
280  
281 =item 1210 - Component blank name
282  
283 You must specify a non-blank name for this component.
284  
285 =item 1211 - Component must have description
286  
287 You must specify a description for this component.
288  
289 =item 1212 - Component name is not unique
290  
291 You have attempted to set more than one component in the same product with the same name.
292 Component names must be unique in each product.
293  
294 =item 1213 - Component needs a default assignee
295  
296 A default assignee is required for this component.
297  
298 =back
299  
300 =head2 delete
301  
302 $ids = BZ::Client::Component->delete( $client, \%params );
303 @ids = BZ::Client::Component->delete( $client, \%params );
304  
305 This allows you to delete one or more components in Bugzilla.
306  
307 =head3 History
308  
309 Added in Bugzilla 5.0.
310  
311 =head3 Parameters
312  
313 You must set one or both of these parameters.
314  
315 =over 4
316  
317 =item ids
318  
319 I<ids> (array) Numeric ID's of the components that you wish to delete.
320  
321 =item names
322  
323 I<names> (array of hashes). Names of the components that you wish to delete. The hash keys are
324 C<product> and C<component>, representing the name of the product and the component you wish to
325 delete.
326  
327 =back
328  
329 =head3 Returns
330  
331 An array of ID's that were deleted
332  
333 =head3 Errors
334  
335 =over 4
336  
337 =item 106 - Product access denied
338  
339 The product you are trying to modify does not exist or you don't have access to it.
340  
341 =item 706 - Product admin denied
342  
343 You do not have the permission to delete components for this product.
344  
345 =item 1202 - Component has bugs
346  
347 The component you are trying to delete currently has bugs assigned to it. You must move these
348 bugs before trying to delete the component.
349  
350 =back
351  
352 =head1 EXCEPTION HANDLING
353  
354 See L<BZ::Client::Exception>
355  
356 =head1 SEE ALSO
357  
358 L<BZ::Client>, L<BZ::Client::API>, L<Bugzilla API|https://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Component.html>
359  
360 =head1 AUTHORS
361  
362 =over 4
363  
364 =item *
365  
366 Dean Hamstead <dean@bytefoundry.com.au>
367  
368 =item *
369  
370 Jochen Wiedmann <jochen.wiedmann@gmail.com>
371  
372 =back
373  
374 =head1 COPYRIGHT AND LICENSE
375  
376 This software is copyright (c) 2026 by Dean Hamstad.
377  
378 This is free software; you can redistribute it and/or modify it under
379 the same terms as the Perl 5 programming language system itself.
380  
381 =cut