Fastly/Object/VersionDetail.pm untested

filter: Statementstmt 0.0% 0 / 142 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 30 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 198 CC 7 SCAR 17.9
CC
7
Cov
0%
from_hash
20.0
_deserialize
20.0
new
2.0
CRAP 6.0
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::VersionDetail;
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::GzipResponse;
37 use WebService::Fastly::Object::HeaderResponse;
38 use WebService::Fastly::Object::HealthcheckResponse;
39 use WebService::Fastly::Object::RequestSettingsResponse;
40 use WebService::Fastly::Object::ResponseObjectResponse;
41 use WebService::Fastly::Object::SchemasSnippetResponse;
42 use WebService::Fastly::Object::SchemasVclResponse;
43 use WebService::Fastly::Object::VersionDetailSettings;
44  
45 use base ("Class::Accessor", "Class::Data::Inheritable");
46  
47 #
48 #
49 #
50 # NOTE: This class is auto generated. Do not edit the class manually.
51 #
52  
53 =begin comment
54  
55 Fastly API
56  
57 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/)
58  
59 The version of the API Spec document: 1.0.0
60 Contact: oss@fastly.com
61  
62 =end comment
63  
64 =cut
65  
66 #
67 # NOTE: This class is auto generated.
68 # Do not edit the class manually.
69 #
70 __PACKAGE__->mk_classdata('attribute_map' => {});
71 __PACKAGE__->mk_classdata('openapi_types' => {});
72 __PACKAGE__->mk_classdata('method_documentation' => {});
73 __PACKAGE__->mk_classdata('class_documentation' => {});
74 __PACKAGE__->mk_classdata('openapi_nullable' => {});
75  
76 # new plain object
77 sub new {
78 my ($class, %args) = @_;
79  
80 my $self = bless {}, $class;
81  
82 $self->init(%args);
83  
84 return $self;
85 }
86  
87 # initialize the object
88 sub init
89 {
90 my ($self, %args) = @_;
91  
92 foreach my $attribute (keys %{$self->attribute_map}) {
93 my $args_key = $self->attribute_map->{$attribute};
94 $self->$attribute( $args{ $args_key } );
95 }
96 }
97  
98 # return perl hash
99 sub to_hash {
100 my $self = shift;
101 my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
102  
103 return $_hash;
104 }
105  
106 # used by JSON for serialization
107 sub TO_JSON {
108 my $self = shift;
109 my $_data = {};
110 foreach my $_key (keys %{$self->attribute_map}) {
111 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
112 }
113  
114 return $_data;
115 }
116  
117 # from Perl hashref
118 sub from_hash {
119 my ($self, $hash) = @_;
120  
121 # loop through attributes and use openapi_types to deserialize the data
122 while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
123 my $_json_attribute = $self->attribute_map->{$_key};
124 my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true';
125 if ($_type =~ /^array\[(.+)\]$/i) { # array
126 my $_subclass = $1;
127 my @_array = ();
128 foreach my $_element (@{$hash->{$_json_attribute}}) {
129 push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable);
130 }
131 $self->{$_key} = \@_array;
132 } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
133 my $_subclass = $1;
134 my %_hash = ();
135 while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
136 $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable);
137 }
138 $self->{$_key} = \%_hash;
139 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
140 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable);
141 } else {
142 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
143 }
144 }
145  
146 return $self;
147 }
148  
149 # deserialize non-array data
150 sub _deserialize {
151 my ($self, $type, $data, $is_nullable) = @_;
152 $log->debugf("deserializing %s with %s",Dumper($data), $type);
153  
154 if (!(defined $data) && $is_nullable) {
155 return undef;
156 }
157 if ($type eq 'DateTime') {
158 return DateTime->from_epoch(epoch => str2time($data));
159 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
160 return $data;
161 } else { # hash(model)
162 my $_instance = eval "WebService::Fastly::Object::$type->new()";
163 return $_instance->from_hash($data);
164 }
165 }
166  
167  
168 __PACKAGE__->class_documentation({description => '',
169 class => 'VersionDetail',
170 required => [], # TODO
171 } );
172  
173 __PACKAGE__->method_documentation({
174 'backends' => {
175 datatype => 'ARRAY[BackendResponse]',
176 base_name => 'backends',
177 description => 'List of backends associated to this service.',
178 format => '',
179 read_only => 'false',
180 },
181 'cache_settings' => {
182 datatype => 'ARRAY[CacheSettingResponse]',
183 base_name => 'cache_settings',
184 description => 'List of cache settings associated to this service.',
185 format => '',
186 read_only => 'false',
187 },
188 'conditions' => {
189 datatype => 'ARRAY[ConditionResponse]',
190 base_name => 'conditions',
191 description => 'List of conditions associated to this service.',
192 format => '',
193 read_only => 'false',
194 },
195 'directors' => {
196 datatype => 'ARRAY[Director]',
197 base_name => 'directors',
198 description => 'List of directors associated to this service.',
199 format => '',
200 read_only => 'false',
201 },
202 'domains' => {
203 datatype => 'ARRAY[DomainResponse]',
204 base_name => 'domains',
205 description => 'List of domains associated to this service.',
206 format => '',
207 read_only => 'false',
208 },
209 'gzips' => {
210 datatype => 'ARRAY[GzipResponse]',
211 base_name => 'gzips',
212 description => 'List of gzip rules associated to this service.',
213 format => '',
214 read_only => 'false',
215 },
216 'headers' => {
217 datatype => 'ARRAY[HeaderResponse]',
218 base_name => 'headers',
219 description => 'List of headers associated to this service.',
220 format => '',
221 read_only => 'false',
222 },
223 'healthchecks' => {
224 datatype => 'ARRAY[HealthcheckResponse]',
225 base_name => 'healthchecks',
226 description => 'List of healthchecks associated to this service.',
227 format => '',
228 read_only => 'false',
229 },
230 'request_settings' => {
231 datatype => 'ARRAY[RequestSettingsResponse]',
232 base_name => 'request_settings',
233 description => 'List of request settings for this service.',
234 format => '',
235 read_only => 'false',
236 },
237 'response_objects' => {
238 datatype => 'ARRAY[ResponseObjectResponse]',
239 base_name => 'response_objects',
240 description => 'List of response objects for this service.',
241 format => '',
242 read_only => 'false',
243 },
244 'settings' => {
245 datatype => 'VersionDetailSettings',
246 base_name => 'settings',
247 description => '',
248 format => '',
249 read_only => 'false',
250 },
251 'snippets' => {
252 datatype => 'ARRAY[SchemasSnippetResponse]',
253 base_name => 'snippets',
254 description => 'List of VCL snippets for this service.',
255 format => '',
256 read_only => 'false',
257 },
258 'vcls' => {
259 datatype => 'ARRAY[SchemasVclResponse]',
260 base_name => 'vcls',
261 description => 'List of VCL files for this service.',
262 format => '',
263 read_only => 'false',
264 },
265 'wordpress' => {
266 datatype => 'ARRAY[object]',
267 base_name => 'wordpress',
268 description => 'A list of Wordpress rules with this service.',
269 format => '',
270 read_only => 'false',
271 },
272 });
273  
274 __PACKAGE__->openapi_types( {
275 'backends' => 'ARRAY[BackendResponse]',
276 'cache_settings' => 'ARRAY[CacheSettingResponse]',
277 'conditions' => 'ARRAY[ConditionResponse]',
278 'directors' => 'ARRAY[Director]',
279 'domains' => 'ARRAY[DomainResponse]',
280 'gzips' => 'ARRAY[GzipResponse]',
281 'headers' => 'ARRAY[HeaderResponse]',
282 'healthchecks' => 'ARRAY[HealthcheckResponse]',
283 'request_settings' => 'ARRAY[RequestSettingsResponse]',
284 'response_objects' => 'ARRAY[ResponseObjectResponse]',
285 'settings' => 'VersionDetailSettings',
286 'snippets' => 'ARRAY[SchemasSnippetResponse]',
287 'vcls' => 'ARRAY[SchemasVclResponse]',
288 'wordpress' => 'ARRAY[object]'
289 } );
290  
291 __PACKAGE__->attribute_map( {
292 'backends' => 'backends',
293 'cache_settings' => 'cache_settings',
294 'conditions' => 'conditions',
295 'directors' => 'directors',
296 'domains' => 'domains',
297 'gzips' => 'gzips',
298 'headers' => 'headers',
299 'healthchecks' => 'healthchecks',
300 'request_settings' => 'request_settings',
301 'response_objects' => 'response_objects',
302 'settings' => 'settings',
303 'snippets' => 'snippets',
304 'vcls' => 'vcls',
305 'wordpress' => 'wordpress'
306 } );
307  
308 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
309  
310 __PACKAGE__->openapi_nullable( {
311 } );
312  
313  
314 1;