| 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::NetworkProtectRule; | ||
| 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::NetworkProtectRuleAction; | ||
| 32 | use WebService::Fastly::Object::NetworkProtectRuleDestinationPorts; | ||
| 33 | use WebService::Fastly::Object::NetworkProtectRuleIpProtocol; | ||
| 34 | use WebService::Fastly::Object::NetworkProtectRuleMatchDestinationIp; | ||
| 35 | use WebService::Fastly::Object::NetworkProtectRuleMatchDestinationPorts; | ||
| 36 | use WebService::Fastly::Object::NetworkProtectRuleMatchIpProtocol; | ||
| 37 | use WebService::Fastly::Object::NetworkProtectRuleMatchSourcePorts; | ||
| 38 | use WebService::Fastly::Object::NetworkProtectRuleMatchSourcePrefixList; | ||
| 39 | use WebService::Fastly::Object::NetworkProtectRuleSourcePorts; | ||
| 40 | |||
| 41 | use base ("Class::Accessor", "Class::Data::Inheritable"); | ||
| 42 | |||
| 43 | # | ||
| 44 | #One ordered firewall rule. All match fields are optional, but at least one must be provided. The action is required. Rules have no public ID; replacing the list preserves timestamps only when logical fields, comment, and position are unchanged. | ||
| 45 | # | ||
| 46 | # NOTE: This class is auto generated. Do not edit the class manually. | ||
| 47 | # | ||
| 48 | |||
| 49 | =begin comment | ||
| 50 | |||
| 51 | Fastly API | ||
| 52 | |||
| 53 | 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/) | ||
| 54 | |||
| 55 | The version of the API Spec document: 1.0.0 | ||
| 56 | Contact: oss@fastly.com | ||
| 57 | |||
| 58 | =end comment | ||
| 59 | |||
| 60 | =cut | ||
| 61 | |||
| 62 | # | ||
| 63 | # NOTE: This class is auto generated. | ||
| 64 | # Do not edit the class manually. | ||
| 65 | # | ||
| 66 | __PACKAGE__->mk_classdata('attribute_map' => {}); | ||
| 67 | __PACKAGE__->mk_classdata('openapi_types' => {}); | ||
| 68 | __PACKAGE__->mk_classdata('method_documentation' => {}); | ||
| 69 | __PACKAGE__->mk_classdata('class_documentation' => {}); | ||
| 70 | __PACKAGE__->mk_classdata('openapi_nullable' => {}); | ||
| 71 | |||
| 72 | # new plain object | ||
| 73 | sub new { | ||
| 74 | my ($class, %args) = @_; | ||
| 75 | |||
| 76 | my $self = bless {}, $class; | ||
| 77 | |||
| 78 | $self->init(%args); | ||
| 79 | |||
| 80 | return $self; | ||
| 81 | } | ||
| 82 | |||
| 83 | # initialize the object | ||
| 84 | sub init | ||
| 85 | { | ||
| 86 | my ($self, %args) = @_; | ||
| 87 | |||
| 88 | foreach my $attribute (keys %{$self->attribute_map}) { | ||
| 89 | my $args_key = $self->attribute_map->{$attribute}; | ||
| 90 | $self->$attribute( $args{ $args_key } ); | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | # return perl hash | ||
| 95 | sub to_hash { | ||
| 96 | my $self = shift; | ||
| 97 | my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self)); | ||
| 98 | |||
| 99 | return $_hash; | ||
| 100 | } | ||
| 101 | |||
| 102 | # used by JSON for serialization | ||
| 103 | sub TO_JSON { | ||
| 104 | my $self = shift; | ||
| 105 | my $_data = {}; | ||
| 106 | foreach my $_key (keys %{$self->attribute_map}) { | ||
| 107 | $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; | ||
| 108 | } | ||
| 109 | |||
| 110 | return $_data; | ||
| 111 | } | ||
| 112 | |||
| 113 | # from Perl hashref | ||
| 114 | sub from_hash { | ||
| 115 | my ($self, $hash) = @_; | ||
| 116 | |||
| 117 | # loop through attributes and use openapi_types to deserialize the data | ||
| 118 | while ( my ($_key, $_type) = each %{$self->openapi_types} ) { | ||
| 119 | my $_json_attribute = $self->attribute_map->{$_key}; | ||
| 120 | my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true'; | ||
| 121 | if ($_type =~ /^array\[(.+)\]$/i) { # array | ||
| 122 | my $_subclass = $1; | ||
| 123 | my @_array = (); | ||
| 124 | foreach my $_element (@{$hash->{$_json_attribute}}) { | ||
| 125 | push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable); | ||
| 126 | } | ||
| 127 | $self->{$_key} = \@_array; | ||
| 128 | } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash | ||
| 129 | my $_subclass = $1; | ||
| 130 | my %_hash = (); | ||
| 131 | while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) { | ||
| 132 | $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable); | ||
| 133 | } | ||
| 134 | $self->{$_key} = \%_hash; | ||
| 135 | } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime | ||
| 136 | $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable); | ||
| 137 | } else { | ||
| 138 | $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | return $self; | ||
| 143 | } | ||
| 144 | |||
| 145 | # deserialize non-array data | ||
| 146 | sub _deserialize { | ||
| 147 | my ($self, $type, $data, $is_nullable) = @_; | ||
| 148 | $log->debugf("deserializing %s with %s",Dumper($data), $type); | ||
| 149 | |||
| 150 | if (!(defined $data) && $is_nullable) { | ||
| 151 | return undef; | ||
| 152 | } | ||
| 153 | if ($type eq 'DateTime') { | ||
| 154 | return DateTime->from_epoch(epoch => str2time($data)); | ||
| 155 | } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { | ||
| 156 | return $data; | ||
| 157 | } else { # hash(model) | ||
| 158 | my $_instance = eval "WebService::Fastly::Object::$type->new()"; | ||
| 159 | return $_instance->from_hash($data); | ||
| 160 | } | ||
| 161 | } | ||
| 162 | |||
| 163 | |||
| 164 | __PACKAGE__->class_documentation({description => 'One ordered firewall rule. All match fields are optional, but at least one must be provided. The action is required. Rules have no public ID; replacing the list preserves timestamps only when logical fields, comment, and position are unchanged.', | ||
| 165 | class => 'NetworkProtectRule', | ||
| 166 | required => [], # TODO | ||
| 167 | } ); | ||
| 168 | |||
| 169 | __PACKAGE__->method_documentation({ | ||
| 170 | 'comment' => { | ||
| 171 | datatype => 'string', | ||
| 172 | base_name => 'comment', | ||
| 173 | description => 'Optional rule metadata of 1 to 100 Unicode code points. It does not participate in traffic matching. Omit it to leave a rule without a comment; replacing rules with an item that omits it clears the stored comment. Omitting rules on PATCH preserves existing comments. Empty strings and null are rejected.', | ||
| 174 | format => '', | ||
| 175 | read_only => 'false', | ||
| 176 | }, | ||
| 177 | 'ip_protocol' => { | ||
| 178 | datatype => 'NetworkProtectRuleIpProtocol', | ||
| 179 | base_name => 'ip_protocol', | ||
| 180 | description => '', | ||
| 181 | format => '', | ||
| 182 | read_only => 'false', | ||
| 183 | }, | ||
| 184 | 'source_prefix_list_id' => { | ||
| 185 | datatype => 'string', | ||
| 186 | base_name => 'source_prefix_list_id', | ||
| 187 | description => 'Match traffic whose source appears in this prefix list.', | ||
| 188 | format => '', | ||
| 189 | read_only => 'false', | ||
| 190 | }, | ||
| 191 | 'destination_ip_address' => { | ||
| 192 | datatype => 'string', | ||
| 193 | base_name => 'destination_ip_address', | ||
| 194 | description => 'Match traffic sent to this address; omit for any destination. An address outside a Network using this Rule Set never matches and still consumes one of the 64 rules. The API does not enforce containment in a network prefix; attached Rule Sets require a compatible IP family.', | ||
| 195 | format => '', | ||
| 196 | read_only => 'false', | ||
| 197 | }, | ||
| 198 | 'source_ports' => { | ||
| 199 | datatype => 'NetworkProtectRuleSourcePorts', | ||
| 200 | base_name => 'source_ports', | ||
| 201 | description => '', | ||
| 202 | format => '', | ||
| 203 | read_only => 'false', | ||
| 204 | }, | ||
| 205 | 'destination_ports' => { | ||
| 206 | datatype => 'NetworkProtectRuleDestinationPorts', | ||
| 207 | base_name => 'destination_ports', | ||
| 208 | description => '', | ||
| 209 | format => '', | ||
| 210 | read_only => 'false', | ||
| 211 | }, | ||
| 212 | 'action' => { | ||
| 213 | datatype => 'NetworkProtectRuleAction', | ||
| 214 | base_name => 'action', | ||
| 215 | description => '', | ||
| 216 | format => '', | ||
| 217 | read_only => 'false', | ||
| 218 | }, | ||
| 219 | }); | ||
| 220 | |||
| 221 | __PACKAGE__->openapi_types( { | ||
| 222 | 'comment' => 'string', | ||
| 223 | 'ip_protocol' => 'NetworkProtectRuleIpProtocol', | ||
| 224 | 'source_prefix_list_id' => 'string', | ||
| 225 | 'destination_ip_address' => 'string', | ||
| 226 | 'source_ports' => 'NetworkProtectRuleSourcePorts', | ||
| 227 | 'destination_ports' => 'NetworkProtectRuleDestinationPorts', | ||
| 228 | 'action' => 'NetworkProtectRuleAction' | ||
| 229 | } ); | ||
| 230 | |||
| 231 | __PACKAGE__->attribute_map( { | ||
| 232 | 'comment' => 'comment', | ||
| 233 | 'ip_protocol' => 'ip_protocol', | ||
| 234 | 'source_prefix_list_id' => 'source_prefix_list_id', | ||
| 235 | 'destination_ip_address' => 'destination_ip_address', | ||
| 236 | 'source_ports' => 'source_ports', | ||
| 237 | 'destination_ports' => 'destination_ports', | ||
| 238 | 'action' => 'action' | ||
| 239 | } ); | ||
| 240 | |||
| 241 | __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); | ||
| 242 | |||
| 243 | __PACKAGE__->openapi_nullable( { | ||
| 244 | } ); | ||
| 245 | |||
| 246 | |||
| 247 | 1; |