« Fastly/Object/ArcVirtualKeyFailoverResponse.pm
↑ Summary
Fastly/Object/AutomationTokenErrorResponse.pm »
| 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::AutomationToken; | ||
| 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::AutomationTokenRole; | ||
| 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 => 'AutomationToken', | ||
| 158 | required => [], # TODO | ||
| 159 | } ); | ||
| 160 | |||
| 161 | __PACKAGE__->method_documentation({ | ||
| 162 | 'name' => { | ||
| 163 | datatype => 'string', | ||
| 164 | base_name => 'name', | ||
| 165 | description => 'The name of the token.', | ||
| 166 | format => '', | ||
| 167 | read_only => 'false', | ||
| 168 | }, | ||
| 169 | 'role' => { | ||
| 170 | datatype => 'string', | ||
| 171 | base_name => 'role', | ||
| 172 | description => 'The primary role on the token. For tokens with multiple roles, this returns the highest-priority role for backwards compatibility.', | ||
| 173 | format => '', | ||
| 174 | read_only => 'false', | ||
| 175 | }, | ||
| 176 | 'roles' => { | ||
| 177 | datatype => 'ARRAY[AutomationTokenRole]', | ||
| 178 | base_name => 'roles', | ||
| 179 | description => 'All roles assigned to the token. Each role includes an `id` and `name`.', | ||
| 180 | format => '', | ||
| 181 | read_only => 'false', | ||
| 182 | }, | ||
| 183 | 'services' => { | ||
| 184 | datatype => 'ARRAY[string]', | ||
| 185 | base_name => 'services', | ||
| 186 | 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.', | ||
| 187 | format => '', | ||
| 188 | read_only => 'false', | ||
| 189 | }, | ||
| 190 | 'limit_services' => { | ||
| 191 | datatype => 'boolean', | ||
| 192 | base_name => 'limit_services', | ||
| 193 | description => 'When `true`, the token is restricted to only the services in the `services` array. When `false`, the token has access to all services.', | ||
| 194 | format => '', | ||
| 195 | read_only => 'false', | ||
| 196 | }, | ||
| 197 | 'limit_workspaces' => { | ||
| 198 | datatype => 'boolean', | ||
| 199 | base_name => 'limit_workspaces', | ||
| 200 | 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.', | ||
| 201 | format => '', | ||
| 202 | read_only => 'false', | ||
| 203 | }, | ||
| 204 | 'workspaces' => { | ||
| 205 | datatype => 'ARRAY[string]', | ||
| 206 | base_name => 'workspaces', | ||
| 207 | description => 'The workspace IDs of the workspaces the token has access to. Returns an empty array for tokens without workspace access.', | ||
| 208 | format => '', | ||
| 209 | read_only => 'false', | ||
| 210 | }, | ||
| 211 | 'scope' => { | ||
| 212 | datatype => 'string', | ||
| 213 | base_name => 'scope', | ||
| 214 | description => 'A space-delimited list of authorization scope.', | ||
| 215 | format => '', | ||
| 216 | read_only => 'false', | ||
| 217 | }, | ||
| 218 | 'expires_at' => { | ||
| 219 | datatype => 'string', | ||
| 220 | base_name => 'expires_at', | ||
| 221 | description => 'A UTC timestamp of when the token expires.', | ||
| 222 | format => '', | ||
| 223 | read_only => 'false', | ||
| 224 | }, | ||
| 225 | }); | ||
| 226 | |||
| 227 | __PACKAGE__->openapi_types( { | ||
| 228 | 'name' => 'string', | ||
| 229 | 'role' => 'string', | ||
| 230 | 'roles' => 'ARRAY[AutomationTokenRole]', | ||
| 231 | 'services' => 'ARRAY[string]', | ||
| 232 | 'limit_services' => 'boolean', | ||
| 233 | 'limit_workspaces' => 'boolean', | ||
| 234 | 'workspaces' => 'ARRAY[string]', | ||
| 235 | 'scope' => 'string', | ||
| 236 | 'expires_at' => 'string' | ||
| 237 | } ); | ||
| 238 | |||
| 239 | __PACKAGE__->attribute_map( { | ||
| 240 | 'name' => 'name', | ||
| 241 | 'role' => 'role', | ||
| 242 | 'roles' => 'roles', | ||
| 243 | 'services' => 'services', | ||
| 244 | 'limit_services' => 'limit_services', | ||
| 245 | 'limit_workspaces' => 'limit_workspaces', | ||
| 246 | 'workspaces' => 'workspaces', | ||
| 247 | 'scope' => 'scope', | ||
| 248 | 'expires_at' => 'expires_at' | ||
| 249 | } ); | ||
| 250 | |||
| 251 | __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); | ||
| 252 | |||
| 253 | __PACKAGE__->openapi_nullable( { | ||
| 254 | } ); | ||
| 255 | |||
| 256 | |||
| 257 | 1; |