Fastly/Object/NetworkProtectNetworkResponse.pm untested

filter: Statementstmt 0.0% 0 / 119 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 22 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 167 CC 7 SCAR 19.7
CC
7
Cov
0%
from_hash
20.0
_deserialize
20.0
new
2.0
CRAP 7.1
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::NetworkProtectNetworkResponse;
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::NetworkProtectEndpointPolicy;
32 use WebService::Fastly::Object::NetworkProtectLoaStatus;
33 use WebService::Fastly::Object::NetworkProtectNetwork;
34 use WebService::Fastly::Object::NetworkProtectNetworkResponseFields;
35 use WebService::Fastly::Object::NetworkProtectRoaStatus;
36  
37 use base ("Class::Accessor", "Class::Data::Inheritable");
38  
39 #
40 #A Network Protect network response.
41 #
42 # NOTE: This class is auto generated. Do not edit the class manually.
43 #
44  
45 =begin comment
46  
47 Fastly API
48  
49 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/)
50  
51 The version of the API Spec document: 1.0.0
52 Contact: oss@fastly.com
53  
54 =end comment
55  
56 =cut
57  
58 #
59 # NOTE: This class is auto generated.
60 # Do not edit the class manually.
61 #
62 __PACKAGE__->mk_classdata('attribute_map' => {});
63 __PACKAGE__->mk_classdata('openapi_types' => {});
64 __PACKAGE__->mk_classdata('method_documentation' => {});
65 __PACKAGE__->mk_classdata('class_documentation' => {});
66 __PACKAGE__->mk_classdata('openapi_nullable' => {});
67  
68 # new plain object
69 sub new {
70 my ($class, %args) = @_;
71  
72 my $self = bless {}, $class;
73  
74 $self->init(%args);
75  
76 return $self;
77 }
78  
79 # initialize the object
80 sub init
81 {
82 my ($self, %args) = @_;
83  
84 foreach my $attribute (keys %{$self->attribute_map}) {
85 my $args_key = $self->attribute_map->{$attribute};
86 $self->$attribute( $args{ $args_key } );
87 }
88 }
89  
90 # return perl hash
91 sub to_hash {
92 my $self = shift;
93 my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
94  
95 return $_hash;
96 }
97  
98 # used by JSON for serialization
99 sub TO_JSON {
100 my $self = shift;
101 my $_data = {};
102 foreach my $_key (keys %{$self->attribute_map}) {
103 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
104 }
105  
106 return $_data;
107 }
108  
109 # from Perl hashref
110 sub from_hash {
111 my ($self, $hash) = @_;
112  
113 # loop through attributes and use openapi_types to deserialize the data
114 while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
115 my $_json_attribute = $self->attribute_map->{$_key};
116 my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true';
117 if ($_type =~ /^array\[(.+)\]$/i) { # array
118 my $_subclass = $1;
119 my @_array = ();
120 foreach my $_element (@{$hash->{$_json_attribute}}) {
121 push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable);
122 }
123 $self->{$_key} = \@_array;
124 } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
125 my $_subclass = $1;
126 my %_hash = ();
127 while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
128 $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable);
129 }
130 $self->{$_key} = \%_hash;
131 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
132 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable);
133 } else {
134 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
135 }
136 }
137  
138 return $self;
139 }
140  
141 # deserialize non-array data
142 sub _deserialize {
143 my ($self, $type, $data, $is_nullable) = @_;
144 $log->debugf("deserializing %s with %s",Dumper($data), $type);
145  
146 if (!(defined $data) && $is_nullable) {
147 return undef;
148 }
149 if ($type eq 'DateTime') {
150 return DateTime->from_epoch(epoch => str2time($data));
151 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
152 return $data;
153 } else { # hash(model)
154 my $_instance = eval "WebService::Fastly::Object::$type->new()";
155 return $_instance->from_hash($data);
156 }
157 }
158  
159  
160 __PACKAGE__->class_documentation({description => 'A Network Protect network response.',
161 class => 'NetworkProtectNetworkResponse',
162 required => [], # TODO
163 } );
164  
165 __PACKAGE__->method_documentation({
166 'description' => {
167 datatype => 'string',
168 base_name => 'description',
169 description => 'Optional descriptive text for the network. This metadata does not change traffic handling. Null clears it on update.',
170 format => '',
171 read_only => 'false',
172 },
173 'name' => {
174 datatype => 'string',
175 base_name => 'name',
176 description => 'A human-readable name, unique within the customer.',
177 format => '',
178 read_only => 'false',
179 },
180 'prefix' => {
181 datatype => 'string',
182 base_name => 'prefix',
183 description => 'The CIDR block to protect, masked to its network address. It cannot be changed after creation.',
184 format => '',
185 read_only => 'false',
186 },
187 'rule_set_id' => {
188 datatype => 'string',
189 base_name => 'rule_set_id',
190 description => 'The backend-assigned rule set applied to this network.',
191 format => '',
192 read_only => 'false',
193 },
194 'endpoint_policies' => {
195 datatype => 'ARRAY[NetworkProtectEndpointPolicy]',
196 base_name => 'endpoint_policies',
197 description => 'Complete endpoint policy configuration. A network has at most one policy per region and may have no policies.',
198 format => '',
199 read_only => 'false',
200 },
201 'advertise' => {
202 datatype => 'boolean',
203 base_name => 'advertise',
204 description => 'Desired advertisement state, which is not the same as observed route state. Enabling it requires approved LOA, valid ROA, and a ready default-region delivery policy. A later ROA failure does not turn an existing advertisement off; losing LOA approval or the last ready default endpoint does.',
205 format => '',
206 read_only => 'false',
207 },
208 'id' => {
209 datatype => 'string',
210 base_name => 'id',
211 description => 'A read-only unique identifier for a Network Protect resource.',
212 format => '',
213 read_only => 'true',
214 },
215 'roa_status' => {
216 datatype => 'NetworkProtectRoaStatus',
217 base_name => 'roa_status',
218 description => '',
219 format => '',
220 read_only => 'false',
221 },
222 'roa_checked_at' => {
223 datatype => 'DateTime',
224 base_name => 'roa_checked_at',
225 description => 'When Fastly last completed a ROA check. Null while the status is pending. A failed check leaves this unchanged; an old value can indicate delayed or failing checks. Null also means the controller did not report a check time.',
226 format => 'date-time',
227 read_only => 'true',
228 },
229 'roa_data_as_of' => {
230 datatype => 'DateTime',
231 base_name => 'roa_data_as_of',
232 description => 'When the RPKI dataset used by the last check was built. This is not the same as `roa_checked_at`; a recent check can use an older dataset. Null while the status is pending or when no dataset build time was reported.',
233 format => 'date-time',
234 read_only => 'true',
235 },
236 'loa_status' => {
237 datatype => 'NetworkProtectLoaStatus',
238 base_name => 'loa_status',
239 description => '',
240 format => '',
241 read_only => 'false',
242 },
243 'created_at' => {
244 datatype => 'DateTime',
245 base_name => 'created_at',
246 description => 'An ISO 8601 timestamp in UTC.',
247 format => 'date-time',
248 read_only => 'true',
249 },
250 'updated_at' => {
251 datatype => 'DateTime',
252 base_name => 'updated_at',
253 description => 'An ISO 8601 timestamp in UTC.',
254 format => 'date-time',
255 read_only => 'true',
256 },
257 });
258  
259 __PACKAGE__->openapi_types( {
260 'description' => 'string',
261 'name' => 'string',
262 'prefix' => 'string',
263 'rule_set_id' => 'string',
264 'endpoint_policies' => 'ARRAY[NetworkProtectEndpointPolicy]',
265 'advertise' => 'boolean',
266 'id' => 'string',
267 'roa_status' => 'NetworkProtectRoaStatus',
268 'roa_checked_at' => 'DateTime',
269 'roa_data_as_of' => 'DateTime',
270 'loa_status' => 'NetworkProtectLoaStatus',
271 'created_at' => 'DateTime',
272 'updated_at' => 'DateTime'
273 } );
274  
275 __PACKAGE__->attribute_map( {
276 'description' => 'description',
277 'name' => 'name',
278 'prefix' => 'prefix',
279 'rule_set_id' => 'rule_set_id',
280 'endpoint_policies' => 'endpoint_policies',
281 'advertise' => 'advertise',
282 'id' => 'id',
283 'roa_status' => 'roa_status',
284 'roa_checked_at' => 'roa_checked_at',
285 'roa_data_as_of' => 'roa_data_as_of',
286 'loa_status' => 'loa_status',
287 'created_at' => 'created_at',
288 'updated_at' => 'updated_at'
289 } );
290  
291 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
292  
293 __PACKAGE__->openapi_nullable( {
294 'description' => 'true',
295 'rule_set_id' => 'true',
296 'roa_checked_at' => 'true',
297 'roa_data_as_of' => 'true',
298 } );
299  
300  
301 1;