Fastly/CacheSettingsApi.pm untested

filter: Statementstmt 0.0% 0 / 242 Branchbran 0.0% 0 / 94 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 / 366 CC 48 SCAR 47.1
CC
48
Cov
0%
update_cache_settings
210.0
create_cache_settings
156.0
delete_cache_settings
90.0
CRAP 110.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::CacheSettingsApi;
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_cache_settings
51 #
52 # Create a cache settings object
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 $action If set, will cause vcl_fetch to terminate after processing this rule with the return state specified. If not set, other configuration logic in vcl_fetch with a lower priority will run after this rule. (optional)
57 # @param string $cache_condition Name of the cache condition controlling when this configuration applies. (optional)
58 # @param string $name Name for the cache settings object. (optional)
59 # @param string $stale_ttl Maximum time in seconds to continue to use a stale version of the object if future requests to your backend server fail (also known as 'stale if error'). (optional)
60 # @param string $ttl Maximum time to consider the object fresh in the cache (the cache 'time to live'). (optional)
61 {
62 my $params = {
63 'service_id' => {
64 data_type => 'string',
65 description => 'Alphanumeric string identifying the service.',
66 required => '1',
67 },
68 'version_id' => {
69 data_type => 'int',
70 description => 'Integer identifying a service version.',
71 required => '1',
72 },
73 'action' => {
74 data_type => 'string',
75 description => 'If set, will cause vcl_fetch to terminate after processing this rule with the return state specified. If not set, other configuration logic in vcl_fetch with a lower priority will run after this rule. ',
76 required => '0',
77 },
78 'cache_condition' => {
79 data_type => 'string',
80 description => 'Name of the cache condition controlling when this configuration applies.',
81 required => '0',
82 },
83 'name' => {
84 data_type => 'string',
85 description => 'Name for the cache settings object.',
86 required => '0',
87 },
88 'stale_ttl' => {
89 data_type => 'string',
90 description => 'Maximum time in seconds to continue to use a stale version of the object if future requests to your backend server fail (also known as 'stale if error').',
91 required => '0',
92 },
93 'ttl' => {
94 data_type => 'string',
95 description => 'Maximum time to consider the object fresh in the cache (the cache 'time to live').',
96 required => '0',
97 },
98 };
99 __PACKAGE__->method_documentation->{ 'create_cache_settings' } = {
100 summary => 'Create a cache settings object',
101 params => $params,
102 returns => 'CacheSettingResponse',
103 };
104 }
105 # @return CacheSettingResponse
106 #
107 sub create_cache_settings {
108 my ($self, %args) = @_;
109  
110 # verify the required parameter 'service_id' is set
111 unless (exists $args{'service_id'}) {
112 croak("Missing the required parameter 'service_id' when calling create_cache_settings");
113 }
114  
115 # verify the required parameter 'version_id' is set
116 unless (exists $args{'version_id'}) {
117 croak("Missing the required parameter 'version_id' when calling create_cache_settings");
118 }
119  
120 # parse inputs
121 my $_resource_path = '/service/{service_id}/version/{version_id}/cache_settings';
122  
123 my $_method = 'POST';
124 my $query_params = {};
125 my $header_params = {};
126 my $form_params = {};
127  
128 # 'Accept' and 'Content-Type' header
129 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
130 if ($_header_accept) {
131 $header_params->{'Accept'} = $_header_accept;
132 }
133 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
134  
135 # path params
136 if ( exists $args{'service_id'}) {
137 my $_base_variable = "{" . "service_id" . "}";
138 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
139 $_resource_path =~ s/$_base_variable/$_base_value/g;
140 }
141  
142 # path params
143 if ( exists $args{'version_id'}) {
144 my $_base_variable = "{" . "version_id" . "}";
145 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
146 $_resource_path =~ s/$_base_variable/$_base_value/g;
147 }
148  
149 # form params
150 if ( exists $args{'action'} ) {
151 $form_params->{'action'} = $self->{api_client}->to_form_value($args{'action'});
152 }
153  
154 # form params
155 if ( exists $args{'cache_condition'} ) {
156 $form_params->{'cache_condition'} = $self->{api_client}->to_form_value($args{'cache_condition'});
157 }
158  
159 # form params
160 if ( exists $args{'name'} ) {
161 $form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
162 }
163  
164 # form params
165 if ( exists $args{'stale_ttl'} ) {
166 $form_params->{'stale_ttl'} = $self->{api_client}->to_form_value($args{'stale_ttl'});
167 }
168  
169 # form params
170 if ( exists $args{'ttl'} ) {
171 $form_params->{'ttl'} = $self->{api_client}->to_form_value($args{'ttl'});
172 }
173  
174 my $_body_data;
175 # authentication setting, if any
176 my $auth_settings = [qw(token )];
177  
178 # make the API Call
179 my $response = $self->{api_client}->call_api($_resource_path, $_method,
180 $query_params, $form_params,
181 $header_params, $_body_data, $auth_settings);
182 if (!$response) {
183 return;
184 }
185 my $_response_object = $self->{api_client}->deserialize('CacheSettingResponse', $response);
186 return $_response_object;
187 }
188  
189 #
190 # delete_cache_settings
191 #
192 # Delete a cache settings object
193 #
194 # @param string $service_id Alphanumeric string identifying the service. (required)
195 # @param int $version_id Integer identifying a service version. (required)
196 # @param string $cache_settings_name Name for the cache settings object. (required)
197 {
198 my $params = {
199 'service_id' => {
200 data_type => 'string',
201 description => 'Alphanumeric string identifying the service.',
202 required => '1',
203 },
204 'version_id' => {
205 data_type => 'int',
206 description => 'Integer identifying a service version.',
207 required => '1',
208 },
209 'cache_settings_name' => {
210 data_type => 'string',
211 description => 'Name for the cache settings object.',
212 required => '1',
213 },
214 };
215 __PACKAGE__->method_documentation->{ 'delete_cache_settings' } = {
216 summary => 'Delete a cache settings object',
217 params => $params,
218 returns => 'InlineResponse200',
219 };
220 }
221 # @return InlineResponse200
222 #
223 sub delete_cache_settings {
224 my ($self, %args) = @_;
225  
226 # verify the required parameter 'service_id' is set
227 unless (exists $args{'service_id'}) {
228 croak("Missing the required parameter 'service_id' when calling delete_cache_settings");
229 }
230  
231 # verify the required parameter 'version_id' is set
232 unless (exists $args{'version_id'}) {
233 croak("Missing the required parameter 'version_id' when calling delete_cache_settings");
234 }
235  
236 # verify the required parameter 'cache_settings_name' is set
237 unless (exists $args{'cache_settings_name'}) {
238 croak("Missing the required parameter 'cache_settings_name' when calling delete_cache_settings");
239 }
240  
241 # parse inputs
242 my $_resource_path = '/service/{service_id}/version/{version_id}/cache_settings/{cache_settings_name}';
243  
244 my $_method = 'DELETE';
245 my $query_params = {};
246 my $header_params = {};
247 my $form_params = {};
248  
249 # 'Accept' and 'Content-Type' header
250 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
251 if ($_header_accept) {
252 $header_params->{'Accept'} = $_header_accept;
253 }
254 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
255  
256 # path params
257 if ( exists $args{'service_id'}) {
258 my $_base_variable = "{" . "service_id" . "}";
259 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
260 $_resource_path =~ s/$_base_variable/$_base_value/g;
261 }
262  
263 # path params
264 if ( exists $args{'version_id'}) {
265 my $_base_variable = "{" . "version_id" . "}";
266 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
267 $_resource_path =~ s/$_base_variable/$_base_value/g;
268 }
269  
270 # path params
271 if ( exists $args{'cache_settings_name'}) {
272 my $_base_variable = "{" . "cache_settings_name" . "}";
273 my $_base_value = $self->{api_client}->to_path_value($args{'cache_settings_name'});
274 $_resource_path =~ s/$_base_variable/$_base_value/g;
275 }
276  
277 my $_body_data;
278 # authentication setting, if any
279 my $auth_settings = [qw(token )];
280  
281 # make the API Call
282 my $response = $self->{api_client}->call_api($_resource_path, $_method,
283 $query_params, $form_params,
284 $header_params, $_body_data, $auth_settings);
285 if (!$response) {
286 return;
287 }
288 my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response);
289 return $_response_object;
290 }
291  
292 #
293 # get_cache_settings
294 #
295 # Get a cache settings object
296 #
297 # @param string $service_id Alphanumeric string identifying the service. (required)
298 # @param int $version_id Integer identifying a service version. (required)
299 # @param string $cache_settings_name Name for the cache settings object. (required)
300 {
301 my $params = {
302 'service_id' => {
303 data_type => 'string',
304 description => 'Alphanumeric string identifying the service.',
305 required => '1',
306 },
307 'version_id' => {
308 data_type => 'int',
309 description => 'Integer identifying a service version.',
310 required => '1',
311 },
312 'cache_settings_name' => {
313 data_type => 'string',
314 description => 'Name for the cache settings object.',
315 required => '1',
316 },
317 };
318 __PACKAGE__->method_documentation->{ 'get_cache_settings' } = {
319 summary => 'Get a cache settings object',
320 params => $params,
321 returns => 'CacheSettingResponse',
322 };
323 }
324 # @return CacheSettingResponse
325 #
326 sub get_cache_settings {
327 my ($self, %args) = @_;
328  
329 # verify the required parameter 'service_id' is set
330 unless (exists $args{'service_id'}) {
331 croak("Missing the required parameter 'service_id' when calling get_cache_settings");
332 }
333  
334 # verify the required parameter 'version_id' is set
335 unless (exists $args{'version_id'}) {
336 croak("Missing the required parameter 'version_id' when calling get_cache_settings");
337 }
338  
339 # verify the required parameter 'cache_settings_name' is set
340 unless (exists $args{'cache_settings_name'}) {
341 croak("Missing the required parameter 'cache_settings_name' when calling get_cache_settings");
342 }
343  
344 # parse inputs
345 my $_resource_path = '/service/{service_id}/version/{version_id}/cache_settings/{cache_settings_name}';
346  
347 my $_method = 'GET';
348 my $query_params = {};
349 my $header_params = {};
350 my $form_params = {};
351  
352 # 'Accept' and 'Content-Type' header
353 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
354 if ($_header_accept) {
355 $header_params->{'Accept'} = $_header_accept;
356 }
357 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
358  
359 # path params
360 if ( exists $args{'service_id'}) {
361 my $_base_variable = "{" . "service_id" . "}";
362 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
363 $_resource_path =~ s/$_base_variable/$_base_value/g;
364 }
365  
366 # path params
367 if ( exists $args{'version_id'}) {
368 my $_base_variable = "{" . "version_id" . "}";
369 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
370 $_resource_path =~ s/$_base_variable/$_base_value/g;
371 }
372  
373 # path params
374 if ( exists $args{'cache_settings_name'}) {
375 my $_base_variable = "{" . "cache_settings_name" . "}";
376 my $_base_value = $self->{api_client}->to_path_value($args{'cache_settings_name'});
377 $_resource_path =~ s/$_base_variable/$_base_value/g;
378 }
379  
380 my $_body_data;
381 # authentication setting, if any
382 my $auth_settings = [qw(token )];
383  
384 # make the API Call
385 my $response = $self->{api_client}->call_api($_resource_path, $_method,
386 $query_params, $form_params,
387 $header_params, $_body_data, $auth_settings);
388 if (!$response) {
389 return;
390 }
391 my $_response_object = $self->{api_client}->deserialize('CacheSettingResponse', $response);
392 return $_response_object;
393 }
394  
395 #
396 # list_cache_settings
397 #
398 # List cache settings objects
399 #
400 # @param string $service_id Alphanumeric string identifying the service. (required)
401 # @param int $version_id Integer identifying a service version. (required)
402 {
403 my $params = {
404 'service_id' => {
405 data_type => 'string',
406 description => 'Alphanumeric string identifying the service.',
407 required => '1',
408 },
409 'version_id' => {
410 data_type => 'int',
411 description => 'Integer identifying a service version.',
412 required => '1',
413 },
414 };
415 __PACKAGE__->method_documentation->{ 'list_cache_settings' } = {
416 summary => 'List cache settings objects',
417 params => $params,
418 returns => 'ARRAY[CacheSettingResponse]',
419 };
420 }
421 # @return ARRAY[CacheSettingResponse]
422 #
423 sub list_cache_settings {
424 my ($self, %args) = @_;
425  
426 # verify the required parameter 'service_id' is set
427 unless (exists $args{'service_id'}) {
428 croak("Missing the required parameter 'service_id' when calling list_cache_settings");
429 }
430  
431 # verify the required parameter 'version_id' is set
432 unless (exists $args{'version_id'}) {
433 croak("Missing the required parameter 'version_id' when calling list_cache_settings");
434 }
435  
436 # parse inputs
437 my $_resource_path = '/service/{service_id}/version/{version_id}/cache_settings';
438  
439 my $_method = 'GET';
440 my $query_params = {};
441 my $header_params = {};
442 my $form_params = {};
443  
444 # 'Accept' and 'Content-Type' header
445 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
446 if ($_header_accept) {
447 $header_params->{'Accept'} = $_header_accept;
448 }
449 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
450  
451 # path params
452 if ( exists $args{'service_id'}) {
453 my $_base_variable = "{" . "service_id" . "}";
454 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
455 $_resource_path =~ s/$_base_variable/$_base_value/g;
456 }
457  
458 # path params
459 if ( exists $args{'version_id'}) {
460 my $_base_variable = "{" . "version_id" . "}";
461 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
462 $_resource_path =~ s/$_base_variable/$_base_value/g;
463 }
464  
465 my $_body_data;
466 # authentication setting, if any
467 my $auth_settings = [qw(token )];
468  
469 # make the API Call
470 my $response = $self->{api_client}->call_api($_resource_path, $_method,
471 $query_params, $form_params,
472 $header_params, $_body_data, $auth_settings);
473 if (!$response) {
474 return;
475 }
476 my $_response_object = $self->{api_client}->deserialize('ARRAY[CacheSettingResponse]', $response);
477 return $_response_object;
478 }
479  
480 #
481 # update_cache_settings
482 #
483 # Update a cache settings object
484 #
485 # @param string $service_id Alphanumeric string identifying the service. (required)
486 # @param int $version_id Integer identifying a service version. (required)
487 # @param string $cache_settings_name Name for the cache settings object. (required)
488 # @param string $action If set, will cause vcl_fetch to terminate after processing this rule with the return state specified. If not set, other configuration logic in vcl_fetch with a lower priority will run after this rule. (optional)
489 # @param string $cache_condition Name of the cache condition controlling when this configuration applies. (optional)
490 # @param string $name Name for the cache settings object. (optional)
491 # @param string $stale_ttl Maximum time in seconds to continue to use a stale version of the object if future requests to your backend server fail (also known as 'stale if error'). (optional)
492 # @param string $ttl Maximum time to consider the object fresh in the cache (the cache 'time to live'). (optional)
493 {
494 my $params = {
495 'service_id' => {
496 data_type => 'string',
497 description => 'Alphanumeric string identifying the service.',
498 required => '1',
499 },
500 'version_id' => {
501 data_type => 'int',
502 description => 'Integer identifying a service version.',
503 required => '1',
504 },
505 'cache_settings_name' => {
506 data_type => 'string',
507 description => 'Name for the cache settings object.',
508 required => '1',
509 },
510 'action' => {
511 data_type => 'string',
512 description => 'If set, will cause vcl_fetch to terminate after processing this rule with the return state specified. If not set, other configuration logic in vcl_fetch with a lower priority will run after this rule. ',
513 required => '0',
514 },
515 'cache_condition' => {
516 data_type => 'string',
517 description => 'Name of the cache condition controlling when this configuration applies.',
518 required => '0',
519 },
520 'name' => {
521 data_type => 'string',
522 description => 'Name for the cache settings object.',
523 required => '0',
524 },
525 'stale_ttl' => {
526 data_type => 'string',
527 description => 'Maximum time in seconds to continue to use a stale version of the object if future requests to your backend server fail (also known as 'stale if error').',
528 required => '0',
529 },
530 'ttl' => {
531 data_type => 'string',
532 description => 'Maximum time to consider the object fresh in the cache (the cache 'time to live').',
533 required => '0',
534 },
535 };
536 __PACKAGE__->method_documentation->{ 'update_cache_settings' } = {
537 summary => 'Update a cache settings object',
538 params => $params,
539 returns => 'CacheSettingResponse',
540 };
541 }
542 # @return CacheSettingResponse
543 #
544 sub update_cache_settings {
545 my ($self, %args) = @_;
546  
547 # verify the required parameter 'service_id' is set
548 unless (exists $args{'service_id'}) {
549 croak("Missing the required parameter 'service_id' when calling update_cache_settings");
550 }
551  
552 # verify the required parameter 'version_id' is set
553 unless (exists $args{'version_id'}) {
554 croak("Missing the required parameter 'version_id' when calling update_cache_settings");
555 }
556  
557 # verify the required parameter 'cache_settings_name' is set
558 unless (exists $args{'cache_settings_name'}) {
559 croak("Missing the required parameter 'cache_settings_name' when calling update_cache_settings");
560 }
561  
562 # parse inputs
563 my $_resource_path = '/service/{service_id}/version/{version_id}/cache_settings/{cache_settings_name}';
564  
565 my $_method = 'PUT';
566 my $query_params = {};
567 my $header_params = {};
568 my $form_params = {};
569  
570 # 'Accept' and 'Content-Type' header
571 my $_header_accept = $self->{api_client}->select_header_accept('application/json');
572 if ($_header_accept) {
573 $header_params->{'Accept'} = $_header_accept;
574 }
575 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
576  
577 # path params
578 if ( exists $args{'service_id'}) {
579 my $_base_variable = "{" . "service_id" . "}";
580 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
581 $_resource_path =~ s/$_base_variable/$_base_value/g;
582 }
583  
584 # path params
585 if ( exists $args{'version_id'}) {
586 my $_base_variable = "{" . "version_id" . "}";
587 my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
588 $_resource_path =~ s/$_base_variable/$_base_value/g;
589 }
590  
591 # path params
592 if ( exists $args{'cache_settings_name'}) {
593 my $_base_variable = "{" . "cache_settings_name" . "}";
594 my $_base_value = $self->{api_client}->to_path_value($args{'cache_settings_name'});
595 $_resource_path =~ s/$_base_variable/$_base_value/g;
596 }
597  
598 # form params
599 if ( exists $args{'action'} ) {
600 $form_params->{'action'} = $self->{api_client}->to_form_value($args{'action'});
601 }
602  
603 # form params
604 if ( exists $args{'cache_condition'} ) {
605 $form_params->{'cache_condition'} = $self->{api_client}->to_form_value($args{'cache_condition'});
606 }
607  
608 # form params
609 if ( exists $args{'name'} ) {
610 $form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
611 }
612  
613 # form params
614 if ( exists $args{'stale_ttl'} ) {
615 $form_params->{'stale_ttl'} = $self->{api_client}->to_form_value($args{'stale_ttl'});
616 }
617  
618 # form params
619 if ( exists $args{'ttl'} ) {
620 $form_params->{'ttl'} = $self->{api_client}->to_form_value($args{'ttl'});
621 }
622  
623 my $_body_data;
624 # authentication setting, if any
625 my $auth_settings = [qw(token )];
626  
627 # make the API Call
628 my $response = $self->{api_client}->call_api($_resource_path, $_method,
629 $query_params, $form_params,
630 $header_params, $_body_data, $auth_settings);
631 if (!$response) {
632 return;
633 }
634 my $_response_object = $self->{api_client}->deserialize('CacheSettingResponse', $response);
635 return $_response_object;
636 }
637  
638 1;