Fastly/Object/AutomationTokenResponse.pm untested

filter: Statementstmt 0.0% 0 / 118 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 / 166 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::AutomationTokenResponse;
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::AutomationToken;
32 use WebService::Fastly::Object::AutomationTokenResponseAllOf;
33 use WebService::Fastly::Object::AutomationTokenRole;
34 use WebService::Fastly::Object::ReadOnlyCustomerId;
35 use WebService::Fastly::Object::ReadOnlyId;
36  
37 use base ("Class::Accessor", "Class::Data::Inheritable");
38  
39 #
40 #
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 => '',
161 class => 'AutomationTokenResponse',
162 required => [], # TODO
163 } );
164  
165 __PACKAGE__->method_documentation({
166 'name' => {
167 datatype => 'string',
168 base_name => 'name',
169 description => 'The name of the token.',
170 format => '',
171 read_only => 'false',
172 },
173 'role' => {
174 datatype => 'string',
175 base_name => 'role',
176 description => '',
177 format => '',
178 read_only => 'false',
179 },
180 'roles' => {
181 datatype => 'ARRAY[AutomationTokenRole]',
182 base_name => 'roles',
183 description => 'All roles assigned to the token. Each role includes an `id` and `name`.',
184 format => '',
185 read_only => 'false',
186 },
187 'services' => {
188 datatype => 'ARRAY[string]',
189 base_name => 'services',
190 description => 'The service IDs of the services the token has access to. Empty when `limit_services` is `false` (full access) or when the token has no service access.',
191 format => '',
192 read_only => 'false',
193 },
194 'limit_services' => {
195 datatype => 'boolean',
196 base_name => 'limit_services',
197 description => 'When `true`, the token is restricted to only the services in the `services` array. When `false`, the token has access to all services.',
198 format => '',
199 read_only => 'false',
200 },
201 'limit_workspaces' => {
202 datatype => 'boolean',
203 base_name => 'limit_workspaces',
204 description => 'When `true`, the token is restricted to only the workspaces in the `workspaces` array. When `false`, the token has access to all workspaces. Only applies to roles that support workspace access.',
205 format => '',
206 read_only => 'false',
207 },
208 'workspaces' => {
209 datatype => 'ARRAY[string]',
210 base_name => 'workspaces',
211 description => 'The workspace IDs of the workspaces the token has access to. Returns an empty array for tokens without workspace access.',
212 format => '',
213 read_only => 'false',
214 },
215 'scope' => {
216 datatype => 'string',
217 base_name => 'scope',
218 description => 'A space-delimited list of authorization scope.',
219 format => '',
220 read_only => 'false',
221 },
222 'expires_at' => {
223 datatype => 'string',
224 base_name => 'expires_at',
225 description => '(optional) A UTC timestamp of when the token will expire.',
226 format => '',
227 read_only => 'false',
228 },
229 'id' => {
230 datatype => 'ReadOnlyId',
231 base_name => 'id',
232 description => '',
233 format => '',
234 read_only => 'false',
235 },
236 'customer_id' => {
237 datatype => 'ReadOnlyCustomerId',
238 base_name => 'customer_id',
239 description => '',
240 format => '',
241 read_only => 'false',
242 },
243 'ip' => {
244 datatype => 'string',
245 base_name => 'ip',
246 description => 'The IP address of the client that last used the token.',
247 format => '',
248 read_only => 'false',
249 },
250 'user_agent' => {
251 datatype => 'string',
252 base_name => 'user_agent',
253 description => 'The User-Agent header of the client that last used the token.',
254 format => '',
255 read_only => 'false',
256 },
257 'tls_access' => {
258 datatype => 'boolean',
259 base_name => 'tls_access',
260 description => 'Indicates whether TLS access is enabled for the token.',
261 format => '',
262 read_only => 'false',
263 },
264 'last_used_at' => {
265 datatype => 'DateTime',
266 base_name => 'last_used_at',
267 description => 'A UTC timestamp of when the token was last used.',
268 format => 'date-time',
269 read_only => 'true',
270 },
271 'created_at' => {
272 datatype => 'string',
273 base_name => 'created_at',
274 description => 'A UTC timestamp of when the token was created.',
275 format => '',
276 read_only => 'false',
277 },
278 });
279  
280 __PACKAGE__->openapi_types( {
281 'name' => 'string',
282 'role' => 'string',
283 'roles' => 'ARRAY[AutomationTokenRole]',
284 'services' => 'ARRAY[string]',
285 'limit_services' => 'boolean',
286 'limit_workspaces' => 'boolean',
287 'workspaces' => 'ARRAY[string]',
288 'scope' => 'string',
289 'expires_at' => 'string',
290 'id' => 'ReadOnlyId',
291 'customer_id' => 'ReadOnlyCustomerId',
292 'ip' => 'string',
293 'user_agent' => 'string',
294 'tls_access' => 'boolean',
295 'last_used_at' => 'DateTime',
296 'created_at' => 'string'
297 } );
298  
299 __PACKAGE__->attribute_map( {
300 'name' => 'name',
301 'role' => 'role',
302 'roles' => 'roles',
303 'services' => 'services',
304 'limit_services' => 'limit_services',
305 'limit_workspaces' => 'limit_workspaces',
306 'workspaces' => 'workspaces',
307 'scope' => 'scope',
308 'expires_at' => 'expires_at',
309 'id' => 'id',
310 'customer_id' => 'customer_id',
311 'ip' => 'ip',
312 'user_agent' => 'user_agent',
313 'tls_access' => 'tls_access',
314 'last_used_at' => 'last_used_at',
315 'created_at' => 'created_at'
316 } );
317  
318 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
319  
320 __PACKAGE__->openapi_nullable( {
321 } );
322  
323  
324 1;