Fastly/DirectorApi.pm untested

filter: Statementstmt 0.0% 0 / 238 Branchbran 0.0% 0 / 90 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 358 CC 46 SCAR 46.8
CC
46
Cov
0%
create_director
240.0
delete_director
90.0
get_director
90.0
CRAP 107.5
1 =begin comment
2  
3 Fastly API
4  
5 Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/)
6  
7 The version of the API Spec document: 1.0.0
8 Contact: oss@fastly.com
9  
10 =end comment
11  
12 =cut
13  
14 #
15 # NOTE: This class is auto generated.
16 # Do not edit the class manually.
17 #
18 package WebService::Fastly::DirectorApi;
19  
20 require 5.6.0;
21 use strict;
22 use warnings;
23 use utf8;
24 use Exporter;
25 use Carp qw( croak );
26 use Log::Any qw($log);
27  
28 use WebService::Fastly::ApiClient;
29  
30 use base "Class::Data::Inheritable";
31  
32 __PACKAGE__->mk_classdata('method_documentation' => {});
33  
34 sub new {
35 my $class = shift;
36 my $api_client;
37  
38 if ($_[0] && ref $_[0] && ref $_[0] eq 'WebService::Fastly::ApiClient' ) {
39 $api_client = $_[0];
40 } else {
41 $api_client = WebService::Fastly::ApiClient->new(@_);
42 }
43  
44 bless { api_client => $api_client }, $class;
45  
46 }
47  
48  
49 #
50 # create_director
51 #
52 # Create a director
53 #
54 # @param string $service_id Alphanumeric string identifying the service. (required)
55 # @param int $version_id Integer identifying a service version. (required)
56 # @param ARRAY[Backend] $backends List of backends associated to a director. (optional)
57 # @param int $capacity Unused. (optional)
58 # @param string $comment A freeform descriptive note. (optional)
59 # @param string $name Name for the Director. (optional)
60 # @param int $quorum The percentage of capacity that needs to be up for a director to be considered up. `0` to `100`. (optional, default to 75)
61 # @param string $shield Selected POP to serve as a shield for the backends. Defaults to `null` meaning no origin shielding if not set. Refer to the [POPs API endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/) to get a list of available POPs used for shielding. (optional, default to 'null')
62 # @param int $type What type of load balance group to use. (optional, default to 1)
63 # @param int $retries How many backends to search if it fails. (optional, default to 5)
64 {
65 my $params = {
66 'service_id' => {
67 data_type => 'string',
68 description => 'Alphanumeric string identifying the service.',
69 required => '1',
70 },
71 'version_id' => {
72 data_type => 'int',
73 description => 'Integer identifying a service version.',
74 required => '1',
75 },
76 'backends' => {
77 data_type => 'ARRAY[Backend]',
78 description => 'List of backends associated to a director.',
79 required => '0',
80 },
81 'capacity' => {
82 data_type => 'int',
83 description => 'Unused.',
84 required => '0',
85 },
86 'comment' => {
87 data_type => 'string',
88 description => 'A freeform descriptive note.',
89 required => '0',
90 },
91 'name' => {
92 data_type => 'string',
93 description => 'Name for the Director.',
94 required => '0',
95 },
96 'quorum' => {
97 data_type => 'int',
98 description => 'The percentage of capacity that needs to be up for a director to be considered up. `0` to `100`.',
99 required => '0',
100 },
101 'shield' => {
102 data_type => 'string',
103 description => 'Selected POP to serve as a shield for the backends. Defaults to `null` meaning no origin shielding if not set. Refer to the [POPs API endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/) to get a list of available POPs used for shielding.',
104 required => '0',
105 },
106 'type' => {
107 data_type => 'int',
108 description => 'What type of load balance group to use.',
109 required => '0',
110 },
111 'retries' => {
112 data_type => 'int',
113 description => 'How many backends to search if it fails.',
114 required => '0',
115 },
116 };
117 __PACKAGE__->method_documentation->{ 'create_director' } = {
118 summary => 'Create a director',
119 params => $params,
120 returns => 'DirectorResponse',
121 };
122 }
123 # @return DirectorResponse
124 #
125 sub create_director {
126 my ($self, %args) = @_;
127  
128 # verify the required parameter 'service_id' is set
129 unless (exists $args{'service_id'}) {
130 croak("Missing the required parameter 'service_id' when calling create_director");
131 }
132  
133 # verify the required parameter 'version_id' is set
134 unless (exists $args{'version_id'}) {
135 croak("Missing the required parameter 'version_id' when calling create_director");
136 }
137  
138 # parse inputs
139 my $_resource_path = '/service/{service_id}/version/{version_id}/director';
140  
141 my $_method = 'POST';
142 my $query_params = {};
143 my $header_params = {};
144 my $form_params = {};
145  
146 # 'Accept' and 'Content-Type' header
147 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
148 if ($_header_accept) {
149 $header_params->{'Accept'} = $_header_accept;
150 }
151 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
152  
153 # path params
154 if ( exists $args{'service_id'}) {
155 my $_base_variable = "{" . "service_id" . "}";
156 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
157 $_resource_path =~ s/$_base_variable/$_base_value/g;
158 }
159  
160 # path params
161 if ( exists $args{'version_id'}) {
162 my $_base_variable = "{" . "version_id" . "}";
163 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
164 $_resource_path =~ s/$_base_variable/$_base_value/g;
165 }
166  
167 # form params
168 if ( exists $args{'backends'} ) {
169 $form_params->{'backends'} = $self->{api_client}->to_form_value($args{'backends'});
170 }
171  
172 # form params
173 if ( exists $args{'capacity'} ) {
174 $form_params->{'capacity'} = $self->{api_client}->to_form_value($args{'capacity'});
175 }
176  
177 # form params
178 if ( exists $args{'comment'} ) {
179 $form_params->{'comment'} = $self->{api_client}->to_form_value($args{'comment'});
180 }
181  
182 # form params
183 if ( exists $args{'name'} ) {
184 $form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
185 }
186  
187 # form params
188 if ( exists $args{'quorum'} ) {
189 $form_params->{'quorum'} = $self->{api_client}->to_form_value($args{'quorum'});
190 }
191  
192 # form params
193 if ( exists $args{'shield'} ) {
194 $form_params->{'shield'} = $self->{api_client}->to_form_value($args{'shield'});
195 }
196  
197 # form params
198 if ( exists $args{'type'} ) {
199 $form_params->{'type'} = $self->{api_client}->to_form_value($args{'type'});
200 }
201  
202 # form params
203 if ( exists $args{'retries'} ) {
204 $form_params->{'retries'} = $self->{api_client}->to_form_value($args{'retries'});
205 }
206  
207 my $_body_data;
208 # authentication setting, if any
209 my $auth_settings = [qw(token )];
210  
211 # make the API Call
212 my $response = $self->{api_client}->call_api($_resource_path, $_method,
213 $query_params, $form_params,
214 $header_params, $_body_data, $auth_settings);
215 if (!$response) {
216 return;
217 }
218 my $_response_object = $self->{api_client}->deserialize('DirectorResponse', $response);
219 return $_response_object;
220 }
221  
222 #
223 # delete_director
224 #
225 # Delete a director
226 #
227 # @param string $service_id Alphanumeric string identifying the service. (required)
228 # @param int $version_id Integer identifying a service version. (required)
229 # @param string $director_name Name for the Director. (required)
230 {
231 my $params = {
232 'service_id' => {
233 data_type => 'string',
234 description => 'Alphanumeric string identifying the service.',
235 required => '1',
236 },
237 'version_id' => {
238 data_type => 'int',
239 description => 'Integer identifying a service version.',
240 required => '1',
241 },
242 'director_name' => {
243 data_type => 'string',
244 description => 'Name for the Director.',
245 required => '1',
246 },
247 };
248 __PACKAGE__->method_documentation->{ 'delete_director' } = {
249 summary => 'Delete a director',
250 params => $params,
251 returns => 'InlineResponse200',
252 };
253 }
254 # @return InlineResponse200
255 #
256 sub delete_director {
257 my ($self, %args) = @_;
258  
259 # verify the required parameter 'service_id' is set
260 unless (exists $args{'service_id'}) {
261 croak("Missing the required parameter 'service_id' when calling delete_director");
262 }
263  
264 # verify the required parameter 'version_id' is set
265 unless (exists $args{'version_id'}) {
266 croak("Missing the required parameter 'version_id' when calling delete_director");
267 }
268  
269 # verify the required parameter 'director_name' is set
270 unless (exists $args{'director_name'}) {
271 croak("Missing the required parameter 'director_name' when calling delete_director");
272 }
273  
274 # parse inputs
275 my $_resource_path = '/service/{service_id}/version/{version_id}/director/{director_name}';
276  
277 my $_method = 'DELETE';
278 my $query_params = {};
279 my $header_params = {};
280 my $form_params = {};
281  
282 # 'Accept' and 'Content-Type' header
283 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
284 if ($_header_accept) {
285 $header_params->{'Accept'} = $_header_accept;
286 }
287 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
288  
289 # path params
290 if ( exists $args{'service_id'}) {
291 my $_base_variable = "{" . "service_id" . "}";
292 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
293 $_resource_path =~ s/$_base_variable/$_base_value/g;
294 }
295  
296 # path params
297 if ( exists $args{'version_id'}) {
298 my $_base_variable = "{" . "version_id" . "}";
299 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
300 $_resource_path =~ s/$_base_variable/$_base_value/g;
301 }
302  
303 # path params
304 if ( exists $args{'director_name'}) {
305 my $_base_variable = "{" . "director_name" . "}";
306 my $_base_value = $self->{api_client}->to_path_value($args{'director_name'});
307 $_resource_path =~ s/$_base_variable/$_base_value/g;
308 }
309  
310 my $_body_data;
311 # authentication setting, if any
312 my $auth_settings = [qw(token )];
313  
314 # make the API Call
315 my $response = $self->{api_client}->call_api($_resource_path, $_method,
316 $query_params, $form_params,
317 $header_params, $_body_data, $auth_settings);
318 if (!$response) {
319 return;
320 }
321 my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response);
322 return $_response_object;
323 }
324  
325 #
326 # get_director
327 #
328 # Get a director
329 #
330 # @param string $service_id Alphanumeric string identifying the service. (required)
331 # @param int $version_id Integer identifying a service version. (required)
332 # @param string $director_name Name for the Director. (required)
333 {
334 my $params = {
335 'service_id' => {
336 data_type => 'string',
337 description => 'Alphanumeric string identifying the service.',
338 required => '1',
339 },
340 'version_id' => {
341 data_type => 'int',
342 description => 'Integer identifying a service version.',
343 required => '1',
344 },
345 'director_name' => {
346 data_type => 'string',
347 description => 'Name for the Director.',
348 required => '1',
349 },
350 };
351 __PACKAGE__->method_documentation->{ 'get_director' } = {
352 summary => 'Get a director',
353 params => $params,
354 returns => 'DirectorResponse',
355 };
356 }
357 # @return DirectorResponse
358 #
359 sub get_director {
360 my ($self, %args) = @_;
361  
362 # verify the required parameter 'service_id' is set
363 unless (exists $args{'service_id'}) {
364 croak("Missing the required parameter 'service_id' when calling get_director");
365 }
366  
367 # verify the required parameter 'version_id' is set
368 unless (exists $args{'version_id'}) {
369 croak("Missing the required parameter 'version_id' when calling get_director");
370 }
371  
372 # verify the required parameter 'director_name' is set
373 unless (exists $args{'director_name'}) {
374 croak("Missing the required parameter 'director_name' when calling get_director");
375 }
376  
377 # parse inputs
378 my $_resource_path = '/service/{service_id}/version/{version_id}/director/{director_name}';
379  
380 my $_method = 'GET';
381 my $query_params = {};
382 my $header_params = {};
383 my $form_params = {};
384  
385 # 'Accept' and 'Content-Type' header
386 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
387 if ($_header_accept) {
388 $header_params->{'Accept'} = $_header_accept;
389 }
390 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
391  
392 # path params
393 if ( exists $args{'service_id'}) {
394 my $_base_variable = "{" . "service_id" . "}";
395 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
396 $_resource_path =~ s/$_base_variable/$_base_value/g;
397 }
398  
399 # path params
400 if ( exists $args{'version_id'}) {
401 my $_base_variable = "{" . "version_id" . "}";
402 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
403 $_resource_path =~ s/$_base_variable/$_base_value/g;
404 }
405  
406 # path params
407 if ( exists $args{'director_name'}) {
408 my $_base_variable = "{" . "director_name" . "}";
409 my $_base_value = $self->{api_client}->to_path_value($args{'director_name'});
410 $_resource_path =~ s/$_base_variable/$_base_value/g;
411 }
412  
413 my $_body_data;
414 # authentication setting, if any
415 my $auth_settings = [qw(token )];
416  
417 # make the API Call
418 my $response = $self->{api_client}->call_api($_resource_path, $_method,
419 $query_params, $form_params,
420 $header_params, $_body_data, $auth_settings);
421 if (!$response) {
422 return;
423 }
424 my $_response_object = $self->{api_client}->deserialize('DirectorResponse', $response);
425 return $_response_object;
426 }
427  
428 #
429 # list_directors
430 #
431 # List directors
432 #
433 # @param string $service_id Alphanumeric string identifying the service. (required)
434 # @param int $version_id Integer identifying a service version. (required)
435 {
436 my $params = {
437 'service_id' => {
438 data_type => 'string',
439 description => 'Alphanumeric string identifying the service.',
440 required => '1',
441 },
442 'version_id' => {
443 data_type => 'int',
444 description => 'Integer identifying a service version.',
445 required => '1',
446 },
447 };
448 __PACKAGE__->method_documentation->{ 'list_directors' } = {
449 summary => 'List directors',
450 params => $params,
451 returns => 'ARRAY[DirectorResponse]',
452 };
453 }
454 # @return ARRAY[DirectorResponse]
455 #
456 sub list_directors {
457 my ($self, %args) = @_;
458  
459 # verify the required parameter 'service_id' is set
460 unless (exists $args{'service_id'}) {
461 croak("Missing the required parameter 'service_id' when calling list_directors");
462 }
463  
464 # verify the required parameter 'version_id' is set
465 unless (exists $args{'version_id'}) {
466 croak("Missing the required parameter 'version_id' when calling list_directors");
467 }
468  
469 # parse inputs
470 my $_resource_path = '/service/{service_id}/version/{version_id}/director';
471  
472 my $_method = 'GET';
473 my $query_params = {};
474 my $header_params = {};
475 my $form_params = {};
476  
477 # 'Accept' and 'Content-Type' header
478 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
479 if ($_header_accept) {
480 $header_params->{'Accept'} = $_header_accept;
481 }
482 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
483  
484 # path params
485 if ( exists $args{'service_id'}) {
486 my $_base_variable = "{" . "service_id" . "}";
487 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
488 $_resource_path =~ s/$_base_variable/$_base_value/g;
489 }
490  
491 # path params
492 if ( exists $args{'version_id'}) {
493 my $_base_variable = "{" . "version_id" . "}";
494 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
495 $_resource_path =~ s/$_base_variable/$_base_value/g;
496 }
497  
498 my $_body_data;
499 # authentication setting, if any
500 my $auth_settings = [qw(token )];
501  
502 # make the API Call
503 my $response = $self->{api_client}->call_api($_resource_path, $_method,
504 $query_params, $form_params,
505 $header_params, $_body_data, $auth_settings);
506 if (!$response) {
507 return;
508 }
509 my $_response_object = $self->{api_client}->deserialize('ARRAY[DirectorResponse]', $response);
510 return $_response_object;
511 }
512  
513 #
514 # update_director
515 #
516 # Update a director
517 #
518 # @param string $service_id Alphanumeric string identifying the service. (required)
519 # @param int $version_id Integer identifying a service version. (required)
520 # @param string $director_name Name for the Director. (required)
521 {
522 my $params = {
523 'service_id' => {
524 data_type => 'string',
525 description => 'Alphanumeric string identifying the service.',
526 required => '1',
527 },
528 'version_id' => {
529 data_type => 'int',
530 description => 'Integer identifying a service version.',
531 required => '1',
532 },
533 'director_name' => {
534 data_type => 'string',
535 description => 'Name for the Director.',
536 required => '1',
537 },
538 };
539 __PACKAGE__->method_documentation->{ 'update_director' } = {
540 summary => 'Update a director',
541 params => $params,
542 returns => 'DirectorResponse',
543 };
544 }
545 # @return DirectorResponse
546 #
547 sub update_director {
548 my ($self, %args) = @_;
549  
550 # verify the required parameter 'service_id' is set
551 unless (exists $args{'service_id'}) {
552 croak("Missing the required parameter 'service_id' when calling update_director");
553 }
554  
555 # verify the required parameter 'version_id' is set
556 unless (exists $args{'version_id'}) {
557 croak("Missing the required parameter 'version_id' when calling update_director");
558 }
559  
560 # verify the required parameter 'director_name' is set
561 unless (exists $args{'director_name'}) {
562 croak("Missing the required parameter 'director_name' when calling update_director");
563 }
564  
565 # parse inputs
566 my $_resource_path = '/service/{service_id}/version/{version_id}/director/{director_name}';
567  
568 my $_method = 'PUT';
569 my $query_params = {};
570 my $header_params = {};
571 my $form_params = {};
572  
573 # 'Accept' and 'Content-Type' header
574 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
575 if ($_header_accept) {
576 $header_params->{'Accept'} = $_header_accept;
577 }
578 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
579  
580 # path params
581 if ( exists $args{'service_id'}) {
582 my $_base_variable = "{" . "service_id" . "}";
583 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
584 $_resource_path =~ s/$_base_variable/$_base_value/g;
585 }
586  
587 # path params
588 if ( exists $args{'version_id'}) {
589 my $_base_variable = "{" . "version_id" . "}";
590 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
591 $_resource_path =~ s/$_base_variable/$_base_value/g;
592 }
593  
594 # path params
595 if ( exists $args{'director_name'}) {
596 my $_base_variable = "{" . "director_name" . "}";
597 my $_base_value = $self->{api_client}->to_path_value($args{'director_name'});
598 $_resource_path =~ s/$_base_variable/$_base_value/g;
599 }
600  
601 my $_body_data;
602 # authentication setting, if any
603 my $auth_settings = [qw(token )];
604  
605 # make the API Call
606 my $response = $self->{api_client}->call_api($_resource_path, $_method,
607 $query_params, $form_params,
608 $header_params, $_body_data, $auth_settings);
609 if (!$response) {
610 return;
611 }
612 my $_response_object = $self->{api_client}->deserialize('DirectorResponse', $response);
613 return $_response_object;
614 }
615  
616 1;