Fastly/Object/LogRecord.pm untested

filter: Statementstmt 0.0% 0 / 106 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 18 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 150 CC 7 SCAR 20.8
CC
7
Cov
0%
from_hash
20.0
_deserialize
20.0
new
2.0
CRAP 8.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::LogRecord;
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::LogPropertyServiceId;
32  
33 use base ("Class::Accessor", "Class::Data::Inheritable");
34  
35 #
36 #
37 #
38 # NOTE: This class is auto generated. Do not edit the class manually.
39 #
40  
41 =begin comment
42  
43 Fastly API
44  
45 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/)
46  
47 The version of the API Spec document: 1.0.0
48 Contact: oss@fastly.com
49  
50 =end comment
51  
52 =cut
53  
54 #
55 # NOTE: This class is auto generated.
56 # Do not edit the class manually.
57 #
58 __PACKAGE__->mk_classdata('attribute_map' => {});
59 __PACKAGE__->mk_classdata('openapi_types' => {});
60 __PACKAGE__->mk_classdata('method_documentation' => {});
61 __PACKAGE__->mk_classdata('class_documentation' => {});
62 __PACKAGE__->mk_classdata('openapi_nullable' => {});
63  
64 # new plain object
65 sub new {
66 my ($class, %args) = @_;
67  
68 my $self = bless {}, $class;
69  
70 $self->init(%args);
71  
72 return $self;
73 }
74  
75 # initialize the object
76 sub init
77 {
78 my ($self, %args) = @_;
79  
80 foreach my $attribute (keys %{$self->attribute_map}) {
81 my $args_key = $self->attribute_map->{$attribute};
82 $self->$attribute( $args{ $args_key } );
83 }
84 }
85  
86 # return perl hash
87 sub to_hash {
88 my $self = shift;
89 my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
90  
91 return $_hash;
92 }
93  
94 # used by JSON for serialization
95 sub TO_JSON {
96 my $self = shift;
97 my $_data = {};
98 foreach my $_key (keys %{$self->attribute_map}) {
99 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
100 }
101  
102 return $_data;
103 }
104  
105 # from Perl hashref
106 sub from_hash {
107 my ($self, $hash) = @_;
108  
109 # loop through attributes and use openapi_types to deserialize the data
110 while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
111 my $_json_attribute = $self->attribute_map->{$_key};
112 my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true';
113 if ($_type =~ /^array\[(.+)\]$/i) { # array
114 my $_subclass = $1;
115 my @_array = ();
116 foreach my $_element (@{$hash->{$_json_attribute}}) {
117 push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable);
118 }
119 $self->{$_key} = \@_array;
120 } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
121 my $_subclass = $1;
122 my %_hash = ();
123 while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
124 $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable);
125 }
126 $self->{$_key} = \%_hash;
127 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
128 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable);
129 } else {
130 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
131 }
132 }
133  
134 return $self;
135 }
136  
137 # deserialize non-array data
138 sub _deserialize {
139 my ($self, $type, $data, $is_nullable) = @_;
140 $log->debugf("deserializing %s with %s",Dumper($data), $type);
141  
142 if (!(defined $data) && $is_nullable) {
143 return undef;
144 }
145 if ($type eq 'DateTime') {
146 return DateTime->from_epoch(epoch => str2time($data));
147 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
148 return $data;
149 } else { # hash(model)
150 my $_instance = eval "WebService::Fastly::Object::$type->new()";
151 return $_instance->from_hash($data);
152 }
153 }
154  
155  
156 __PACKAGE__->class_documentation({description => '',
157 class => 'LogRecord',
158 required => [], # TODO
159 } );
160  
161 __PACKAGE__->method_documentation({
162 'customer_id' => {
163 datatype => 'string',
164 base_name => 'customer_id',
165 description => 'The ID of the Fastly customer that owns the service.',
166 format => '',
167 read_only => 'true',
168 },
169 'service_id' => {
170 datatype => 'LogPropertyServiceId',
171 base_name => 'service_id',
172 description => '',
173 format => '',
174 read_only => 'false',
175 },
176 'timestamp' => {
177 datatype => 'DateTime',
178 base_name => 'timestamp',
179 description => 'Timestamp of the request in ISO 8601 format.',
180 format => 'date-time',
181 read_only => 'false',
182 },
183 'client_as_number' => {
184 datatype => 'int',
185 base_name => 'client_as_number',
186 description => 'The autonomous system (AS) number of the client.',
187 format => '',
188 read_only => 'true',
189 },
190 'client_region' => {
191 datatype => 'string',
192 base_name => 'client_region',
193 description => 'The client's country subdivision code as found in ISO 3166-2.',
194 format => '',
195 read_only => 'true',
196 },
197 'client_country_code' => {
198 datatype => 'string',
199 base_name => 'client_country_code',
200 description => 'The two-letter ISO 3166-1 country code for the client.',
201 format => '',
202 read_only => 'true',
203 },
204 'client_os_name' => {
205 datatype => 'string',
206 base_name => 'client_os_name',
207 description => 'The name of the operating system installed on the client device.',
208 format => '',
209 read_only => 'true',
210 },
211 'client_device_type' => {
212 datatype => 'string',
213 base_name => 'client_device_type',
214 description => 'The type of the client's device.',
215 format => '',
216 read_only => 'true',
217 },
218 'client_browser_name' => {
219 datatype => 'string',
220 base_name => 'client_browser_name',
221 description => 'The name of the browser in use on the client device.',
222 format => '',
223 read_only => 'true',
224 },
225 'client_browser_version' => {
226 datatype => 'string',
227 base_name => 'client_browser_version',
228 description => 'The version of the browser in use on client device.',
229 format => '',
230 read_only => 'true',
231 },
232 'fastly_pop' => {
233 datatype => 'string',
234 base_name => 'fastly_pop',
235 description => 'The name of the Fastly POP that served this request.',
236 format => '',
237 read_only => 'true',
238 },
239 'origin_host' => {
240 datatype => 'string',
241 base_name => 'origin_host',
242 description => 'The name of the origin host that served this request.',
243 format => '',
244 read_only => 'true',
245 },
246 'request_protocol' => {
247 datatype => 'string',
248 base_name => 'request_protocol',
249 description => 'HTTP protocol version in use for this request. For example, HTTP/1.1.',
250 format => '',
251 read_only => 'true',
252 },
253 'request_host' => {
254 datatype => 'string',
255 base_name => 'request_host',
256 description => 'The name of the request host used for this request.',
257 format => '',
258 read_only => 'true',
259 },
260 'request_path' => {
261 datatype => 'string',
262 base_name => 'request_path',
263 description => 'The URL path supplied for this request.',
264 format => '',
265 read_only => 'true',
266 },
267 'request_method' => {
268 datatype => 'string',
269 base_name => 'request_method',
270 description => 'HTTP method sent by the client such as \"GET\" or \"POST\".',
271 format => '',
272 read_only => 'true',
273 },
274 'response_bytes_body' => {
275 datatype => 'int',
276 base_name => 'response_bytes_body',
277 description => 'Body bytes sent to the client in the response.',
278 format => '',
279 read_only => 'true',
280 },
281 'response_bytes_header' => {
282 datatype => 'int',
283 base_name => 'response_bytes_header',
284 description => 'Header bytes sent to the client in the response.',
285 format => '',
286 read_only => 'true',
287 },
288 'response_content_length' => {
289 datatype => 'int',
290 base_name => 'response_content_length',
291 description => 'Total bytes sent to the client in the response.',
292 format => '',
293 read_only => 'true',
294 },
295 'response_content_type' => {
296 datatype => 'string',
297 base_name => 'response_content_type',
298 description => 'The content type of the response sent to the client.',
299 format => '',
300 read_only => 'true',
301 },
302 'response_reason' => {
303 datatype => 'string',
304 base_name => 'response_reason',
305 description => 'The HTTP reason phrase returned for this request, if any.',
306 format => '',
307 read_only => 'true',
308 },
309 'response_state' => {
310 datatype => 'string',
311 base_name => 'response_state',
312 description => 'The state of the request with optional suffixes describing special cases.',
313 format => '',
314 read_only => 'true',
315 },
316 'response_status' => {
317 datatype => 'int',
318 base_name => 'response_status',
319 description => 'The HTTP response code returned for this request.',
320 format => '',
321 read_only => 'true',
322 },
323 'response_time' => {
324 datatype => 'double',
325 base_name => 'response_time',
326 description => 'The time since the request started in seconds.',
327 format => 'float',
328 read_only => 'true',
329 },
330 'response_x_cache' => {
331 datatype => 'string',
332 base_name => 'response_x_cache',
333 description => 'Indicates whether the request was a HIT or a MISS.',
334 format => '',
335 read_only => 'true',
336 },
337 'is_cache_hit' => {
338 datatype => 'boolean',
339 base_name => 'is_cache_hit',
340 description => 'Indicates whether this request was fulfilled from cache.',
341 format => '',
342 read_only => 'true',
343 },
344 'is_edge' => {
345 datatype => 'boolean',
346 base_name => 'is_edge',
347 description => 'Indicates whether the request was handled by a Fastly edge POP.',
348 format => '',
349 read_only => 'true',
350 },
351 'is_shield' => {
352 datatype => 'boolean',
353 base_name => 'is_shield',
354 description => 'Indicates whether the request was handled by a Fastly shield POP.',
355 format => '',
356 read_only => 'true',
357 },
358 });
359  
360 __PACKAGE__->openapi_types( {
361 'customer_id' => 'string',
362 'service_id' => 'LogPropertyServiceId',
363 'timestamp' => 'DateTime',
364 'client_as_number' => 'int',
365 'client_region' => 'string',
366 'client_country_code' => 'string',
367 'client_os_name' => 'string',
368 'client_device_type' => 'string',
369 'client_browser_name' => 'string',
370 'client_browser_version' => 'string',
371 'fastly_pop' => 'string',
372 'origin_host' => 'string',
373 'request_protocol' => 'string',
374 'request_host' => 'string',
375 'request_path' => 'string',
376 'request_method' => 'string',
377 'response_bytes_body' => 'int',
378 'response_bytes_header' => 'int',
379 'response_content_length' => 'int',
380 'response_content_type' => 'string',
381 'response_reason' => 'string',
382 'response_state' => 'string',
383 'response_status' => 'int',
384 'response_time' => 'double',
385 'response_x_cache' => 'string',
386 'is_cache_hit' => 'boolean',
387 'is_edge' => 'boolean',
388 'is_shield' => 'boolean'
389 } );
390  
391 __PACKAGE__->attribute_map( {
392 'customer_id' => 'customer_id',
393 'service_id' => 'service_id',
394 'timestamp' => 'timestamp',
395 'client_as_number' => 'client_as_number',
396 'client_region' => 'client_region',
397 'client_country_code' => 'client_country_code',
398 'client_os_name' => 'client_os_name',
399 'client_device_type' => 'client_device_type',
400 'client_browser_name' => 'client_browser_name',
401 'client_browser_version' => 'client_browser_version',
402 'fastly_pop' => 'fastly_pop',
403 'origin_host' => 'origin_host',
404 'request_protocol' => 'request_protocol',
405 'request_host' => 'request_host',
406 'request_path' => 'request_path',
407 'request_method' => 'request_method',
408 'response_bytes_body' => 'response_bytes_body',
409 'response_bytes_header' => 'response_bytes_header',
410 'response_content_length' => 'response_content_length',
411 'response_content_type' => 'response_content_type',
412 'response_reason' => 'response_reason',
413 'response_state' => 'response_state',
414 'response_status' => 'response_status',
415 'response_time' => 'response_time',
416 'response_x_cache' => 'response_x_cache',
417 'is_cache_hit' => 'is_cache_hit',
418 'is_edge' => 'is_edge',
419 'is_shield' => 'is_shield'
420 } );
421  
422 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
423  
424 __PACKAGE__->openapi_nullable( {
425 } );
426  
427  
428 1;