| 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::PurgeApi; | ||
| 19 | |||
| 20 | require 5.6.0; | ||
| 21 | use strict; | ||
| 22 | use warnings; | ||
| 23 | use utf8; | ||
| 24 | use Exporter; | ||
| 25 | use Carp qw( croak ); | ||
| 26 | use Log::Any qw($log); | ||
| 27 | |||
| 28 | use WebService::Fastly::ApiClient; | ||
| 29 | |||
| 30 | use base "Class::Data::Inheritable"; | ||
| 31 | |||
| 32 | __PACKAGE__->mk_classdata('method_documentation' => {}); | ||
| 33 | |||
| 34 | sub new { | ||
| 35 | my $class = shift; | ||
| 36 | my $api_client; | ||
| 37 | |||
| 38 | if ($_[0] && ref $_[0] && ref $_[0] eq 'WebService::Fastly::ApiClient' ) { | ||
| 39 | $api_client = $_[0]; | ||
| 40 | } else { | ||
| 41 | $api_client = WebService::Fastly::ApiClient->new(@_); | ||
| 42 | } | ||
| 43 | |||
| 44 | bless { api_client => $api_client }, $class; | ||
| 45 | |||
| 46 | } | ||
| 47 | |||
| 48 | |||
| 49 | # | ||
| 50 | # bulk_purge_tag | ||
| 51 | # | ||
| 52 | # Purge multiple surrogate key tags | ||
| 53 | # | ||
| 54 | # @param string $service_id Alphanumeric string identifying the service. (required) | ||
| 55 | # @param int $fastly_soft_purge If present, this header triggers the purge to be 'soft', which marks the affected object as stale rather than making it inaccessible. Typically set to \"1\" when used, but the value is not important. (optional) | ||
| 56 | # @param string $fastly_purge_environment Set to `staging` to purge the cache of the service's [staging environment](https://www.fastly.com/documentation/guides/getting-started/services/working-with-staging/) instead of its production environment. If this header is not present, the purge applies to the production environment. (optional) | ||
| 57 | # @param string $surrogate_key Purge multiple surrogate key tags using a request header. Not required if a JSON POST body is specified. (optional) | ||
| 58 | # @param PurgeResponse $purge_response (optional) | ||
| 59 | { | ||
| 60 | my $params = { | ||
| 61 | 'service_id' => { | ||
| 62 | data_type => 'string', | ||
| 63 | description => 'Alphanumeric string identifying the service.', | ||
| 64 | required => '1', | ||
| 65 | }, | ||
| 66 | 'fastly_soft_purge' => { | ||
| 67 | data_type => 'int', | ||
| 68 | description => 'If present, this header triggers the purge to be 'soft', which marks the affected object as stale rather than making it inaccessible. Typically set to \"1\" when used, but the value is not important.', | ||
| 69 | required => '0', | ||
| 70 | }, | ||
| 71 | 'fastly_purge_environment' => { | ||
| 72 | data_type => 'string', | ||
| 73 | description => 'Set to `staging` to purge the cache of the service's [staging environment](https://www.fastly.com/documentation/guides/getting-started/services/working-with-staging/) instead of its production environment. If this header is not present, the purge applies to the production environment.', | ||
| 74 | required => '0', | ||
| 75 | }, | ||
| 76 | 'surrogate_key' => { | ||
| 77 | data_type => 'string', | ||
| 78 | description => 'Purge multiple surrogate key tags using a request header. Not required if a JSON POST body is specified.', | ||
| 79 | required => '0', | ||
| 80 | }, | ||
| 81 | 'purge_response' => { | ||
| 82 | data_type => 'PurgeResponse', | ||
| 83 | description => '', | ||
| 84 | required => '0', | ||
| 85 | }, | ||
| 86 | }; | ||
| 87 | __PACKAGE__->method_documentation->{ 'bulk_purge_tag' } = { | ||
| 88 | summary => 'Purge multiple surrogate key tags', | ||
| 89 | params => $params, | ||
| 90 | returns => 'HASH[string,string]', | ||
| 91 | }; | ||
| 92 | } | ||
| 93 | # @return HASH[string,string] | ||
| 94 | # | ||
| 95 | sub bulk_purge_tag { | ||
| 96 | my ($self, %args) = @_; | ||
| 97 | |||
| 98 | # verify the required parameter 'service_id' is set | ||
| 99 | unless (exists $args{'service_id'}) { | ||
| 100 | croak("Missing the required parameter 'service_id' when calling bulk_purge_tag"); | ||
| 101 | } | ||
| 102 | |||
| 103 | # parse inputs | ||
| 104 | my $_resource_path = '/service/{service_id}/purge'; | ||
| 105 | |||
| 106 | my $_method = 'POST'; | ||
| 107 | my $query_params = {}; | ||
| 108 | my $header_params = {}; | ||
| 109 | my $form_params = {}; | ||
| 110 | |||
| 111 | # 'Accept' and 'Content-Type' header | ||
| 112 | my $_header_accept = $self->{api_client}->select_header_accept('application/json'); | ||
| 113 | if ($_header_accept) { | ||
| 114 | $header_params->{'Accept'} = $_header_accept; | ||
| 115 | } | ||
| 116 | $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json'); | ||
| 117 | |||
| 118 | # header params | ||
| 119 | if ( exists $args{'fastly_soft_purge'}) { | ||
| 120 | $header_params->{'fastly-soft-purge'} = $self->{api_client}->to_header_value($args{'fastly_soft_purge'}); | ||
| 121 | } | ||
| 122 | |||
| 123 | # header params | ||
| 124 | if ( exists $args{'fastly_purge_environment'}) { | ||
| 125 | $header_params->{'fastly-purge-environment'} = $self->{api_client}->to_header_value($args{'fastly_purge_environment'}); | ||
| 126 | } | ||
| 127 | |||
| 128 | # header params | ||
| 129 | if ( exists $args{'surrogate_key'}) { | ||
| 130 | $header_params->{'surrogate-key'} = $self->{api_client}->to_header_value($args{'surrogate_key'}); | ||
| 131 | } | ||
| 132 | |||
| 133 | # path params | ||
| 134 | if ( exists $args{'service_id'}) { | ||
| 135 | my $_base_variable = "{" . "service_id" . "}"; | ||
| 136 | my $_base_value = $self->{api_client}->to_path_value($args{'service_id'}); | ||
| 137 | $_resource_path =~ s/$_base_variable/$_base_value/g; | ||
| 138 | } | ||
| 139 | |||
| 140 | my $_body_data; | ||
| 141 | # body params | ||
| 142 | if ( exists $args{'purge_response'}) { | ||
| 143 | $_body_data = $args{'purge_response'}; | ||
| 144 | } | ||
| 145 | |||
| 146 | # authentication setting, if any | ||
| 147 | my $auth_settings = [qw(token )]; | ||
| 148 | |||
| 149 | # make the API Call | ||
| 150 | my $response = $self->{api_client}->call_api($_resource_path, $_method, | ||
| 151 | $query_params, $form_params, | ||
| 152 | $header_params, $_body_data, $auth_settings); | ||
| 153 | if (!$response) { | ||
| 154 | return; | ||
| 155 | } | ||
| 156 | my $_response_object = $self->{api_client}->deserialize('HASH[string,string]', $response); | ||
| 157 | return $_response_object; | ||
| 158 | } | ||
| 159 | |||
| 160 | # | ||
| 161 | # purge_all | ||
| 162 | # | ||
| 163 | # Purge everything from a service | ||
| 164 | # | ||
| 165 | # @param string $service_id Alphanumeric string identifying the service. (required) | ||
| 166 | # @param string $fastly_purge_environment Set to `staging` to purge the cache of the service's [staging environment](https://www.fastly.com/documentation/guides/getting-started/services/working-with-staging/) instead of its production environment. If this header is not present, the purge applies to the production environment. (optional) | ||
| 167 | { | ||
| 168 | my $params = { | ||
| 169 | 'service_id' => { | ||
| 170 | data_type => 'string', | ||
| 171 | description => 'Alphanumeric string identifying the service.', | ||
| 172 | required => '1', | ||
| 173 | }, | ||
| 174 | 'fastly_purge_environment' => { | ||
| 175 | data_type => 'string', | ||
| 176 | description => 'Set to `staging` to purge the cache of the service's [staging environment](https://www.fastly.com/documentation/guides/getting-started/services/working-with-staging/) instead of its production environment. If this header is not present, the purge applies to the production environment.', | ||
| 177 | required => '0', | ||
| 178 | }, | ||
| 179 | }; | ||
| 180 | __PACKAGE__->method_documentation->{ 'purge_all' } = { | ||
| 181 | summary => 'Purge everything from a service', | ||
| 182 | params => $params, | ||
| 183 | returns => 'InlineResponse200', | ||
| 184 | }; | ||
| 185 | } | ||
| 186 | # @return InlineResponse200 | ||
| 187 | # | ||
| 188 | sub purge_all { | ||
| 189 | my ($self, %args) = @_; | ||
| 190 | |||
| 191 | # verify the required parameter 'service_id' is set | ||
| 192 | unless (exists $args{'service_id'}) { | ||
| 193 | croak("Missing the required parameter 'service_id' when calling purge_all"); | ||
| 194 | } | ||
| 195 | |||
| 196 | # parse inputs | ||
| 197 | my $_resource_path = '/service/{service_id}/purge_all'; | ||
| 198 | |||
| 199 | my $_method = 'POST'; | ||
| 200 | my $query_params = {}; | ||
| 201 | my $header_params = {}; | ||
| 202 | my $form_params = {}; | ||
| 203 | |||
| 204 | # 'Accept' and 'Content-Type' header | ||
| 205 | my $_header_accept = $self->{api_client}->select_header_accept('application/json'); | ||
| 206 | if ($_header_accept) { | ||
| 207 | $header_params->{'Accept'} = $_header_accept; | ||
| 208 | } | ||
| 209 | $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type(); | ||
| 210 | |||
| 211 | # header params | ||
| 212 | if ( exists $args{'fastly_purge_environment'}) { | ||
| 213 | $header_params->{'fastly-purge-environment'} = $self->{api_client}->to_header_value($args{'fastly_purge_environment'}); | ||
| 214 | } | ||
| 215 | |||
| 216 | # path params | ||
| 217 | if ( exists $args{'service_id'}) { | ||
| 218 | my $_base_variable = "{" . "service_id" . "}"; | ||
| 219 | my $_base_value = $self->{api_client}->to_path_value($args{'service_id'}); | ||
| 220 | $_resource_path =~ s/$_base_variable/$_base_value/g; | ||
| 221 | } | ||
| 222 | |||
| 223 | my $_body_data; | ||
| 224 | # authentication setting, if any | ||
| 225 | my $auth_settings = [qw(token )]; | ||
| 226 | |||
| 227 | # make the API Call | ||
| 228 | my $response = $self->{api_client}->call_api($_resource_path, $_method, | ||
| 229 | $query_params, $form_params, | ||
| 230 | $header_params, $_body_data, $auth_settings); | ||
| 231 | if (!$response) { | ||
| 232 | return; | ||
| 233 | } | ||
| 234 | my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response); | ||
| 235 | return $_response_object; | ||
| 236 | } | ||
| 237 | |||
| 238 | # | ||
| 239 | # purge_single_url | ||
| 240 | # | ||
| 241 | # Purge a URL | ||
| 242 | # | ||
| 243 | # @param string $cached_url URL of object in cache to be purged. (required) | ||
| 244 | # @param int $fastly_soft_purge If present, this header triggers the purge to be 'soft', which marks the affected object as stale rather than making it inaccessible. Typically set to \"1\" when used, but the value is not important. (optional) | ||
| 245 | { | ||
| 246 | my $params = { | ||
| 247 | 'cached_url' => { | ||
| 248 | data_type => 'string', | ||
| 249 | description => 'URL of object in cache to be purged.', | ||
| 250 | required => '1', | ||
| 251 | }, | ||
| 252 | 'fastly_soft_purge' => { | ||
| 253 | data_type => 'int', | ||
| 254 | description => 'If present, this header triggers the purge to be 'soft', which marks the affected object as stale rather than making it inaccessible. Typically set to \"1\" when used, but the value is not important.', | ||
| 255 | required => '0', | ||
| 256 | }, | ||
| 257 | }; | ||
| 258 | __PACKAGE__->method_documentation->{ 'purge_single_url' } = { | ||
| 259 | summary => 'Purge a URL', | ||
| 260 | params => $params, | ||
| 261 | returns => 'PurgeResponse', | ||
| 262 | }; | ||
| 263 | } | ||
| 264 | # @return PurgeResponse | ||
| 265 | # | ||
| 266 | sub purge_single_url { | ||
| 267 | my ($self, %args) = @_; | ||
| 268 | |||
| 269 | # verify the required parameter 'cached_url' is set | ||
| 270 | unless (exists $args{'cached_url'}) { | ||
| 271 | croak("Missing the required parameter 'cached_url' when calling purge_single_url"); | ||
| 272 | } | ||
| 273 | |||
| 274 | # parse inputs | ||
| 275 | my $_resource_path = '/purge/{cached_url}'; | ||
| 276 | |||
| 277 | my $_method = 'POST'; | ||
| 278 | my $query_params = {}; | ||
| 279 | my $header_params = {}; | ||
| 280 | my $form_params = {}; | ||
| 281 | |||
| 282 | # 'Accept' and 'Content-Type' header | ||
| 283 | my $_header_accept = $self->{api_client}->select_header_accept('application/json'); | ||
| 284 | if ($_header_accept) { | ||
| 285 | $header_params->{'Accept'} = $_header_accept; | ||
| 286 | } | ||
| 287 | $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type(); | ||
| 288 | |||
| 289 | # header params | ||
| 290 | if ( exists $args{'fastly_soft_purge'}) { | ||
| 291 | $header_params->{'fastly-soft-purge'} = $self->{api_client}->to_header_value($args{'fastly_soft_purge'}); | ||
| 292 | } | ||
| 293 | |||
| 294 | # path params | ||
| 295 | if ( exists $args{'cached_url'}) { | ||
| 296 | my $_base_variable = "{" . "cached_url" . "}"; | ||
| 297 | my $_base_value = $self->{api_client}->to_path_value($args{'cached_url'}, 1); | ||
| 298 | $_resource_path =~ s/$_base_variable/$_base_value/g; | ||
| 299 | } | ||
| 300 | |||
| 301 | my $_body_data; | ||
| 302 | # authentication setting, if any | ||
| 303 | my $auth_settings = [qw(token )]; | ||
| 304 | |||
| 305 | # make the API Call | ||
| 306 | my $response = $self->{api_client}->call_api($_resource_path, $_method, | ||
| 307 | $query_params, $form_params, | ||
| 308 | $header_params, $_body_data, $auth_settings); | ||
| 309 | if (!$response) { | ||
| 310 | return; | ||
| 311 | } | ||
| 312 | my $_response_object = $self->{api_client}->deserialize('PurgeResponse', $response); | ||
| 313 | return $_response_object; | ||
| 314 | } | ||
| 315 | |||
| 316 | # | ||
| 317 | # purge_tag | ||
| 318 | # | ||
| 319 | # Purge by surrogate key tag | ||
| 320 | # | ||
| 321 | # @param string $service_id Alphanumeric string identifying the service. (required) | ||
| 322 | # @param string $surrogate_key Surrogate keys are used to efficiently purge content from cache. Instead of purging your entire site or individual URLs, you can tag related assets (like all images and descriptions associated with a single product) with surrogate keys, and these grouped URLs can be purged in a single request. (required) | ||
| 323 | # @param int $fastly_soft_purge If present, this header triggers the purge to be 'soft', which marks the affected object as stale rather than making it inaccessible. Typically set to \"1\" when used, but the value is not important. (optional) | ||
| 324 | # @param string $fastly_purge_environment Set to `staging` to purge the cache of the service's [staging environment](https://www.fastly.com/documentation/guides/getting-started/services/working-with-staging/) instead of its production environment. If this header is not present, the purge applies to the production environment. (optional) | ||
| 325 | { | ||
| 326 | my $params = { | ||
| 327 | 'service_id' => { | ||
| 328 | data_type => 'string', | ||
| 329 | description => 'Alphanumeric string identifying the service.', | ||
| 330 | required => '1', | ||
| 331 | }, | ||
| 332 | 'surrogate_key' => { | ||
| 333 | data_type => 'string', | ||
| 334 | description => 'Surrogate keys are used to efficiently purge content from cache. Instead of purging your entire site or individual URLs, you can tag related assets (like all images and descriptions associated with a single product) with surrogate keys, and these grouped URLs can be purged in a single request.', | ||
| 335 | required => '1', | ||
| 336 | }, | ||
| 337 | 'fastly_soft_purge' => { | ||
| 338 | data_type => 'int', | ||
| 339 | description => 'If present, this header triggers the purge to be 'soft', which marks the affected object as stale rather than making it inaccessible. Typically set to \"1\" when used, but the value is not important.', | ||
| 340 | required => '0', | ||
| 341 | }, | ||
| 342 | 'fastly_purge_environment' => { | ||
| 343 | data_type => 'string', | ||
| 344 | description => 'Set to `staging` to purge the cache of the service's [staging environment](https://www.fastly.com/documentation/guides/getting-started/services/working-with-staging/) instead of its production environment. If this header is not present, the purge applies to the production environment.', | ||
| 345 | required => '0', | ||
| 346 | }, | ||
| 347 | }; | ||
| 348 | __PACKAGE__->method_documentation->{ 'purge_tag' } = { | ||
| 349 | summary => 'Purge by surrogate key tag', | ||
| 350 | params => $params, | ||
| 351 | returns => 'PurgeResponse', | ||
| 352 | }; | ||
| 353 | } | ||
| 354 | # @return PurgeResponse | ||
| 355 | # | ||
| 356 | sub purge_tag { | ||
| 357 | my ($self, %args) = @_; | ||
| 358 | |||
| 359 | # verify the required parameter 'service_id' is set | ||
| 360 | unless (exists $args{'service_id'}) { | ||
| 361 | croak("Missing the required parameter 'service_id' when calling purge_tag"); | ||
| 362 | } | ||
| 363 | |||
| 364 | # verify the required parameter 'surrogate_key' is set | ||
| 365 | unless (exists $args{'surrogate_key'}) { | ||
| 366 | croak("Missing the required parameter 'surrogate_key' when calling purge_tag"); | ||
| 367 | } | ||
| 368 | |||
| 369 | # parse inputs | ||
| 370 | my $_resource_path = '/service/{service_id}/purge/{surrogate_key}'; | ||
| 371 | |||
| 372 | my $_method = 'POST'; | ||
| 373 | my $query_params = {}; | ||
| 374 | my $header_params = {}; | ||
| 375 | my $form_params = {}; | ||
| 376 | |||
| 377 | # 'Accept' and 'Content-Type' header | ||
| 378 | my $_header_accept = $self->{api_client}->select_header_accept('application/json'); | ||
| 379 | if ($_header_accept) { | ||
| 380 | $header_params->{'Accept'} = $_header_accept; | ||
| 381 | } | ||
| 382 | $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type(); | ||
| 383 | |||
| 384 | # header params | ||
| 385 | if ( exists $args{'fastly_soft_purge'}) { | ||
| 386 | $header_params->{'fastly-soft-purge'} = $self->{api_client}->to_header_value($args{'fastly_soft_purge'}); | ||
| 387 | } | ||
| 388 | |||
| 389 | # header params | ||
| 390 | if ( exists $args{'fastly_purge_environment'}) { | ||
| 391 | $header_params->{'fastly-purge-environment'} = $self->{api_client}->to_header_value($args{'fastly_purge_environment'}); | ||
| 392 | } | ||
| 393 | |||
| 394 | # path params | ||
| 395 | if ( exists $args{'service_id'}) { | ||
| 396 | my $_base_variable = "{" . "service_id" . "}"; | ||
| 397 | my $_base_value = $self->{api_client}->to_path_value($args{'service_id'}); | ||
| 398 | $_resource_path =~ s/$_base_variable/$_base_value/g; | ||
| 399 | } | ||
| 400 | |||
| 401 | # path params | ||
| 402 | if ( exists $args{'surrogate_key'}) { | ||
| 403 | my $_base_variable = "{" . "surrogate_key" . "}"; | ||
| 404 | my $_base_value = $self->{api_client}->to_path_value($args{'surrogate_key'}, 1); | ||
| 405 | $_resource_path =~ s/$_base_variable/$_base_value/g; | ||
| 406 | } | ||
| 407 | |||
| 408 | my $_body_data; | ||
| 409 | # authentication setting, if any | ||
| 410 | my $auth_settings = [qw(token )]; | ||
| 411 | |||
| 412 | # make the API Call | ||
| 413 | my $response = $self->{api_client}->call_api($_resource_path, $_method, | ||
| 414 | $query_params, $form_params, | ||
| 415 | $header_params, $_body_data, $auth_settings); | ||
| 416 | if (!$response) { | ||
| 417 | return; | ||
| 418 | } | ||
| 419 | my $_response_object = $self->{api_client}->deserialize('PurgeResponse', $response); | ||
| 420 | return $_response_object; | ||
| 421 | } | ||
| 422 | |||
| 423 | 1; |