Fastly/ServiceApi.pm untested

filter: Statementstmt 0.0% 0 / 270 Branchbran 0.0% 0 / 84 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 18 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 390 CC 43 SCAR 36.8
CC
43
Cov
0%
update_service
72.0
create_service
56.0
get_service_detail
56.0
CRAP 39.7
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::ServiceApi;
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_service
51 #
52 # Create a service
53 #
54 # @param string $comment A freeform descriptive note. (optional)
55 # @param string $name The name of the service. (optional)
56 # @param string $customer_id Alphanumeric string identifying the customer. (optional)
57 # @param string $type The type of this service. (optional)
58 {
59 my $params = {
60 'comment' => {
61 data_type => 'string',
62 description => 'A freeform descriptive note.',
63 required => '0',
64 },
65 'name' => {
66 data_type => 'string',
67 description => 'The name of the service.',
68 required => '0',
69 },
70 'customer_id' => {
71 data_type => 'string',
72 description => 'Alphanumeric string identifying the customer.',
73 required => '0',
74 },
75 'type' => {
76 data_type => 'string',
77 description => 'The type of this service.',
78 required => '0',
79 },
80 };
81 __PACKAGE__->method_documentation->{ 'create_service' } = {
82 summary => 'Create a service',
83 params => $params,
84 returns => 'ServiceResponse',
85 };
86 }
87 # @return ServiceResponse
88 #
89 sub create_service {
90 my ($self, %args) = @_;
91  
92 # parse inputs
93 my $_resource_path = '/service';
94  
95 my $_method = 'POST';
96 my $query_params = {};
97 my $header_params = {};
98 my $form_params = {};
99  
100 # 'Accept' and 'Content-Type' header
101 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
102 if ($_header_accept) {
103 $header_params->{'Accept'} = $_header_accept;
104 }
105 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
106  
107 # form params
108 if ( exists $args{'comment'} ) {
109 $form_params->{'comment'} = $self->{api_client}->to_form_value($args{'comment'});
110 }
111  
112 # form params
113 if ( exists $args{'name'} ) {
114 $form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
115 }
116  
117 # form params
118 if ( exists $args{'customer_id'} ) {
119 $form_params->{'customer_id'} = $self->{api_client}->to_form_value($args{'customer_id'});
120 }
121  
122 # form params
123 if ( exists $args{'type'} ) {
124 $form_params->{'type'} = $self->{api_client}->to_form_value($args{'type'});
125 }
126  
127 my $_body_data;
128 # authentication setting, if any
129 my $auth_settings = [qw(token )];
130  
131 # make the API Call
132 my $response = $self->{api_client}->call_api($_resource_path, $_method,
133 $query_params, $form_params,
134 $header_params, $_body_data, $auth_settings);
135 if (!$response) {
136 return;
137 }
138 my $_response_object = $self->{api_client}->deserialize('ServiceResponse', $response);
139 return $_response_object;
140 }
141  
142 #
143 # delete_service
144 #
145 # Delete a service
146 #
147 # @param string $service_id Alphanumeric string identifying the service. (required)
148 {
149 my $params = {
150 'service_id' => {
151 data_type => 'string',
152 description => 'Alphanumeric string identifying the service.',
153 required => '1',
154 },
155 };
156 __PACKAGE__->method_documentation->{ 'delete_service' } = {
157 summary => 'Delete a service',
158 params => $params,
159 returns => 'InlineResponse200',
160 };
161 }
162 # @return InlineResponse200
163 #
164 sub delete_service {
165 my ($self, %args) = @_;
166  
167 # verify the required parameter 'service_id' is set
168 unless (exists $args{'service_id'}) {
169 croak("Missing the required parameter 'service_id' when calling delete_service");
170 }
171  
172 # parse inputs
173 my $_resource_path = '/service/{service_id}';
174  
175 my $_method = 'DELETE';
176 my $query_params = {};
177 my $header_params = {};
178 my $form_params = {};
179  
180 # 'Accept' and 'Content-Type' header
181 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
182 if ($_header_accept) {
183 $header_params->{'Accept'} = $_header_accept;
184 }
185 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
186  
187 # path params
188 if ( exists $args{'service_id'}) {
189 my $_base_variable = "{" . "service_id" . "}";
190 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
191 $_resource_path =~ s/$_base_variable/$_base_value/g;
192 }
193  
194 my $_body_data;
195 # authentication setting, if any
196 my $auth_settings = [qw(token )];
197  
198 # make the API Call
199 my $response = $self->{api_client}->call_api($_resource_path, $_method,
200 $query_params, $form_params,
201 $header_params, $_body_data, $auth_settings);
202 if (!$response) {
203 return;
204 }
205 my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response);
206 return $_response_object;
207 }
208  
209 #
210 # get_service
211 #
212 # Get a service
213 #
214 # @param string $service_id Alphanumeric string identifying the service. (required)
215 {
216 my $params = {
217 'service_id' => {
218 data_type => 'string',
219 description => 'Alphanumeric string identifying the service.',
220 required => '1',
221 },
222 };
223 __PACKAGE__->method_documentation->{ 'get_service' } = {
224 summary => 'Get a service',
225 params => $params,
226 returns => 'ServiceResponse',
227 };
228 }
229 # @return ServiceResponse
230 #
231 sub get_service {
232 my ($self, %args) = @_;
233  
234 # verify the required parameter 'service_id' is set
235 unless (exists $args{'service_id'}) {
236 croak("Missing the required parameter 'service_id' when calling get_service");
237 }
238  
239 # parse inputs
240 my $_resource_path = '/service/{service_id}';
241  
242 my $_method = 'GET';
243 my $query_params = {};
244 my $header_params = {};
245 my $form_params = {};
246  
247 # 'Accept' and 'Content-Type' header
248 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
249 if ($_header_accept) {
250 $header_params->{'Accept'} = $_header_accept;
251 }
252 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
253  
254 # path params
255 if ( exists $args{'service_id'}) {
256 my $_base_variable = "{" . "service_id" . "}";
257 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
258 $_resource_path =~ s/$_base_variable/$_base_value/g;
259 }
260  
261 my $_body_data;
262 # authentication setting, if any
263 my $auth_settings = [qw(token )];
264  
265 # make the API Call
266 my $response = $self->{api_client}->call_api($_resource_path, $_method,
267 $query_params, $form_params,
268 $header_params, $_body_data, $auth_settings);
269 if (!$response) {
270 return;
271 }
272 my $_response_object = $self->{api_client}->deserialize('ServiceResponse', $response);
273 return $_response_object;
274 }
275  
276 #
277 # get_service_detail
278 #
279 # Get service details
280 #
281 # @param string $service_id Alphanumeric string identifying the service. (required)
282 # @param int $version Number identifying a version of the service. (optional)
283 # @param boolean $filter[versions/active] Limits the versions array to the active versions. Accepts `true` or `false` (defaults to false). (optional)
284 {
285 my $params = {
286 'service_id' => {
287 data_type => 'string',
288 description => 'Alphanumeric string identifying the service.',
289 required => '1',
290 },
291 'version' => {
292 data_type => 'int',
293 description => 'Number identifying a version of the service.',
294 required => '0',
295 },
296 'filter[versions/active]' => {
297 data_type => 'boolean',
298 description => 'Limits the versions array to the active versions. Accepts `true` or `false` (defaults to false).',
299 required => '0',
300 },
301 };
302 __PACKAGE__->method_documentation->{ 'get_service_detail' } = {
303 summary => 'Get service details',
304 params => $params,
305 returns => 'ServiceDetail',
306 };
307 }
308 # @return ServiceDetail
309 #
310 sub get_service_detail {
311 my ($self, %args) = @_;
312  
313 # verify the required parameter 'service_id' is set
314 unless (exists $args{'service_id'}) {
315 croak("Missing the required parameter 'service_id' when calling get_service_detail");
316 }
317  
318 # parse inputs
319 my $_resource_path = '/service/{service_id}/details';
320  
321 my $_method = 'GET';
322 my $query_params = {};
323 my $header_params = {};
324 my $form_params = {};
325  
326 # 'Accept' and 'Content-Type' header
327 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
328 if ($_header_accept) {
329 $header_params->{'Accept'} = $_header_accept;
330 }
331 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
332  
333 # query params
334 if ( exists $args{'version'}) {
335 $query_params->{'version'} = $self->{api_client}->to_query_value($args{'version'});
336 }
337  
338 # query params
339 if ( exists $args{'filter[versions/active]'}) {
340 $query_params->{'filter[versions.active]'} = $self->{api_client}->to_query_value($args{'filter[versions/active]'});
341 }
342  
343 # path params
344 if ( exists $args{'service_id'}) {
345 my $_base_variable = "{" . "service_id" . "}";
346 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
347 $_resource_path =~ s/$_base_variable/$_base_value/g;
348 }
349  
350 my $_body_data;
351 # authentication setting, if any
352 my $auth_settings = [qw(token )];
353  
354 # make the API Call
355 my $response = $self->{api_client}->call_api($_resource_path, $_method,
356 $query_params, $form_params,
357 $header_params, $_body_data, $auth_settings);
358 if (!$response) {
359 return;
360 }
361 my $_response_object = $self->{api_client}->deserialize('ServiceDetail', $response);
362 return $_response_object;
363 }
364  
365 #
366 # list_service_domains
367 #
368 # List the domains within a service
369 #
370 # @param string $service_id Alphanumeric string identifying the service. (required)
371 {
372 my $params = {
373 'service_id' => {
374 data_type => 'string',
375 description => 'Alphanumeric string identifying the service.',
376 required => '1',
377 },
378 };
379 __PACKAGE__->method_documentation->{ 'list_service_domains' } = {
380 summary => 'List the domains within a service',
381 params => $params,
382 returns => 'ARRAY[DomainResponse]',
383 };
384 }
385 # @return ARRAY[DomainResponse]
386 #
387 sub list_service_domains {
388 my ($self, %args) = @_;
389  
390 # verify the required parameter 'service_id' is set
391 unless (exists $args{'service_id'}) {
392 croak("Missing the required parameter 'service_id' when calling list_service_domains");
393 }
394  
395 # parse inputs
396 my $_resource_path = '/service/{service_id}/domain';
397  
398 my $_method = 'GET';
399 my $query_params = {};
400 my $header_params = {};
401 my $form_params = {};
402  
403 # 'Accept' and 'Content-Type' header
404 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
405 if ($_header_accept) {
406 $header_params->{'Accept'} = $_header_accept;
407 }
408 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
409  
410 # path params
411 if ( exists $args{'service_id'}) {
412 my $_base_variable = "{" . "service_id" . "}";
413 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
414 $_resource_path =~ s/$_base_variable/$_base_value/g;
415 }
416  
417 my $_body_data;
418 # authentication setting, if any
419 my $auth_settings = [qw(token )];
420  
421 # make the API Call
422 my $response = $self->{api_client}->call_api($_resource_path, $_method,
423 $query_params, $form_params,
424 $header_params, $_body_data, $auth_settings);
425 if (!$response) {
426 return;
427 }
428 my $_response_object = $self->{api_client}->deserialize('ARRAY[DomainResponse]', $response);
429 return $_response_object;
430 }
431  
432 #
433 # list_services
434 #
435 # List services
436 #
437 # @param int $page Current page. (optional)
438 # @param int $per_page Number of records per page. (optional, default to 20)
439 # @param string $sort Field on which to sort. (optional, default to 'created')
440 # @param string $direction Direction in which to sort results. (optional, default to 'ascend')
441 {
442 my $params = {
443 'page' => {
444 data_type => 'int',
445 description => 'Current page.',
446 required => '0',
447 },
448 'per_page' => {
449 data_type => 'int',
450 description => 'Number of records per page.',
451 required => '0',
452 },
453 'sort' => {
454 data_type => 'string',
455 description => 'Field on which to sort.',
456 required => '0',
457 },
458 'direction' => {
459 data_type => 'string',
460 description => 'Direction in which to sort results.',
461 required => '0',
462 },
463 };
464 __PACKAGE__->method_documentation->{ 'list_services' } = {
465 summary => 'List services',
466 params => $params,
467 returns => 'ARRAY[ServiceListResponse]',
468 };
469 }
470 # @return ARRAY[ServiceListResponse]
471 #
472 sub list_services {
473 my ($self, %args) = @_;
474  
475 # parse inputs
476 my $_resource_path = '/service';
477  
478 my $_method = 'GET';
479 my $query_params = {};
480 my $header_params = {};
481 my $form_params = {};
482  
483 # 'Accept' and 'Content-Type' header
484 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
485 if ($_header_accept) {
486 $header_params->{'Accept'} = $_header_accept;
487 }
488 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
489  
490 # query params
491 if ( exists $args{'page'}) {
492 $query_params->{'page'} = $self->{api_client}->to_query_value($args{'page'});
493 }
494  
495 # query params
496 if ( exists $args{'per_page'}) {
497 $query_params->{'per_page'} = $self->{api_client}->to_query_value($args{'per_page'});
498 }
499  
500 # query params
501 if ( exists $args{'sort'}) {
502 $query_params->{'sort'} = $self->{api_client}->to_query_value($args{'sort'});
503 }
504  
505 # query params
506 if ( exists $args{'direction'}) {
507 $query_params->{'direction'} = $self->{api_client}->to_query_value($args{'direction'});
508 }
509  
510 my $_body_data;
511 # authentication setting, if any
512 my $auth_settings = [qw(token )];
513  
514 # make the API Call
515 my $response = $self->{api_client}->call_api($_resource_path, $_method,
516 $query_params, $form_params,
517 $header_params, $_body_data, $auth_settings);
518 if (!$response) {
519 return;
520 }
521 my $_response_object = $self->{api_client}->deserialize('ARRAY[ServiceListResponse]', $response);
522 return $_response_object;
523 }
524  
525 #
526 # search_service
527 #
528 # Search for a service by name
529 #
530 # @param string $name The name of the service. (required)
531 {
532 my $params = {
533 'name' => {
534 data_type => 'string',
535 description => 'The name of the service.',
536 required => '1',
537 },
538 };
539 __PACKAGE__->method_documentation->{ 'search_service' } = {
540 summary => 'Search for a service by name',
541 params => $params,
542 returns => 'ServiceResponse',
543 };
544 }
545 # @return ServiceResponse
546 #
547 sub search_service {
548 my ($self, %args) = @_;
549  
550 # verify the required parameter 'name' is set
551 unless (exists $args{'name'}) {
552 croak("Missing the required parameter 'name' when calling search_service");
553 }
554  
555 # parse inputs
556 my $_resource_path = '/service/search';
557  
558 my $_method = 'GET';
559 my $query_params = {};
560 my $header_params = {};
561 my $form_params = {};
562  
563 # 'Accept' and 'Content-Type' header
564 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
565 if ($_header_accept) {
566 $header_params->{'Accept'} = $_header_accept;
567 }
568 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
569  
570 # query params
571 if ( exists $args{'name'}) {
572 $query_params->{'name'} = $self->{api_client}->to_query_value($args{'name'});
573 }
574  
575 my $_body_data;
576 # authentication setting, if any
577 my $auth_settings = [qw(token )];
578  
579 # make the API Call
580 my $response = $self->{api_client}->call_api($_resource_path, $_method,
581 $query_params, $form_params,
582 $header_params, $_body_data, $auth_settings);
583 if (!$response) {
584 return;
585 }
586 my $_response_object = $self->{api_client}->deserialize('ServiceResponse', $response);
587 return $_response_object;
588 }
589  
590 #
591 # update_service
592 #
593 # Update a service
594 #
595 # @param string $service_id Alphanumeric string identifying the service. (required)
596 # @param string $comment A freeform descriptive note. (optional)
597 # @param string $name The name of the service. (optional)
598 # @param string $customer_id Alphanumeric string identifying the customer. (optional)
599 {
600 my $params = {
601 'service_id' => {
602 data_type => 'string',
603 description => 'Alphanumeric string identifying the service.',
604 required => '1',
605 },
606 'comment' => {
607 data_type => 'string',
608 description => 'A freeform descriptive note.',
609 required => '0',
610 },
611 'name' => {
612 data_type => 'string',
613 description => 'The name of the service.',
614 required => '0',
615 },
616 'customer_id' => {
617 data_type => 'string',
618 description => 'Alphanumeric string identifying the customer.',
619 required => '0',
620 },
621 };
622 __PACKAGE__->method_documentation->{ 'update_service' } = {
623 summary => 'Update a service',
624 params => $params,
625 returns => 'ServiceResponse',
626 };
627 }
628 # @return ServiceResponse
629 #
630 sub update_service {
631 my ($self, %args) = @_;
632  
633 # verify the required parameter 'service_id' is set
634 unless (exists $args{'service_id'}) {
635 croak("Missing the required parameter 'service_id' when calling update_service");
636 }
637  
638 # parse inputs
639 my $_resource_path = '/service/{service_id}';
640  
641 my $_method = 'PUT';
642 my $query_params = {};
643 my $header_params = {};
644 my $form_params = {};
645  
646 # 'Accept' and 'Content-Type' header
647 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
648 if ($_header_accept) {
649 $header_params->{'Accept'} = $_header_accept;
650 }
651 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
652  
653 # path params
654 if ( exists $args{'service_id'}) {
655 my $_base_variable = "{" . "service_id" . "}";
656 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
657 $_resource_path =~ s/$_base_variable/$_base_value/g;
658 }
659  
660 # form params
661 if ( exists $args{'comment'} ) {
662 $form_params->{'comment'} = $self->{api_client}->to_form_value($args{'comment'});
663 }
664  
665 # form params
666 if ( exists $args{'name'} ) {
667 $form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
668 }
669  
670 # form params
671 if ( exists $args{'customer_id'} ) {
672 $form_params->{'customer_id'} = $self->{api_client}->to_form_value($args{'customer_id'});
673 }
674  
675 my $_body_data;
676 # authentication setting, if any
677 my $auth_settings = [qw(token )];
678  
679 # make the API Call
680 my $response = $self->{api_client}->call_api($_resource_path, $_method,
681 $query_params, $form_params,
682 $header_params, $_body_data, $auth_settings);
683 if (!$response) {
684 return;
685 }
686 my $_response_object = $self->{api_client}->deserialize('ServiceResponse', $response);
687 return $_response_object;
688 }
689  
690 1;