Fastly/Object/ServiceVersionDetailOrNull.pm untested

filter: Statementstmt 0.0% 0 / 152 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 33 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 211 CC 7 SCAR 17.4
CC
7
Cov
0%
from_hash
20.0
_deserialize
20.0
new
2.0
CRAP 5.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::Object::ServiceVersionDetailOrNull;
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::BackendResponse;
32 use WebService::Fastly::Object::CacheSettingResponse;
33 use WebService::Fastly::Object::ConditionResponse;
34 use WebService::Fastly::Object::Director;
35 use WebService::Fastly::Object::DomainResponse;
36 use WebService::Fastly::Object::Environment;
37 use WebService::Fastly::Object::GzipResponse;
38 use WebService::Fastly::Object::HeaderResponse;
39 use WebService::Fastly::Object::HealthcheckResponse;
40 use WebService::Fastly::Object::RequestSettingsResponse;
41 use WebService::Fastly::Object::ResponseObjectResponse;
42 use WebService::Fastly::Object::SchemasSnippetResponse;
43 use WebService::Fastly::Object::SchemasVclResponse;
44 use WebService::Fastly::Object::SchemasVersionResponse;
45 use WebService::Fastly::Object::VersionDetail;
46 use WebService::Fastly::Object::VersionDetailSettings;
47  
48 use base ("Class::Accessor", "Class::Data::Inheritable");
49  
50 #
51 #
52 #
53 # NOTE: This class is auto generated. Do not edit the class manually.
54 #
55  
56 =begin comment
57  
58 Fastly API
59  
60 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/)
61  
62 The version of the API Spec document: 1.0.0
63 Contact: oss@fastly.com
64  
65 =end comment
66  
67 =cut
68  
69 #
70 # NOTE: This class is auto generated.
71 # Do not edit the class manually.
72 #
73 __PACKAGE__->mk_classdata('attribute_map' => {});
74 __PACKAGE__->mk_classdata('openapi_types' => {});
75 __PACKAGE__->mk_classdata('method_documentation' => {});
76 __PACKAGE__->mk_classdata('class_documentation' => {});
77 __PACKAGE__->mk_classdata('openapi_nullable' => {});
78  
79 # new plain object
80 sub new {
81 my ($class, %args) = @_;
82  
83 my $self = bless {}, $class;
84  
85 $self->init(%args);
86  
87 return $self;
88 }
89  
90 # initialize the object
91 sub init
92 {
93 my ($self, %args) = @_;
94  
95 foreach my $attribute (keys %{$self->attribute_map}) {
96 my $args_key = $self->attribute_map->{$attribute};
97 $self->$attribute( $args{ $args_key } );
98 }
99 }
100  
101 # return perl hash
102 sub to_hash {
103 my $self = shift;
104 my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
105  
106 return $_hash;
107 }
108  
109 # used by JSON for serialization
110 sub TO_JSON {
111 my $self = shift;
112 my $_data = {};
113 foreach my $_key (keys %{$self->attribute_map}) {
114 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
115 }
116  
117 return $_data;
118 }
119  
120 # from Perl hashref
121 sub from_hash {
122 my ($self, $hash) = @_;
123  
124 # loop through attributes and use openapi_types to deserialize the data
125 while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
126 my $_json_attribute = $self->attribute_map->{$_key};
127 my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true';
128 if ($_type =~ /^array\[(.+)\]$/i) { # array
129 my $_subclass = $1;
130 my @_array = ();
131 foreach my $_element (@{$hash->{$_json_attribute}}) {
132 push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable);
133 }
134 $self->{$_key} = \@_array;
135 } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
136 my $_subclass = $1;
137 my %_hash = ();
138 while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
139 $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable);
140 }
141 $self->{$_key} = \%_hash;
142 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
143 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable);
144 } else {
145 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
146 }
147 }
148  
149 return $self;
150 }
151  
152 # deserialize non-array data
153 sub _deserialize {
154 my ($self, $type, $data, $is_nullable) = @_;
155 $log->debugf("deserializing %s with %s",Dumper($data), $type);
156  
157 if (!(defined $data) && $is_nullable) {
158 return undef;
159 }
160 if ($type eq 'DateTime') {
161 return DateTime->from_epoch(epoch => str2time($data));
162 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
163 return $data;
164 } else { # hash(model)
165 my $_instance = eval "WebService::Fastly::Object::$type->new()";
166 return $_instance->from_hash($data);
167 }
168 }
169  
170  
171 __PACKAGE__->class_documentation({description => '',
172 class => 'ServiceVersionDetailOrNull',
173 required => [], # TODO
174 } );
175  
176 __PACKAGE__->method_documentation({
177 'active' => {
178 datatype => 'boolean',
179 base_name => 'active',
180 description => 'Whether this is the active version or not.',
181 format => '',
182 read_only => 'false',
183 },
184 'comment' => {
185 datatype => 'string',
186 base_name => 'comment',
187 description => 'A freeform descriptive note.',
188 format => '',
189 read_only => 'false',
190 },
191 'deployed' => {
192 datatype => 'boolean',
193 base_name => 'deployed',
194 description => 'Unused at this time.',
195 format => '',
196 read_only => 'false',
197 },
198 'locked' => {
199 datatype => 'boolean',
200 base_name => 'locked',
201 description => 'Whether this version is locked or not. Objects can not be added or edited on locked versions.',
202 format => '',
203 read_only => 'false',
204 },
205 'number' => {
206 datatype => 'int',
207 base_name => 'number',
208 description => 'The number of this version.',
209 format => '',
210 read_only => 'true',
211 },
212 'staging' => {
213 datatype => 'boolean',
214 base_name => 'staging',
215 description => 'Unused at this time.',
216 format => '',
217 read_only => 'false',
218 },
219 'testing' => {
220 datatype => 'boolean',
221 base_name => 'testing',
222 description => 'Unused at this time.',
223 format => '',
224 read_only => 'false',
225 },
226 'created_at' => {
227 datatype => 'DateTime',
228 base_name => 'created_at',
229 description => 'Date and time in ISO 8601 format.',
230 format => 'date-time',
231 read_only => 'true',
232 },
233 'deleted_at' => {
234 datatype => 'DateTime',
235 base_name => 'deleted_at',
236 description => 'Date and time in ISO 8601 format.',
237 format => 'date-time',
238 read_only => 'true',
239 },
240 'updated_at' => {
241 datatype => 'DateTime',
242 base_name => 'updated_at',
243 description => 'Date and time in ISO 8601 format.',
244 format => 'date-time',
245 read_only => 'true',
246 },
247 'service_id' => {
248 datatype => 'string',
249 base_name => 'service_id',
250 description => '',
251 format => '',
252 read_only => 'true',
253 },
254 'environments' => {
255 datatype => 'ARRAY[Environment]',
256 base_name => 'environments',
257 description => 'A list of environments where the service has been deployed.',
258 format => '',
259 read_only => 'false',
260 },
261 'backends' => {
262 datatype => 'ARRAY[BackendResponse]',
263 base_name => 'backends',
264 description => 'List of backends associated to this service.',
265 format => '',
266 read_only => 'false',
267 },
268 'cache_settings' => {
269 datatype => 'ARRAY[CacheSettingResponse]',
270 base_name => 'cache_settings',
271 description => 'List of cache settings associated to this service.',
272 format => '',
273 read_only => 'false',
274 },
275 'conditions' => {
276 datatype => 'ARRAY[ConditionResponse]',
277 base_name => 'conditions',
278 description => 'List of conditions associated to this service.',
279 format => '',
280 read_only => 'false',
281 },
282 'directors' => {
283 datatype => 'ARRAY[Director]',
284 base_name => 'directors',
285 description => 'List of directors associated to this service.',
286 format => '',
287 read_only => 'false',
288 },
289 'domains' => {
290 datatype => 'ARRAY[DomainResponse]',
291 base_name => 'domains',
292 description => 'List of domains associated to this service.',
293 format => '',
294 read_only => 'false',
295 },
296 'gzips' => {
297 datatype => 'ARRAY[GzipResponse]',
298 base_name => 'gzips',
299 description => 'List of gzip rules associated to this service.',
300 format => '',
301 read_only => 'false',
302 },
303 'headers' => {
304 datatype => 'ARRAY[HeaderResponse]',
305 base_name => 'headers',
306 description => 'List of headers associated to this service.',
307 format => '',
308 read_only => 'false',
309 },
310 'healthchecks' => {
311 datatype => 'ARRAY[HealthcheckResponse]',
312 base_name => 'healthchecks',
313 description => 'List of healthchecks associated to this service.',
314 format => '',
315 read_only => 'false',
316 },
317 'request_settings' => {
318 datatype => 'ARRAY[RequestSettingsResponse]',
319 base_name => 'request_settings',
320 description => 'List of request settings for this service.',
321 format => '',
322 read_only => 'false',
323 },
324 'response_objects' => {
325 datatype => 'ARRAY[ResponseObjectResponse]',
326 base_name => 'response_objects',
327 description => 'List of response objects for this service.',
328 format => '',
329 read_only => 'false',
330 },
331 'settings' => {
332 datatype => 'VersionDetailSettings',
333 base_name => 'settings',
334 description => '',
335 format => '',
336 read_only => 'false',
337 },
338 'snippets' => {
339 datatype => 'ARRAY[SchemasSnippetResponse]',
340 base_name => 'snippets',
341 description => 'List of VCL snippets for this service.',
342 format => '',
343 read_only => 'false',
344 },
345 'vcls' => {
346 datatype => 'ARRAY[SchemasVclResponse]',
347 base_name => 'vcls',
348 description => 'List of VCL files for this service.',
349 format => '',
350 read_only => 'false',
351 },
352 'wordpress' => {
353 datatype => 'ARRAY[object]',
354 base_name => 'wordpress',
355 description => 'A list of Wordpress rules with this service.',
356 format => '',
357 read_only => 'false',
358 },
359 });
360  
361 __PACKAGE__->openapi_types( {
362 'active' => 'boolean',
363 'comment' => 'string',
364 'deployed' => 'boolean',
365 'locked' => 'boolean',
366 'number' => 'int',
367 'staging' => 'boolean',
368 'testing' => 'boolean',
369 'created_at' => 'DateTime',
370 'deleted_at' => 'DateTime',
371 'updated_at' => 'DateTime',
372 'service_id' => 'string',
373 'environments' => 'ARRAY[Environment]',
374 'backends' => 'ARRAY[BackendResponse]',
375 'cache_settings' => 'ARRAY[CacheSettingResponse]',
376 'conditions' => 'ARRAY[ConditionResponse]',
377 'directors' => 'ARRAY[Director]',
378 'domains' => 'ARRAY[DomainResponse]',
379 'gzips' => 'ARRAY[GzipResponse]',
380 'headers' => 'ARRAY[HeaderResponse]',
381 'healthchecks' => 'ARRAY[HealthcheckResponse]',
382 'request_settings' => 'ARRAY[RequestSettingsResponse]',
383 'response_objects' => 'ARRAY[ResponseObjectResponse]',
384 'settings' => 'VersionDetailSettings',
385 'snippets' => 'ARRAY[SchemasSnippetResponse]',
386 'vcls' => 'ARRAY[SchemasVclResponse]',
387 'wordpress' => 'ARRAY[object]'
388 } );
389  
390 __PACKAGE__->attribute_map( {
391 'active' => 'active',
392 'comment' => 'comment',
393 'deployed' => 'deployed',
394 'locked' => 'locked',
395 'number' => 'number',
396 'staging' => 'staging',
397 'testing' => 'testing',
398 'created_at' => 'created_at',
399 'deleted_at' => 'deleted_at',
400 'updated_at' => 'updated_at',
401 'service_id' => 'service_id',
402 'environments' => 'environments',
403 'backends' => 'backends',
404 'cache_settings' => 'cache_settings',
405 'conditions' => 'conditions',
406 'directors' => 'directors',
407 'domains' => 'domains',
408 'gzips' => 'gzips',
409 'headers' => 'headers',
410 'healthchecks' => 'healthchecks',
411 'request_settings' => 'request_settings',
412 'response_objects' => 'response_objects',
413 'settings' => 'settings',
414 'snippets' => 'snippets',
415 'vcls' => 'vcls',
416 'wordpress' => 'wordpress'
417 } );
418  
419 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
420  
421 __PACKAGE__->openapi_nullable( {
422 'comment' => 'true',
423 'created_at' => 'true',
424 'deleted_at' => 'true',
425 'updated_at' => 'true',
426 } );
427  
428  
429 1;