Fastly/Object/HeaderResponse.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::HeaderResponse;
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::Header;
32 use WebService::Fastly::Object::ServiceIdAndVersionString;
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 => 'HeaderResponse',
160 required => [], # TODO
161 } );
162  
163 __PACKAGE__->method_documentation({
164 'action' => {
165 datatype => 'string',
166 base_name => 'action',
167 description => 'Accepts a string value.',
168 format => '',
169 read_only => 'false',
170 },
171 'cache_condition' => {
172 datatype => 'string',
173 base_name => 'cache_condition',
174 description => 'Name of the cache condition controlling when this configuration applies.',
175 format => '',
176 read_only => 'false',
177 },
178 'dst' => {
179 datatype => 'string',
180 base_name => 'dst',
181 description => 'Header to set.',
182 format => '',
183 read_only => 'false',
184 },
185 'name' => {
186 datatype => 'string',
187 base_name => 'name',
188 description => 'A handle to refer to this Header object.',
189 format => '',
190 read_only => 'false',
191 },
192 'regex' => {
193 datatype => 'string',
194 base_name => 'regex',
195 description => 'Regular expression to use. Only applies to `regex` and `regex_repeat` actions.',
196 format => '',
197 read_only => 'false',
198 },
199 'request_condition' => {
200 datatype => 'string',
201 base_name => 'request_condition',
202 description => 'Condition which, if met, will select this configuration during a request. Optional.',
203 format => '',
204 read_only => 'false',
205 },
206 'response_condition' => {
207 datatype => 'string',
208 base_name => 'response_condition',
209 description => 'Optional name of a response condition to apply.',
210 format => '',
211 read_only => 'false',
212 },
213 'src' => {
214 datatype => 'string',
215 base_name => 'src',
216 description => 'Variable to be used as a source for the header content. Does not apply to `delete` action.',
217 format => '',
218 read_only => 'false',
219 },
220 'substitution' => {
221 datatype => 'string',
222 base_name => 'substitution',
223 description => 'Value to substitute in place of regular expression. Only applies to `regex` and `regex_repeat` actions.',
224 format => '',
225 read_only => 'false',
226 },
227 'type' => {
228 datatype => 'string',
229 base_name => 'type',
230 description => 'Accepts a string value.',
231 format => '',
232 read_only => 'false',
233 },
234 'ignore_if_set' => {
235 datatype => 'string',
236 base_name => 'ignore_if_set',
237 description => 'Don't add the header if it is added already. Only applies to 'set' action. Numerical value (\"0\" = false, \"1\" = true)',
238 format => '',
239 read_only => 'false',
240 },
241 'priority' => {
242 datatype => 'string',
243 base_name => 'priority',
244 description => 'Priority determines execution order. Lower numbers execute first.',
245 format => '',
246 read_only => 'false',
247 },
248 'service_id' => {
249 datatype => 'string',
250 base_name => 'service_id',
251 description => '',
252 format => '',
253 read_only => 'true',
254 },
255 'version' => {
256 datatype => 'string',
257 base_name => 'version',
258 description => '',
259 format => '',
260 read_only => 'true',
261 },
262 'created_at' => {
263 datatype => 'DateTime',
264 base_name => 'created_at',
265 description => 'Date and time in ISO 8601 format.',
266 format => 'date-time',
267 read_only => 'true',
268 },
269 'deleted_at' => {
270 datatype => 'DateTime',
271 base_name => 'deleted_at',
272 description => 'Date and time in ISO 8601 format.',
273 format => 'date-time',
274 read_only => 'true',
275 },
276 'updated_at' => {
277 datatype => 'DateTime',
278 base_name => 'updated_at',
279 description => 'Date and time in ISO 8601 format.',
280 format => 'date-time',
281 read_only => 'true',
282 },
283 });
284  
285 __PACKAGE__->openapi_types( {
286 'action' => 'string',
287 'cache_condition' => 'string',
288 'dst' => 'string',
289 'name' => 'string',
290 'regex' => 'string',
291 'request_condition' => 'string',
292 'response_condition' => 'string',
293 'src' => 'string',
294 'substitution' => 'string',
295 'type' => 'string',
296 'ignore_if_set' => 'string',
297 'priority' => 'string',
298 'service_id' => 'string',
299 'version' => 'string',
300 'created_at' => 'DateTime',
301 'deleted_at' => 'DateTime',
302 'updated_at' => 'DateTime'
303 } );
304  
305 __PACKAGE__->attribute_map( {
306 'action' => 'action',
307 'cache_condition' => 'cache_condition',
308 'dst' => 'dst',
309 'name' => 'name',
310 'regex' => 'regex',
311 'request_condition' => 'request_condition',
312 'response_condition' => 'response_condition',
313 'src' => 'src',
314 'substitution' => 'substitution',
315 'type' => 'type',
316 'ignore_if_set' => 'ignore_if_set',
317 'priority' => 'priority',
318 'service_id' => 'service_id',
319 'version' => 'version',
320 'created_at' => 'created_at',
321 'deleted_at' => 'deleted_at',
322 'updated_at' => 'updated_at'
323 } );
324  
325 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
326  
327 __PACKAGE__->openapi_nullable( {
328 'cache_condition' => 'true',
329 'regex' => 'true',
330 'request_condition' => 'true',
331 'response_condition' => 'true',
332 'src' => 'true',
333 'substitution' => 'true',
334 'created_at' => 'true',
335 'deleted_at' => 'true',
336 'updated_at' => 'true',
337 } );
338  
339  
340 1;