Fastly/ApexRedirectApi.pm untested

filter: Statementstmt 0.0% 0 / 218 Branchbran 0.0% 0 / 82 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 / 330 CC 42 SCAR 47.8
CC
42
Cov
0%
create_apex_redirect
240.0
update_apex_redirect
182.0
list_apex_redirects
56.0
CRAP 119.4
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::ApexRedirectApi;
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_apex_redirect
51 #
52 # Create an apex redirect
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 string $service_id (optional)
57 # @param int $version (optional)
58 # @param DateTime $created_at Date and time in ISO 8601 format. (optional)
59 # @param DateTime $deleted_at Date and time in ISO 8601 format. (optional)
60 # @param DateTime $updated_at Date and time in ISO 8601 format. (optional)
61 # @param int $status_code HTTP status code used to redirect the client. (optional)
62 # @param ARRAY[string] $domains Array of apex domains that should redirect to their WWW subdomain. (optional)
63 # @param int $feature_revision Revision number of the apex redirect feature implementation. Defaults to the most recent revision. (optional)
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 'service_id' => {
77 data_type => 'string',
78 description => '',
79 required => '0',
80 },
81 'version' => {
82 data_type => 'int',
83 description => '',
84 required => '0',
85 },
86 'created_at' => {
87 data_type => 'DateTime',
88 description => 'Date and time in ISO 8601 format.',
89 required => '0',
90 },
91 'deleted_at' => {
92 data_type => 'DateTime',
93 description => 'Date and time in ISO 8601 format.',
94 required => '0',
95 },
96 'updated_at' => {
97 data_type => 'DateTime',
98 description => 'Date and time in ISO 8601 format.',
99 required => '0',
100 },
101 'status_code' => {
102 data_type => 'int',
103 description => 'HTTP status code used to redirect the client.',
104 required => '0',
105 },
106 'domains' => {
107 data_type => 'ARRAY[string]',
108 description => 'Array of apex domains that should redirect to their WWW subdomain.',
109 required => '0',
110 },
111 'feature_revision' => {
112 data_type => 'int',
113 description => 'Revision number of the apex redirect feature implementation. Defaults to the most recent revision.',
114 required => '0',
115 },
116 };
117 __PACKAGE__->method_documentation->{ 'create_apex_redirect' } = {
118 summary => 'Create an apex redirect',
119 params => $params,
120 returns => 'ApexRedirect',
121 };
122 }
123 # @return ApexRedirect
124 #
125 sub create_apex_redirect {
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_apex_redirect");
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_apex_redirect");
136 }
137  
138 # parse inputs
139 my $_resource_path = '/service/{service_id}/version/{version_id}/apex-redirects';
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{'service_id'} ) {
169 $form_params->{'service_id'} = $self->{api_client}->to_form_value($args{'service_id'});
170 }
171  
172 # form params
173 if ( exists $args{'version'} ) {
174 $form_params->{'version'} = $self->{api_client}->to_form_value($args{'version'});
175 }
176  
177 # form params
178 if ( exists $args{'created_at'} ) {
179 $form_params->{'created_at'} = $self->{api_client}->to_form_value($args{'created_at'});
180 }
181  
182 # form params
183 if ( exists $args{'deleted_at'} ) {
184 $form_params->{'deleted_at'} = $self->{api_client}->to_form_value($args{'deleted_at'});
185 }
186  
187 # form params
188 if ( exists $args{'updated_at'} ) {
189 $form_params->{'updated_at'} = $self->{api_client}->to_form_value($args{'updated_at'});
190 }
191  
192 # form params
193 if ( exists $args{'status_code'} ) {
194 $form_params->{'status_code'} = $self->{api_client}->to_form_value($args{'status_code'});
195 }
196  
197 # form params
198 if ( exists $args{'domains'} ) {
199 $form_params->{'domains'} = $self->{api_client}->to_form_value($args{'domains'});
200 }
201  
202 # form params
203 if ( exists $args{'feature_revision'} ) {
204 $form_params->{'feature_revision'} = $self->{api_client}->to_form_value($args{'feature_revision'});
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('ApexRedirect', $response);
219 return $_response_object;
220 }
221  
222 #
223 # delete_apex_redirect
224 #
225 # Delete an apex redirect
226 #
227 # @param string $apex_redirect_id (required)
228 {
229 my $params = {
230 'apex_redirect_id' => {
231 data_type => 'string',
232 description => '',
233 required => '1',
234 },
235 };
236 __PACKAGE__->method_documentation->{ 'delete_apex_redirect' } = {
237 summary => 'Delete an apex redirect',
238 params => $params,
239 returns => 'InlineResponse200',
240 };
241 }
242 # @return InlineResponse200
243 #
244 sub delete_apex_redirect {
245 my ($self, %args) = @_;
246  
247 # verify the required parameter 'apex_redirect_id' is set
248 unless (exists $args{'apex_redirect_id'}) {
249 croak("Missing the required parameter 'apex_redirect_id' when calling delete_apex_redirect");
250 }
251  
252 # parse inputs
253 my $_resource_path = '/apex-redirects/{apex_redirect_id}';
254  
255 my $_method = 'DELETE';
256 my $query_params = {};
257 my $header_params = {};
258 my $form_params = {};
259  
260 # 'Accept' and 'Content-Type' header
261 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
262 if ($_header_accept) {
263 $header_params->{'Accept'} = $_header_accept;
264 }
265 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
266  
267 # path params
268 if ( exists $args{'apex_redirect_id'}) {
269 my $_base_variable = "{" . "apex_redirect_id" . "}";
270 my $_base_value = $self->{api_client}->to_path_value($args{'apex_redirect_id'});
271 $_resource_path =~ s/$_base_variable/$_base_value/g;
272 }
273  
274 my $_body_data;
275 # authentication setting, if any
276 my $auth_settings = [qw(token )];
277  
278 # make the API Call
279 my $response = $self->{api_client}->call_api($_resource_path, $_method,
280 $query_params, $form_params,
281 $header_params, $_body_data, $auth_settings);
282 if (!$response) {
283 return;
284 }
285 my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response);
286 return $_response_object;
287 }
288  
289 #
290 # get_apex_redirect
291 #
292 # Get an apex redirect
293 #
294 # @param string $apex_redirect_id (required)
295 {
296 my $params = {
297 'apex_redirect_id' => {
298 data_type => 'string',
299 description => '',
300 required => '1',
301 },
302 };
303 __PACKAGE__->method_documentation->{ 'get_apex_redirect' } = {
304 summary => 'Get an apex redirect',
305 params => $params,
306 returns => 'ApexRedirect',
307 };
308 }
309 # @return ApexRedirect
310 #
311 sub get_apex_redirect {
312 my ($self, %args) = @_;
313  
314 # verify the required parameter 'apex_redirect_id' is set
315 unless (exists $args{'apex_redirect_id'}) {
316 croak("Missing the required parameter 'apex_redirect_id' when calling get_apex_redirect");
317 }
318  
319 # parse inputs
320 my $_resource_path = '/apex-redirects/{apex_redirect_id}';
321  
322 my $_method = 'GET';
323 my $query_params = {};
324 my $header_params = {};
325 my $form_params = {};
326  
327 # 'Accept' and 'Content-Type' header
328 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
329 if ($_header_accept) {
330 $header_params->{'Accept'} = $_header_accept;
331 }
332 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
333  
334 # path params
335 if ( exists $args{'apex_redirect_id'}) {
336 my $_base_variable = "{" . "apex_redirect_id" . "}";
337 my $_base_value = $self->{api_client}->to_path_value($args{'apex_redirect_id'});
338 $_resource_path =~ s/$_base_variable/$_base_value/g;
339 }
340  
341 my $_body_data;
342 # authentication setting, if any
343 my $auth_settings = [qw(token )];
344  
345 # make the API Call
346 my $response = $self->{api_client}->call_api($_resource_path, $_method,
347 $query_params, $form_params,
348 $header_params, $_body_data, $auth_settings);
349 if (!$response) {
350 return;
351 }
352 my $_response_object = $self->{api_client}->deserialize('ApexRedirect', $response);
353 return $_response_object;
354 }
355  
356 #
357 # list_apex_redirects
358 #
359 # List apex redirects
360 #
361 # @param string $service_id Alphanumeric string identifying the service. (required)
362 # @param int $version_id Integer identifying a service version. (required)
363 {
364 my $params = {
365 'service_id' => {
366 data_type => 'string',
367 description => 'Alphanumeric string identifying the service.',
368 required => '1',
369 },
370 'version_id' => {
371 data_type => 'int',
372 description => 'Integer identifying a service version.',
373 required => '1',
374 },
375 };
376 __PACKAGE__->method_documentation->{ 'list_apex_redirects' } = {
377 summary => 'List apex redirects',
378 params => $params,
379 returns => 'ARRAY[ApexRedirect]',
380 };
381 }
382 # @return ARRAY[ApexRedirect]
383 #
384 sub list_apex_redirects {
385 my ($self, %args) = @_;
386  
387 # verify the required parameter 'service_id' is set
388 unless (exists $args{'service_id'}) {
389 croak("Missing the required parameter 'service_id' when calling list_apex_redirects");
390 }
391  
392 # verify the required parameter 'version_id' is set
393 unless (exists $args{'version_id'}) {
394 croak("Missing the required parameter 'version_id' when calling list_apex_redirects");
395 }
396  
397 # parse inputs
398 my $_resource_path = '/service/{service_id}/version/{version_id}/apex-redirects';
399  
400 my $_method = 'GET';
401 my $query_params = {};
402 my $header_params = {};
403 my $form_params = {};
404  
405 # 'Accept' and 'Content-Type' header
406 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
407 if ($_header_accept) {
408 $header_params->{'Accept'} = $_header_accept;
409 }
410 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
411  
412 # path params
413 if ( exists $args{'service_id'}) {
414 my $_base_variable = "{" . "service_id" . "}";
415 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
416 $_resource_path =~ s/$_base_variable/$_base_value/g;
417 }
418  
419 # path params
420 if ( exists $args{'version_id'}) {
421 my $_base_variable = "{" . "version_id" . "}";
422 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
423 $_resource_path =~ s/$_base_variable/$_base_value/g;
424 }
425  
426 my $_body_data;
427 # authentication setting, if any
428 my $auth_settings = [qw(token )];
429  
430 # make the API Call
431 my $response = $self->{api_client}->call_api($_resource_path, $_method,
432 $query_params, $form_params,
433 $header_params, $_body_data, $auth_settings);
434 if (!$response) {
435 return;
436 }
437 my $_response_object = $self->{api_client}->deserialize('ARRAY[ApexRedirect]', $response);
438 return $_response_object;
439 }
440  
441 #
442 # update_apex_redirect
443 #
444 # Update an apex redirect
445 #
446 # @param string $apex_redirect_id (required)
447 # @param string $service_id (optional)
448 # @param int $version (optional)
449 # @param DateTime $created_at Date and time in ISO 8601 format. (optional)
450 # @param DateTime $deleted_at Date and time in ISO 8601 format. (optional)
451 # @param DateTime $updated_at Date and time in ISO 8601 format. (optional)
452 # @param int $status_code HTTP status code used to redirect the client. (optional)
453 # @param ARRAY[string] $domains Array of apex domains that should redirect to their WWW subdomain. (optional)
454 # @param int $feature_revision Revision number of the apex redirect feature implementation. Defaults to the most recent revision. (optional)
455 {
456 my $params = {
457 'apex_redirect_id' => {
458 data_type => 'string',
459 description => '',
460 required => '1',
461 },
462 'service_id' => {
463 data_type => 'string',
464 description => '',
465 required => '0',
466 },
467 'version' => {
468 data_type => 'int',
469 description => '',
470 required => '0',
471 },
472 'created_at' => {
473 data_type => 'DateTime',
474 description => 'Date and time in ISO 8601 format.',
475 required => '0',
476 },
477 'deleted_at' => {
478 data_type => 'DateTime',
479 description => 'Date and time in ISO 8601 format.',
480 required => '0',
481 },
482 'updated_at' => {
483 data_type => 'DateTime',
484 description => 'Date and time in ISO 8601 format.',
485 required => '0',
486 },
487 'status_code' => {
488 data_type => 'int',
489 description => 'HTTP status code used to redirect the client.',
490 required => '0',
491 },
492 'domains' => {
493 data_type => 'ARRAY[string]',
494 description => 'Array of apex domains that should redirect to their WWW subdomain.',
495 required => '0',
496 },
497 'feature_revision' => {
498 data_type => 'int',
499 description => 'Revision number of the apex redirect feature implementation. Defaults to the most recent revision.',
500 required => '0',
501 },
502 };
503 __PACKAGE__->method_documentation->{ 'update_apex_redirect' } = {
504 summary => 'Update an apex redirect',
505 params => $params,
506 returns => 'ApexRedirect',
507 };
508 }
509 # @return ApexRedirect
510 #
511 sub update_apex_redirect {
512 my ($self, %args) = @_;
513  
514 # verify the required parameter 'apex_redirect_id' is set
515 unless (exists $args{'apex_redirect_id'}) {
516 croak("Missing the required parameter 'apex_redirect_id' when calling update_apex_redirect");
517 }
518  
519 # parse inputs
520 my $_resource_path = '/apex-redirects/{apex_redirect_id}';
521  
522 my $_method = 'PUT';
523 my $query_params = {};
524 my $header_params = {};
525 my $form_params = {};
526  
527 # 'Accept' and 'Content-Type' header
528 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
529 if ($_header_accept) {
530 $header_params->{'Accept'} = $_header_accept;
531 }
532 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
533  
534 # path params
535 if ( exists $args{'apex_redirect_id'}) {
536 my $_base_variable = "{" . "apex_redirect_id" . "}";
537 my $_base_value = $self->{api_client}->to_path_value($args{'apex_redirect_id'});
538 $_resource_path =~ s/$_base_variable/$_base_value/g;
539 }
540  
541 # form params
542 if ( exists $args{'service_id'} ) {
543 $form_params->{'service_id'} = $self->{api_client}->to_form_value($args{'service_id'});
544 }
545  
546 # form params
547 if ( exists $args{'version'} ) {
548 $form_params->{'version'} = $self->{api_client}->to_form_value($args{'version'});
549 }
550  
551 # form params
552 if ( exists $args{'created_at'} ) {
553 $form_params->{'created_at'} = $self->{api_client}->to_form_value($args{'created_at'});
554 }
555  
556 # form params
557 if ( exists $args{'deleted_at'} ) {
558 $form_params->{'deleted_at'} = $self->{api_client}->to_form_value($args{'deleted_at'});
559 }
560  
561 # form params
562 if ( exists $args{'updated_at'} ) {
563 $form_params->{'updated_at'} = $self->{api_client}->to_form_value($args{'updated_at'});
564 }
565  
566 # form params
567 if ( exists $args{'status_code'} ) {
568 $form_params->{'status_code'} = $self->{api_client}->to_form_value($args{'status_code'});
569 }
570  
571 # form params
572 if ( exists $args{'domains'} ) {
573 $form_params->{'domains'} = $self->{api_client}->to_form_value($args{'domains'});
574 }
575  
576 # form params
577 if ( exists $args{'feature_revision'} ) {
578 $form_params->{'feature_revision'} = $self->{api_client}->to_form_value($args{'feature_revision'});
579 }
580  
581 my $_body_data;
582 # authentication setting, if any
583 my $auth_settings = [qw(token )];
584  
585 # make the API Call
586 my $response = $self->{api_client}->call_api($_resource_path, $_method,
587 $query_params, $form_params,
588 $header_params, $_body_data, $auth_settings);
589 if (!$response) {
590 return;
591 }
592 my $_response_object = $self->{api_client}->deserialize('ApexRedirect', $response);
593 return $_response_object;
594 }
595  
596 1;