| 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::ArcSession; | ||
| 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::ArcSessionLogEntry; | ||
| 32 | |||
| 33 | use base ("Class::Accessor", "Class::Data::Inheritable"); | ||
| 34 | |||
| 35 | # | ||
| 36 | #A session log. Other than `firewall_enabled` (always present), `firewall_*` fields are only present when AI Firewall ran on a request in this session. They're absent (not merely empty) otherwise, so their absence and an empty value mean different things. | ||
| 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 => 'A session log. Other than `firewall_enabled` (always present), `firewall_*` fields are only present when AI Firewall ran on a request in this session. They're absent (not merely empty) otherwise, so their absence and an empty value mean different things. ', | ||
| 157 | class => 'ArcSession', | ||
| 158 | required => [], # TODO | ||
| 159 | } ); | ||
| 160 | |||
| 161 | __PACKAGE__->method_documentation({ | ||
| 162 | 'id' => { | ||
| 163 | datatype => 'string', | ||
| 164 | base_name => 'id', | ||
| 165 | description => 'The unique identifier of the session.', | ||
| 166 | format => '', | ||
| 167 | read_only => 'true', | ||
| 168 | }, | ||
| 169 | 'virtual_key_id' => { | ||
| 170 | datatype => 'string', | ||
| 171 | base_name => 'virtual_key_id', | ||
| 172 | description => 'The ID of the virtual key used for this session.', | ||
| 173 | format => '', | ||
| 174 | read_only => 'false', | ||
| 175 | }, | ||
| 176 | 'virtual_key_name' => { | ||
| 177 | datatype => 'string', | ||
| 178 | base_name => 'virtual_key_name', | ||
| 179 | description => 'The display name of the virtual key used for this session.', | ||
| 180 | format => '', | ||
| 181 | read_only => 'false', | ||
| 182 | }, | ||
| 183 | 'model' => { | ||
| 184 | datatype => 'string', | ||
| 185 | base_name => 'model', | ||
| 186 | description => 'The AI model identifier used.', | ||
| 187 | format => '', | ||
| 188 | read_only => 'false', | ||
| 189 | }, | ||
| 190 | 'provider' => { | ||
| 191 | datatype => 'string', | ||
| 192 | base_name => 'provider', | ||
| 193 | description => 'The name of the provider connection that ultimately served the session.', | ||
| 194 | format => '', | ||
| 195 | read_only => 'false', | ||
| 196 | }, | ||
| 197 | 'provider_connection_id' => { | ||
| 198 | datatype => 'string', | ||
| 199 | base_name => 'provider_connection_id', | ||
| 200 | description => 'The ID of the provider connection that ultimately served the session.', | ||
| 201 | format => '', | ||
| 202 | read_only => 'false', | ||
| 203 | }, | ||
| 204 | 'primary_provider' => { | ||
| 205 | datatype => 'string', | ||
| 206 | base_name => 'primary_provider', | ||
| 207 | description => 'The ID of the provider connection originally requested, before any failover occurred.', | ||
| 208 | format => '', | ||
| 209 | read_only => 'false', | ||
| 210 | }, | ||
| 211 | 'requests' => { | ||
| 212 | datatype => 'int', | ||
| 213 | base_name => 'requests', | ||
| 214 | description => 'The number of requests made in this session.', | ||
| 215 | format => '', | ||
| 216 | read_only => 'false', | ||
| 217 | }, | ||
| 218 | 'input_tokens' => { | ||
| 219 | datatype => 'int', | ||
| 220 | base_name => 'input_tokens', | ||
| 221 | description => 'The total input tokens consumed in this session.', | ||
| 222 | format => '', | ||
| 223 | read_only => 'false', | ||
| 224 | }, | ||
| 225 | 'output_tokens' => { | ||
| 226 | datatype => 'int', | ||
| 227 | base_name => 'output_tokens', | ||
| 228 | description => 'The total output tokens generated in this session.', | ||
| 229 | format => '', | ||
| 230 | read_only => 'false', | ||
| 231 | }, | ||
| 232 | 'violations' => { | ||
| 233 | datatype => 'int', | ||
| 234 | base_name => 'violations', | ||
| 235 | description => 'The number of AI Firewall violations detected in this session.', | ||
| 236 | format => '', | ||
| 237 | read_only => 'false', | ||
| 238 | }, | ||
| 239 | 'firewall_enabled' => { | ||
| 240 | datatype => 'boolean', | ||
| 241 | base_name => 'firewall_enabled', | ||
| 242 | description => 'Whether AI Firewall was enabled for this session's virtual key.', | ||
| 243 | format => '', | ||
| 244 | read_only => 'false', | ||
| 245 | }, | ||
| 246 | 'firewall_outcome' => { | ||
| 247 | datatype => 'string', | ||
| 248 | base_name => 'firewall_outcome', | ||
| 249 | description => 'The outcome AI Firewall reached for this session. Present only when AI Firewall ran.', | ||
| 250 | format => '', | ||
| 251 | read_only => 'false', | ||
| 252 | }, | ||
| 253 | 'firewall_stage' => { | ||
| 254 | datatype => 'string', | ||
| 255 | base_name => 'firewall_stage', | ||
| 256 | description => 'The AI Firewall stage that produced the outcome (for example, the request or response stage). Present only when AI Firewall ran.', | ||
| 257 | format => '', | ||
| 258 | read_only => 'false', | ||
| 259 | }, | ||
| 260 | 'firewall_policy' => { | ||
| 261 | datatype => 'string', | ||
| 262 | base_name => 'firewall_policy', | ||
| 263 | description => 'The AI Firewall policy that was applied. Present only when AI Firewall ran.', | ||
| 264 | format => '', | ||
| 265 | read_only => 'false', | ||
| 266 | }, | ||
| 267 | 'firewall_incomplete_reason' => { | ||
| 268 | datatype => 'string', | ||
| 269 | base_name => 'firewall_incomplete_reason', | ||
| 270 | description => 'Why AI Firewall inspection was incomplete, if applicable. Present only when AI Firewall ran and inspection didn't complete.', | ||
| 271 | format => '', | ||
| 272 | read_only => 'false', | ||
| 273 | }, | ||
| 274 | 'created_at' => { | ||
| 275 | datatype => 'DateTime', | ||
| 276 | base_name => 'created_at', | ||
| 277 | description => 'The date and time the session was created, in RFC 3339 format.', | ||
| 278 | format => 'date-time', | ||
| 279 | read_only => 'true', | ||
| 280 | }, | ||
| 281 | 'updated_at' => { | ||
| 282 | datatype => 'DateTime', | ||
| 283 | base_name => 'updated_at', | ||
| 284 | description => 'The date and time the session was last updated, in RFC 3339 format.', | ||
| 285 | format => 'date-time', | ||
| 286 | read_only => 'true', | ||
| 287 | }, | ||
| 288 | 'logs' => { | ||
| 289 | datatype => 'ARRAY[ArcSessionLogEntry]', | ||
| 290 | base_name => 'logs', | ||
| 291 | description => 'The request and response pairs recorded for this session.', | ||
| 292 | format => '', | ||
| 293 | read_only => 'false', | ||
| 294 | }, | ||
| 295 | }); | ||
| 296 | |||
| 297 | __PACKAGE__->openapi_types( { | ||
| 298 | 'id' => 'string', | ||
| 299 | 'virtual_key_id' => 'string', | ||
| 300 | 'virtual_key_name' => 'string', | ||
| 301 | 'model' => 'string', | ||
| 302 | 'provider' => 'string', | ||
| 303 | 'provider_connection_id' => 'string', | ||
| 304 | 'primary_provider' => 'string', | ||
| 305 | 'requests' => 'int', | ||
| 306 | 'input_tokens' => 'int', | ||
| 307 | 'output_tokens' => 'int', | ||
| 308 | 'violations' => 'int', | ||
| 309 | 'firewall_enabled' => 'boolean', | ||
| 310 | 'firewall_outcome' => 'string', | ||
| 311 | 'firewall_stage' => 'string', | ||
| 312 | 'firewall_policy' => 'string', | ||
| 313 | 'firewall_incomplete_reason' => 'string', | ||
| 314 | 'created_at' => 'DateTime', | ||
| 315 | 'updated_at' => 'DateTime', | ||
| 316 | 'logs' => 'ARRAY[ArcSessionLogEntry]' | ||
| 317 | } ); | ||
| 318 | |||
| 319 | __PACKAGE__->attribute_map( { | ||
| 320 | 'id' => 'id', | ||
| 321 | 'virtual_key_id' => 'virtual_key_id', | ||
| 322 | 'virtual_key_name' => 'virtual_key_name', | ||
| 323 | 'model' => 'model', | ||
| 324 | 'provider' => 'provider', | ||
| 325 | 'provider_connection_id' => 'provider_connection_id', | ||
| 326 | 'primary_provider' => 'primary_provider', | ||
| 327 | 'requests' => 'requests', | ||
| 328 | 'input_tokens' => 'input_tokens', | ||
| 329 | 'output_tokens' => 'output_tokens', | ||
| 330 | 'violations' => 'violations', | ||
| 331 | 'firewall_enabled' => 'firewall_enabled', | ||
| 332 | 'firewall_outcome' => 'firewall_outcome', | ||
| 333 | 'firewall_stage' => 'firewall_stage', | ||
| 334 | 'firewall_policy' => 'firewall_policy', | ||
| 335 | 'firewall_incomplete_reason' => 'firewall_incomplete_reason', | ||
| 336 | 'created_at' => 'created_at', | ||
| 337 | 'updated_at' => 'updated_at', | ||
| 338 | 'logs' => 'logs' | ||
| 339 | } ); | ||
| 340 | |||
| 341 | __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); | ||
| 342 | |||
| 343 | __PACKAGE__->openapi_nullable( { | ||
| 344 | } ); | ||
| 345 | |||
| 346 | |||
| 347 | 1; |