Fastly/Object/HealthcheckResponse.pm untested

filter: Statementstmt 0.0% 0 / 113 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 20 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 159 CC 7 SCAR 20.2
CC
7
Cov
0%
from_hash
20.0
_deserialize
20.0
new
2.0
CRAP 7.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::Object::HealthcheckResponse;
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 use WebService::Fastly::Object::Healthcheck;
32 use WebService::Fastly::Object::ServiceIdAndVersion;
33 use WebService::Fastly::Object::Timestamps;
34  
35 use base ("Class::Accessor", "Class::Data::Inheritable");
36  
37 #
38 #
39 #
40 # NOTE: This class is auto generated. Do not edit the class manually.
41 #
42  
43 =begin comment
44  
45 Fastly API
46  
47 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/)
48  
49 The version of the API Spec document: 1.0.0
50 Contact: oss@fastly.com
51  
52 =end comment
53  
54 =cut
55  
56 #
57 # NOTE: This class is auto generated.
58 # Do not edit the class manually.
59 #
60 __PACKAGE__->mk_classdata('attribute_map' => {});
61 __PACKAGE__->mk_classdata('openapi_types' => {});
62 __PACKAGE__->mk_classdata('method_documentation' => {});
63 __PACKAGE__->mk_classdata('class_documentation' => {});
64 __PACKAGE__->mk_classdata('openapi_nullable' => {});
65  
66 # new plain object
67 sub new {
68 my ($class, %args) = @_;
69  
70 my $self = bless {}, $class;
71  
72 $self->init(%args);
73  
74 return $self;
75 }
76  
77 # initialize the object
78 sub init
79 {
80 my ($self, %args) = @_;
81  
82 foreach my $attribute (keys %{$self->attribute_map}) {
83 my $args_key = $self->attribute_map->{$attribute};
84 $self->$attribute( $args{ $args_key } );
85 }
86 }
87  
88 # return perl hash
89 sub to_hash {
90 my $self = shift;
91 my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
92  
93 return $_hash;
94 }
95  
96 # used by JSON for serialization
97 sub TO_JSON {
98 my $self = shift;
99 my $_data = {};
100 foreach my $_key (keys %{$self->attribute_map}) {
101 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
102 }
103  
104 return $_data;
105 }
106  
107 # from Perl hashref
108 sub from_hash {
109 my ($self, $hash) = @_;
110  
111 # loop through attributes and use openapi_types to deserialize the data
112 while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
113 my $_json_attribute = $self->attribute_map->{$_key};
114 my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true';
115 if ($_type =~ /^array\[(.+)\]$/i) { # array
116 my $_subclass = $1;
117 my @_array = ();
118 foreach my $_element (@{$hash->{$_json_attribute}}) {
119 push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable);
120 }
121 $self->{$_key} = \@_array;
122 } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
123 my $_subclass = $1;
124 my %_hash = ();
125 while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
126 $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable);
127 }
128 $self->{$_key} = \%_hash;
129 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
130 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable);
131 } else {
132 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
133 }
134 }
135  
136 return $self;
137 }
138  
139 # deserialize non-array data
140 sub _deserialize {
141 my ($self, $type, $data, $is_nullable) = @_;
142 $log->debugf("deserializing %s with %s",Dumper($data), $type);
143  
144 if (!(defined $data) && $is_nullable) {
145 return undef;
146 }
147 if ($type eq 'DateTime') {
148 return DateTime->from_epoch(epoch => str2time($data));
149 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
150 return $data;
151 } else { # hash(model)
152 my $_instance = eval "WebService::Fastly::Object::$type->new()";
153 return $_instance->from_hash($data);
154 }
155 }
156  
157  
158 __PACKAGE__->class_documentation({description => '',
159 class => 'HealthcheckResponse',
160 required => [], # TODO
161 } );
162  
163 __PACKAGE__->method_documentation({
164 'check_interval' => {
165 datatype => 'int',
166 base_name => 'check_interval',
167 description => 'How often to run the health check in milliseconds. Minimum 1 second, maximum 1 hour.',
168 format => '',
169 read_only => 'false',
170 },
171 'comment' => {
172 datatype => 'string',
173 base_name => 'comment',
174 description => 'A freeform descriptive note.',
175 format => '',
176 read_only => 'false',
177 },
178 'expected_response' => {
179 datatype => 'int',
180 base_name => 'expected_response',
181 description => 'The status code expected from the host.',
182 format => '',
183 read_only => 'false',
184 },
185 'headers' => {
186 datatype => 'ARRAY[string]',
187 base_name => 'headers',
188 description => 'Array of custom headers that will be added to the health check probes.',
189 format => '',
190 read_only => 'false',
191 },
192 'host' => {
193 datatype => 'string',
194 base_name => 'host',
195 description => 'Which host to check.',
196 format => '',
197 read_only => 'false',
198 },
199 'http_version' => {
200 datatype => 'string',
201 base_name => 'http_version',
202 description => 'Whether to use version 1.0 or 1.1 HTTP.',
203 format => '',
204 read_only => 'false',
205 },
206 'initial' => {
207 datatype => 'int',
208 base_name => 'initial',
209 description => 'When loading a config, the initial number of probes to be seen as OK.',
210 format => '',
211 read_only => 'false',
212 },
213 'method' => {
214 datatype => 'string',
215 base_name => 'method',
216 description => 'Which HTTP method to use.',
217 format => '',
218 read_only => 'false',
219 },
220 'name' => {
221 datatype => 'string',
222 base_name => 'name',
223 description => 'The name of the health check.',
224 format => '',
225 read_only => 'false',
226 },
227 'path' => {
228 datatype => 'string',
229 base_name => 'path',
230 description => 'The path to check.',
231 format => '',
232 read_only => 'false',
233 },
234 'threshold' => {
235 datatype => 'int',
236 base_name => 'threshold',
237 description => 'How many health checks must succeed to be considered healthy.',
238 format => '',
239 read_only => 'false',
240 },
241 'timeout' => {
242 datatype => 'int',
243 base_name => 'timeout',
244 description => 'Timeout in milliseconds.',
245 format => '',
246 read_only => 'false',
247 },
248 'window' => {
249 datatype => 'int',
250 base_name => 'window',
251 description => 'The number of most recent health check queries to keep for this health check.',
252 format => '',
253 read_only => 'false',
254 },
255 'service_id' => {
256 datatype => 'string',
257 base_name => 'service_id',
258 description => '',
259 format => '',
260 read_only => 'true',
261 },
262 'version' => {
263 datatype => 'int',
264 base_name => 'version',
265 description => '',
266 format => '',
267 read_only => 'true',
268 },
269 'created_at' => {
270 datatype => 'DateTime',
271 base_name => 'created_at',
272 description => 'Date and time in ISO 8601 format.',
273 format => 'date-time',
274 read_only => 'true',
275 },
276 'deleted_at' => {
277 datatype => 'DateTime',
278 base_name => 'deleted_at',
279 description => 'Date and time in ISO 8601 format.',
280 format => 'date-time',
281 read_only => 'true',
282 },
283 'updated_at' => {
284 datatype => 'DateTime',
285 base_name => 'updated_at',
286 description => 'Date and time in ISO 8601 format.',
287 format => 'date-time',
288 read_only => 'true',
289 },
290 });
291  
292 __PACKAGE__->openapi_types( {
293 'check_interval' => 'int',
294 'comment' => 'string',
295 'expected_response' => 'int',
296 'headers' => 'ARRAY[string]',
297 'host' => 'string',
298 'http_version' => 'string',
299 'initial' => 'int',
300 'method' => 'string',
301 'name' => 'string',
302 'path' => 'string',
303 'threshold' => 'int',
304 'timeout' => 'int',
305 'window' => 'int',
306 'service_id' => 'string',
307 'version' => 'int',
308 'created_at' => 'DateTime',
309 'deleted_at' => 'DateTime',
310 'updated_at' => 'DateTime'
311 } );
312  
313 __PACKAGE__->attribute_map( {
314 'check_interval' => 'check_interval',
315 'comment' => 'comment',
316 'expected_response' => 'expected_response',
317 'headers' => 'headers',
318 'host' => 'host',
319 'http_version' => 'http_version',
320 'initial' => 'initial',
321 'method' => 'method',
322 'name' => 'name',
323 'path' => 'path',
324 'threshold' => 'threshold',
325 'timeout' => 'timeout',
326 'window' => 'window',
327 'service_id' => 'service_id',
328 'version' => 'version',
329 'created_at' => 'created_at',
330 'deleted_at' => 'deleted_at',
331 'updated_at' => 'updated_at'
332 } );
333  
334 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
335  
336 __PACKAGE__->openapi_nullable( {
337 'comment' => 'true',
338 'created_at' => 'true',
339 'deleted_at' => 'true',
340 'updated_at' => 'true',
341 } );
342  
343  
344 1;