« Fastly/Object/NetworkProtectEndpointsResponse.pm
↑ Summary
Fastly/Object/NetworkProtectNetworksResponse.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::NetworkProtectNetworkResponseFields; | ||
| 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::NetworkProtectLoaStatus; | ||
| 32 | use WebService::Fastly::Object::NetworkProtectRoaStatus; | ||
| 33 | |||
| 34 | use base ("Class::Accessor", "Class::Data::Inheritable"); | ||
| 35 | |||
| 36 | # | ||
| 37 | #Read-only fields and required fields in a network response. | ||
| 38 | # | ||
| 39 | # NOTE: This class is auto generated. Do not edit the class manually. | ||
| 40 | # | ||
| 41 | |||
| 42 | =begin comment | ||
| 43 | |||
| 44 | Fastly API | ||
| 45 | |||
| 46 | 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/) | ||
| 47 | |||
| 48 | The version of the API Spec document: 1.0.0 | ||
| 49 | Contact: oss@fastly.com | ||
| 50 | |||
| 51 | =end comment | ||
| 52 | |||
| 53 | =cut | ||
| 54 | |||
| 55 | # | ||
| 56 | # NOTE: This class is auto generated. | ||
| 57 | # Do not edit the class manually. | ||
| 58 | # | ||
| 59 | __PACKAGE__->mk_classdata('attribute_map' => {}); | ||
| 60 | __PACKAGE__->mk_classdata('openapi_types' => {}); | ||
| 61 | __PACKAGE__->mk_classdata('method_documentation' => {}); | ||
| 62 | __PACKAGE__->mk_classdata('class_documentation' => {}); | ||
| 63 | __PACKAGE__->mk_classdata('openapi_nullable' => {}); | ||
| 64 | |||
| 65 | # new plain object | ||
| 66 | sub new { | ||
| 67 | my ($class, %args) = @_; | ||
| 68 | |||
| 69 | my $self = bless {}, $class; | ||
| 70 | |||
| 71 | $self->init(%args); | ||
| 72 | |||
| 73 | return $self; | ||
| 74 | } | ||
| 75 | |||
| 76 | # initialize the object | ||
| 77 | sub init | ||
| 78 | { | ||
| 79 | my ($self, %args) = @_; | ||
| 80 | |||
| 81 | foreach my $attribute (keys %{$self->attribute_map}) { | ||
| 82 | my $args_key = $self->attribute_map->{$attribute}; | ||
| 83 | $self->$attribute( $args{ $args_key } ); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | # return perl hash | ||
| 88 | sub to_hash { | ||
| 89 | my $self = shift; | ||
| 90 | my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self)); | ||
| 91 | |||
| 92 | return $_hash; | ||
| 93 | } | ||
| 94 | |||
| 95 | # used by JSON for serialization | ||
| 96 | sub TO_JSON { | ||
| 97 | my $self = shift; | ||
| 98 | my $_data = {}; | ||
| 99 | foreach my $_key (keys %{$self->attribute_map}) { | ||
| 100 | $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; | ||
| 101 | } | ||
| 102 | |||
| 103 | return $_data; | ||
| 104 | } | ||
| 105 | |||
| 106 | # from Perl hashref | ||
| 107 | sub from_hash { | ||
| 108 | my ($self, $hash) = @_; | ||
| 109 | |||
| 110 | # loop through attributes and use openapi_types to deserialize the data | ||
| 111 | while ( my ($_key, $_type) = each %{$self->openapi_types} ) { | ||
| 112 | my $_json_attribute = $self->attribute_map->{$_key}; | ||
| 113 | my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true'; | ||
| 114 | if ($_type =~ /^array\[(.+)\]$/i) { # array | ||
| 115 | my $_subclass = $1; | ||
| 116 | my @_array = (); | ||
| 117 | foreach my $_element (@{$hash->{$_json_attribute}}) { | ||
| 118 | push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable); | ||
| 119 | } | ||
| 120 | $self->{$_key} = \@_array; | ||
| 121 | } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash | ||
| 122 | my $_subclass = $1; | ||
| 123 | my %_hash = (); | ||
| 124 | while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) { | ||
| 125 | $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable); | ||
| 126 | } | ||
| 127 | $self->{$_key} = \%_hash; | ||
| 128 | } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime | ||
| 129 | $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable); | ||
| 130 | } else { | ||
| 131 | $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); | ||
| 132 | } | ||
| 133 | } | ||
| 134 | |||
| 135 | return $self; | ||
| 136 | } | ||
| 137 | |||
| 138 | # deserialize non-array data | ||
| 139 | sub _deserialize { | ||
| 140 | my ($self, $type, $data, $is_nullable) = @_; | ||
| 141 | $log->debugf("deserializing %s with %s",Dumper($data), $type); | ||
| 142 | |||
| 143 | if (!(defined $data) && $is_nullable) { | ||
| 144 | return undef; | ||
| 145 | } | ||
| 146 | if ($type eq 'DateTime') { | ||
| 147 | return DateTime->from_epoch(epoch => str2time($data)); | ||
| 148 | } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { | ||
| 149 | return $data; | ||
| 150 | } else { # hash(model) | ||
| 151 | my $_instance = eval "WebService::Fastly::Object::$type->new()"; | ||
| 152 | return $_instance->from_hash($data); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | |||
| 157 | __PACKAGE__->class_documentation({description => 'Read-only fields and required fields in a network response.', | ||
| 158 | class => 'NetworkProtectNetworkResponseFields', | ||
| 159 | required => [], # TODO | ||
| 160 | } ); | ||
| 161 | |||
| 162 | __PACKAGE__->method_documentation({ | ||
| 163 | 'id' => { | ||
| 164 | datatype => 'string', | ||
| 165 | base_name => 'id', | ||
| 166 | description => 'A read-only unique identifier for a Network Protect resource.', | ||
| 167 | format => '', | ||
| 168 | read_only => 'true', | ||
| 169 | }, | ||
| 170 | 'roa_status' => { | ||
| 171 | datatype => 'NetworkProtectRoaStatus', | ||
| 172 | base_name => 'roa_status', | ||
| 173 | description => '', | ||
| 174 | format => '', | ||
| 175 | read_only => 'false', | ||
| 176 | }, | ||
| 177 | 'roa_checked_at' => { | ||
| 178 | datatype => 'DateTime', | ||
| 179 | base_name => 'roa_checked_at', | ||
| 180 | 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.', | ||
| 181 | format => 'date-time', | ||
| 182 | read_only => 'true', | ||
| 183 | }, | ||
| 184 | 'roa_data_as_of' => { | ||
| 185 | datatype => 'DateTime', | ||
| 186 | base_name => 'roa_data_as_of', | ||
| 187 | 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.', | ||
| 188 | format => 'date-time', | ||
| 189 | read_only => 'true', | ||
| 190 | }, | ||
| 191 | 'loa_status' => { | ||
| 192 | datatype => 'NetworkProtectLoaStatus', | ||
| 193 | base_name => 'loa_status', | ||
| 194 | description => '', | ||
| 195 | format => '', | ||
| 196 | read_only => 'false', | ||
| 197 | }, | ||
| 198 | 'created_at' => { | ||
| 199 | datatype => 'DateTime', | ||
| 200 | base_name => 'created_at', | ||
| 201 | description => 'An ISO 8601 timestamp in UTC.', | ||
| 202 | format => 'date-time', | ||
| 203 | read_only => 'true', | ||
| 204 | }, | ||
| 205 | 'updated_at' => { | ||
| 206 | datatype => 'DateTime', | ||
| 207 | base_name => 'updated_at', | ||
| 208 | description => 'An ISO 8601 timestamp in UTC.', | ||
| 209 | format => 'date-time', | ||
| 210 | read_only => 'true', | ||
| 211 | }, | ||
| 212 | }); | ||
| 213 | |||
| 214 | __PACKAGE__->openapi_types( { | ||
| 215 | 'id' => 'string', | ||
| 216 | 'roa_status' => 'NetworkProtectRoaStatus', | ||
| 217 | 'roa_checked_at' => 'DateTime', | ||
| 218 | 'roa_data_as_of' => 'DateTime', | ||
| 219 | 'loa_status' => 'NetworkProtectLoaStatus', | ||
| 220 | 'created_at' => 'DateTime', | ||
| 221 | 'updated_at' => 'DateTime' | ||
| 222 | } ); | ||
| 223 | |||
| 224 | __PACKAGE__->attribute_map( { | ||
| 225 | 'id' => 'id', | ||
| 226 | 'roa_status' => 'roa_status', | ||
| 227 | 'roa_checked_at' => 'roa_checked_at', | ||
| 228 | 'roa_data_as_of' => 'roa_data_as_of', | ||
| 229 | 'loa_status' => 'loa_status', | ||
| 230 | 'created_at' => 'created_at', | ||
| 231 | 'updated_at' => 'updated_at' | ||
| 232 | } ); | ||
| 233 | |||
| 234 | __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); | ||
| 235 | |||
| 236 | __PACKAGE__->openapi_nullable( { | ||
| 237 | 'roa_checked_at' => 'true', | ||
| 238 | 'roa_data_as_of' => 'true', | ||
| 239 | } ); | ||
| 240 | |||
| 241 | |||
| 242 | 1; |