Fastly/Object/Backend.pm untested

filter: Statementstmt 0.0% 0 / 104 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 17 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 147 CC 7 SCAR 21.1
CC
7
Cov
0%
from_hash
20.0
_deserialize
20.0
new
2.0
CRAP 8.3
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::Object::Backend;
19  
20 require 5.6.0;
21 use strict;
22 use warnings;
23 use utf8;
24 use JSON::MaybeXS qw(decode_json);
25 use Data::Dumper;
26 use Module::Runtime qw(use_module);
27 use Log::Any qw($log);
28 use Date::Parse;
29 use DateTime;
30  
31  
32 use base ("Class::Accessor", "Class::Data::Inheritable");
33  
34 #
35 #
36 #
37 # NOTE: This class is auto generated. Do not edit the class manually.
38 #
39  
40 =begin comment
41  
42 Fastly API
43  
44 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/)
45  
46 The version of the API Spec document: 1.0.0
47 Contact: oss@fastly.com
48  
49 =end comment
50  
51 =cut
52  
53 #
54 # NOTE: This class is auto generated.
55 # Do not edit the class manually.
56 #
57 __PACKAGE__->mk_classdata('attribute_map' => {});
58 __PACKAGE__->mk_classdata('openapi_types' => {});
59 __PACKAGE__->mk_classdata('method_documentation' => {});
60 __PACKAGE__->mk_classdata('class_documentation' => {});
61 __PACKAGE__->mk_classdata('openapi_nullable' => {});
62  
63 # new plain object
64 sub new {
65 my ($class, %args) = @_;
66  
67 my $self = bless {}, $class;
68  
69 $self->init(%args);
70  
71 return $self;
72 }
73  
74 # initialize the object
75 sub init
76 {
77 my ($self, %args) = @_;
78  
79 foreach my $attribute (keys %{$self->attribute_map}) {
80 my $args_key = $self->attribute_map->{$attribute};
81 $self->$attribute( $args{ $args_key } );
82 }
83 }
84  
85 # return perl hash
86 sub to_hash {
87 my $self = shift;
88 my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
89  
90 return $_hash;
91 }
92  
93 # used by JSON for serialization
94 sub TO_JSON {
95 my $self = shift;
96 my $_data = {};
97 foreach my $_key (keys %{$self->attribute_map}) {
98 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
99 }
100  
101 return $_data;
102 }
103  
104 # from Perl hashref
105 sub from_hash {
106 my ($self, $hash) = @_;
107  
108 # loop through attributes and use openapi_types to deserialize the data
109 while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
110 my $_json_attribute = $self->attribute_map->{$_key};
111 my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true';
112 if ($_type =~ /^array\[(.+)\]$/i) { # array
113 my $_subclass = $1;
114 my @_array = ();
115 foreach my $_element (@{$hash->{$_json_attribute}}) {
116 push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable);
117 }
118 $self->{$_key} = \@_array;
119 } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
120 my $_subclass = $1;
121 my %_hash = ();
122 while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
123 $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable);
124 }
125 $self->{$_key} = \%_hash;
126 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
127 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable);
128 } else {
129 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
130 }
131 }
132  
133 return $self;
134 }
135  
136 # deserialize non-array data
137 sub _deserialize {
138 my ($self, $type, $data, $is_nullable) = @_;
139 $log->debugf("deserializing %s with %s",Dumper($data), $type);
140  
141 if (!(defined $data) && $is_nullable) {
142 return undef;
143 }
144 if ($type eq 'DateTime') {
145 return DateTime->from_epoch(epoch => str2time($data));
146 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
147 return $data;
148 } else { # hash(model)
149 my $_instance = eval "WebService::Fastly::Object::$type->new()";
150 return $_instance->from_hash($data);
151 }
152 }
153  
154  
155 __PACKAGE__->class_documentation({description => '',
156 class => 'Backend',
157 required => [], # TODO
158 } );
159  
160 __PACKAGE__->method_documentation({
161 'address' => {
162 datatype => 'string',
163 base_name => 'address',
164 description => 'A hostname, IPv4, or IPv6 address for the backend. This is the preferred way to specify the location of your backend.',
165 format => '',
166 read_only => 'false',
167 },
168 'auto_loadbalance' => {
169 datatype => 'boolean',
170 base_name => 'auto_loadbalance',
171 description => 'Whether or not this backend should be automatically load balanced. If true, all backends with this setting that don't have a `request_condition` will be selected based on their `weight`.',
172 format => '',
173 read_only => 'false',
174 },
175 'between_bytes_timeout' => {
176 datatype => 'int',
177 base_name => 'between_bytes_timeout',
178 description => 'Maximum duration in milliseconds that Fastly will wait while receiving no data on a download from a backend. If exceeded, for Delivery services, the response received so far will be considered complete and the fetch will end. For Compute services, timeout expiration is treated as a failure of the backend connection, and an error is generated. May be set at runtime using `bereq.between_bytes_timeout`.',
179 format => '',
180 read_only => 'false',
181 },
182 'client_cert' => {
183 datatype => 'string',
184 base_name => 'client_cert',
185 description => 'Unused.',
186 format => '',
187 read_only => 'false',
188 },
189 'comment' => {
190 datatype => 'string',
191 base_name => 'comment',
192 description => 'A freeform descriptive note.',
193 format => '',
194 read_only => 'false',
195 },
196 'connect_timeout' => {
197 datatype => 'int',
198 base_name => 'connect_timeout',
199 description => 'Maximum duration in milliseconds to wait for a connection to this backend to be established. If exceeded, the connection is aborted and a synthetic `503` response will be presented instead. May be set at runtime using `bereq.connect_timeout`.',
200 format => '',
201 read_only => 'false',
202 },
203 'first_byte_timeout' => {
204 datatype => 'int',
205 base_name => 'first_byte_timeout',
206 description => 'Maximum duration in milliseconds to wait for the server response to begin after a TCP connection is established and the request has been sent. If exceeded, the connection is aborted and a synthetic `503` response will be presented instead. May be set at runtime using `bereq.first_byte_timeout`.',
207 format => '',
208 read_only => 'false',
209 },
210 'fetch_timeout' => {
211 datatype => 'int',
212 base_name => 'fetch_timeout',
213 description => 'Maximum duration in milliseconds to wait for the entire response to be received after a TCP connection is established and the request has been sent. If exceeded, the connection is aborted and a synthetic `503` response will be presented instead. May be set at runtime using `bereq.fetch_timeout`.',
214 format => '',
215 read_only => 'false',
216 },
217 'healthcheck' => {
218 datatype => 'string',
219 base_name => 'healthcheck',
220 description => 'The name of the healthcheck to use with this backend.',
221 format => '',
222 read_only => 'false',
223 },
224 'hostname' => {
225 datatype => 'string',
226 base_name => 'hostname',
227 description => 'The hostname of the backend. May be used as an alternative to `address` to set the backend location.',
228 format => '',
229 read_only => 'false',
230 },
231 'iam_external_id' => {
232 datatype => 'string',
233 base_name => 'iam_external_id',
234 description => 'If the backend is using IAM authentication and the IAM system policy requires a matching external identifier, it should match this value. Your Fastly customer ID will be used if this attribute is not set.',
235 format => '',
236 read_only => 'false',
237 },
238 'iam_product' => {
239 datatype => 'string',
240 base_name => 'iam_product',
241 description => 'If the backend is using IAM authentication, the IAM signature will use this as the product element.',
242 format => '',
243 read_only => 'false',
244 },
245 'iam_region' => {
246 datatype => 'string',
247 base_name => 'iam_region',
248 description => 'If the backend is using IAM authentication, this region will be used for signing and access.',
249 format => '',
250 read_only => 'false',
251 },
252 'iam_role' => {
253 datatype => 'string',
254 base_name => 'iam_role',
255 description => 'If the backend is using IAM authentication, the fully qualified role string supplied by the storage vendor.',
256 format => '',
257 read_only => 'false',
258 },
259 'iam_vendor' => {
260 datatype => 'string',
261 base_name => 'iam_vendor',
262 description => 'A label that identifies the storage vendor. Providing a value in this field enables IAM usage, and all other IAM fields depend on its value.',
263 format => '',
264 read_only => 'false',
265 },
266 'ipv4' => {
267 datatype => 'string',
268 base_name => 'ipv4',
269 description => 'IPv4 address of the backend. May be used as an alternative to `address` to set the backend location.',
270 format => '',
271 read_only => 'false',
272 },
273 'ipv6' => {
274 datatype => 'string',
275 base_name => 'ipv6',
276 description => 'IPv6 address of the backend. May be used as an alternative to `address` to set the backend location.',
277 format => '',
278 read_only => 'false',
279 },
280 'keepalive_time' => {
281 datatype => 'int',
282 base_name => 'keepalive_time',
283 description => 'How long (in seconds) to keep a persistent connection to the backend between requests. By default, Fastly keeps connections open as long as it can.',
284 format => '',
285 read_only => 'false',
286 },
287 'max_conn' => {
288 datatype => 'int',
289 base_name => 'max_conn',
290 description => 'Maximum number of concurrent connections this backend will accept.',
291 format => '',
292 read_only => 'false',
293 },
294 'max_lifetime' => {
295 datatype => 'int',
296 base_name => 'max_lifetime',
297 description => 'Maximum time from creation (in milliseconds) that a pooled HTTP keepalive connection will be eligible for reuse; 0 is treated as unlimited.',
298 format => '',
299 read_only => 'false',
300 },
301 'max_tls_version' => {
302 datatype => 'string',
303 base_name => 'max_tls_version',
304 description => 'Maximum allowed TLS version on SSL connections to this backend. If your backend server is not able to negotiate a connection meeting this constraint, a synthetic `503` error response will be generated.',
305 format => '',
306 read_only => 'false',
307 },
308 'min_tls_version' => {
309 datatype => 'string',
310 base_name => 'min_tls_version',
311 description => 'Minimum allowed TLS version on SSL connections to this backend. If your backend server is not able to negotiate a connection meeting this constraint, a synthetic `503` error response will be generated.',
312 format => '',
313 read_only => 'false',
314 },
315 'max_use' => {
316 datatype => 'int',
317 base_name => 'max_use',
318 description => 'Maximum number of requests allowed over a single, pooled HTTP keepalive connection to this backend; 0 is treated as unlimited.',
319 format => '',
320 read_only => 'false',
321 },
322 'name' => {
323 datatype => 'string',
324 base_name => 'name',
325 description => 'The name of the backend.',
326 format => '',
327 read_only => 'false',
328 },
329 'override_host' => {
330 datatype => 'string',
331 base_name => 'override_host',
332 description => 'If set, will replace the client-supplied HTTP `Host` header on connections to this backend. Applied after VCL has been processed, so this setting will take precedence over changing `bereq.http.Host` in VCL.',
333 format => '',
334 read_only => 'false',
335 },
336 'port' => {
337 datatype => 'int',
338 base_name => 'port',
339 description => 'Port on which the backend server is listening for connections from Fastly. Setting `port` to 80 or 443 will also set `use_ssl` automatically (to false and true respectively), unless explicitly overridden by setting `use_ssl` in the same request.',
340 format => '',
341 read_only => 'false',
342 },
343 'prefer_ipv6' => {
344 datatype => 'boolean',
345 base_name => 'prefer_ipv6',
346 description => 'Prefer IPv6 connections to origins for hostname backends. Default is 'false' for Delivery services and 'true' for Compute services.',
347 format => '',
348 read_only => 'false',
349 },
350 'request_condition' => {
351 datatype => 'string',
352 base_name => 'request_condition',
353 description => 'Name of a Condition, which if satisfied, will select this backend during a request. If set, will override any `auto_loadbalance` setting. By default, the first backend added to a service is selected for all requests.',
354 format => '',
355 read_only => 'false',
356 },
357 'share_key' => {
358 datatype => 'string',
359 base_name => 'share_key',
360 description => 'Value that when shared across backends will enable those backends to share the same health check.',
361 format => '',
362 read_only => 'false',
363 },
364 'shield' => {
365 datatype => 'string',
366 base_name => 'shield',
367 description => 'Identifier of the POP to use as a [shield](https://www.fastly.com/documentation/guides/getting-started/hosts/shielding/).',
368 format => '',
369 read_only => 'false',
370 },
371 'ssl_ca_cert' => {
372 datatype => 'string',
373 base_name => 'ssl_ca_cert',
374 description => 'CA certificate attached to origin.',
375 format => '',
376 read_only => 'false',
377 },
378 'ssl_cert_hostname' => {
379 datatype => 'string',
380 base_name => 'ssl_cert_hostname',
381 description => 'Overrides `ssl_hostname`, but only for cert verification. Does not affect SNI at all.',
382 format => '',
383 read_only => 'false',
384 },
385 'ssl_check_cert' => {
386 datatype => 'boolean',
387 base_name => 'ssl_check_cert',
388 description => 'Be strict on checking SSL certs.',
389 format => '',
390 read_only => 'false',
391 },
392 'ssl_ciphers' => {
393 datatype => 'string',
394 base_name => 'ssl_ciphers',
395 description => 'List of [OpenSSL ciphers](https://www.openssl.org/docs/man1.1.1/man1/ciphers.html) to support for connections to this origin. If your backend server is not able to negotiate a connection meeting this constraint, a synthetic `503` error response will be generated.',
396 format => '',
397 read_only => 'false',
398 },
399 'ssl_client_cert' => {
400 datatype => 'string',
401 base_name => 'ssl_client_cert',
402 description => 'Client certificate attached to origin.',
403 format => '',
404 read_only => 'false',
405 },
406 'ssl_client_key' => {
407 datatype => 'string',
408 base_name => 'ssl_client_key',
409 description => 'Client key attached to origin.',
410 format => '',
411 read_only => 'false',
412 },
413 'ssl_hostname' => {
414 datatype => 'string',
415 base_name => 'ssl_hostname',
416 description => 'Use `ssl_cert_hostname` and `ssl_sni_hostname` to configure certificate validation.',
417 format => '',
418 read_only => 'false',
419 },
420 'ssl_sni_hostname' => {
421 datatype => 'string',
422 base_name => 'ssl_sni_hostname',
423 description => 'Overrides `ssl_hostname`, but only for SNI in the handshake. Does not affect cert validation at all.',
424 format => '',
425 read_only => 'false',
426 },
427 'tcp_keepalive_enable' => {
428 datatype => 'boolean',
429 base_name => 'tcp_keepalive_enable',
430 description => 'Whether to enable TCP keepalives for backend connections. Varnish defaults to using keepalives if this is unspecified.',
431 format => '',
432 read_only => 'false',
433 },
434 'tcp_keepalive_interval' => {
435 datatype => 'int',
436 base_name => 'tcp_keepalive_interval',
437 description => 'Interval in seconds between subsequent keepalive probes.',
438 format => '',
439 read_only => 'false',
440 },
441 'tcp_keepalive_probes' => {
442 datatype => 'int',
443 base_name => 'tcp_keepalive_probes',
444 description => 'Number of unacknowledged probes to send before considering the connection dead.',
445 format => '',
446 read_only => 'false',
447 },
448 'tcp_keepalive_time' => {
449 datatype => 'int',
450 base_name => 'tcp_keepalive_time',
451 description => 'Interval in seconds between the last data packet sent and the first keepalive probe.',
452 format => '',
453 read_only => 'false',
454 },
455 'use_ssl' => {
456 datatype => 'boolean',
457 base_name => 'use_ssl',
458 description => 'Whether or not to require TLS for connections to this backend.',
459 format => '',
460 read_only => 'false',
461 },
462 'weight' => {
463 datatype => 'int',
464 base_name => 'weight',
465 description => 'Weight used to load balance this backend against others. May be any positive integer. If `auto_loadbalance` is true, the chance of this backend being selected is equal to its own weight over the sum of all weights for backends that have `auto_loadbalance` set to true.',
466 format => '',
467 read_only => 'false',
468 },
469 });
470  
471 __PACKAGE__->openapi_types( {
472 'address' => 'string',
473 'auto_loadbalance' => 'boolean',
474 'between_bytes_timeout' => 'int',
475 'client_cert' => 'string',
476 'comment' => 'string',
477 'connect_timeout' => 'int',
478 'first_byte_timeout' => 'int',
479 'fetch_timeout' => 'int',
480 'healthcheck' => 'string',
481 'hostname' => 'string',
482 'iam_external_id' => 'string',
483 'iam_product' => 'string',
484 'iam_region' => 'string',
485 'iam_role' => 'string',
486 'iam_vendor' => 'string',
487 'ipv4' => 'string',
488 'ipv6' => 'string',
489 'keepalive_time' => 'int',
490 'max_conn' => 'int',
491 'max_lifetime' => 'int',
492 'max_tls_version' => 'string',
493 'min_tls_version' => 'string',
494 'max_use' => 'int',
495 'name' => 'string',
496 'override_host' => 'string',
497 'port' => 'int',
498 'prefer_ipv6' => 'boolean',
499 'request_condition' => 'string',
500 'share_key' => 'string',
501 'shield' => 'string',
502 'ssl_ca_cert' => 'string',
503 'ssl_cert_hostname' => 'string',
504 'ssl_check_cert' => 'boolean',
505 'ssl_ciphers' => 'string',
506 'ssl_client_cert' => 'string',
507 'ssl_client_key' => 'string',
508 'ssl_hostname' => 'string',
509 'ssl_sni_hostname' => 'string',
510 'tcp_keepalive_enable' => 'boolean',
511 'tcp_keepalive_interval' => 'int',
512 'tcp_keepalive_probes' => 'int',
513 'tcp_keepalive_time' => 'int',
514 'use_ssl' => 'boolean',
515 'weight' => 'int'
516 } );
517  
518 __PACKAGE__->attribute_map( {
519 'address' => 'address',
520 'auto_loadbalance' => 'auto_loadbalance',
521 'between_bytes_timeout' => 'between_bytes_timeout',
522 'client_cert' => 'client_cert',
523 'comment' => 'comment',
524 'connect_timeout' => 'connect_timeout',
525 'first_byte_timeout' => 'first_byte_timeout',
526 'fetch_timeout' => 'fetch_timeout',
527 'healthcheck' => 'healthcheck',
528 'hostname' => 'hostname',
529 'iam_external_id' => 'iam_external_id',
530 'iam_product' => 'iam_product',
531 'iam_region' => 'iam_region',
532 'iam_role' => 'iam_role',
533 'iam_vendor' => 'iam_vendor',
534 'ipv4' => 'ipv4',
535 'ipv6' => 'ipv6',
536 'keepalive_time' => 'keepalive_time',
537 'max_conn' => 'max_conn',
538 'max_lifetime' => 'max_lifetime',
539 'max_tls_version' => 'max_tls_version',
540 'min_tls_version' => 'min_tls_version',
541 'max_use' => 'max_use',
542 'name' => 'name',
543 'override_host' => 'override_host',
544 'port' => 'port',
545 'prefer_ipv6' => 'prefer_ipv6',
546 'request_condition' => 'request_condition',
547 'share_key' => 'share_key',
548 'shield' => 'shield',
549 'ssl_ca_cert' => 'ssl_ca_cert',
550 'ssl_cert_hostname' => 'ssl_cert_hostname',
551 'ssl_check_cert' => 'ssl_check_cert',
552 'ssl_ciphers' => 'ssl_ciphers',
553 'ssl_client_cert' => 'ssl_client_cert',
554 'ssl_client_key' => 'ssl_client_key',
555 'ssl_hostname' => 'ssl_hostname',
556 'ssl_sni_hostname' => 'ssl_sni_hostname',
557 'tcp_keepalive_enable' => 'tcp_keepalive_enable',
558 'tcp_keepalive_interval' => 'tcp_keepalive_interval',
559 'tcp_keepalive_probes' => 'tcp_keepalive_probes',
560 'tcp_keepalive_time' => 'tcp_keepalive_time',
561 'use_ssl' => 'use_ssl',
562 'weight' => 'weight'
563 } );
564  
565 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
566  
567 __PACKAGE__->openapi_nullable( {
568 'client_cert' => 'true',
569 'comment' => 'true',
570 'healthcheck' => 'true',
571 'hostname' => 'true',
572 'iam_external_id' => 'true',
573 'iam_product' => 'true',
574 'iam_region' => 'true',
575 'iam_role' => 'true',
576 'iam_vendor' => 'true',
577 'ipv4' => 'true',
578 'ipv6' => 'true',
579 'keepalive_time' => 'true',
580 'max_lifetime' => 'true',
581 'max_tls_version' => 'true',
582 'min_tls_version' => 'true',
583 'max_use' => 'true',
584 'override_host' => 'true',
585 'share_key' => 'true',
586 'shield' => 'true',
587 'ssl_ca_cert' => 'true',
588 'ssl_cert_hostname' => 'true',
589 'ssl_check_cert' => 'true',
590 'ssl_ciphers' => 'true',
591 'ssl_client_cert' => 'true',
592 'ssl_client_key' => 'true',
593 'ssl_hostname' => 'true',
594 'ssl_sni_hostname' => 'true',
595 'tcp_keepalive_enable' => 'true',
596 'tcp_keepalive_interval' => 'true',
597 'tcp_keepalive_probes' => 'true',
598 'tcp_keepalive_time' => 'true',
599 } );
600  
601  
602 1;