The Perl Toolchain Summit 2025 Needs You: You can help 🙏 Learn more

=begin comment
Fastly API
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/)
The version of the API Spec document: 1.0.0
Contact: oss@fastly.com
=end comment
=cut
#
# NOTE: This class is auto generated.
# Do not edit the class manually.
#
require 5.6.0;
use strict;
use utf8;
use Carp qw( croak );
use Log::Any qw($log);
__PACKAGE__->mk_classdata('method_documentation' => {});
sub new {
my $class = shift;
my $api_client;
if ($_[0] && ref $_[0] && ref $_[0] eq 'WebService::Fastly::ApiClient' ) {
$api_client = $_[0];
} else {
$api_client = WebService::Fastly::ApiClient->new(@_);
}
bless { api_client => $api_client }, $class;
}
#
# create_director
#
# Create a director
#
# @param string $service_id Alphanumeric string identifying the service. (required)
# @param int $version_id Integer identifying a service version. (required)
# @param ARRAY[Backend] $backends List of backends associated to a director. (optional)
# @param int $capacity Unused. (optional)
# @param string $comment A freeform descriptive note. (optional)
# @param string $name Name for the Director. (optional)
# @param int $quorum The percentage of capacity that needs to be up for a director to be considered up. `0` to `100`. (optional, default to 75)
# @param string $shield Selected POP to serve as a shield for the backends. Defaults to `null` meaning no origin shielding if not set. Refer to the [POPs API endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/) to get a list of available POPs used for shielding. (optional, default to 'null')
# @param int $type What type of load balance group to use. (optional, default to 1)
# @param int $retries How many backends to search if it fails. (optional, default to 5)
{
my $params = {
'service_id' => {
data_type => 'string',
description => 'Alphanumeric string identifying the service.',
required => '1',
},
'version_id' => {
data_type => 'int',
description => 'Integer identifying a service version.',
required => '1',
},
'backends' => {
data_type => 'ARRAY[Backend]',
description => 'List of backends associated to a director.',
required => '0',
},
'capacity' => {
data_type => 'int',
description => 'Unused.',
required => '0',
},
'comment' => {
data_type => 'string',
description => 'A freeform descriptive note.',
required => '0',
},
'name' => {
data_type => 'string',
description => 'Name for the Director.',
required => '0',
},
'quorum' => {
data_type => 'int',
description => 'The percentage of capacity that needs to be up for a director to be considered up. `0` to `100`.',
required => '0',
},
'shield' => {
data_type => 'string',
description => 'Selected POP to serve as a shield for the backends. Defaults to `null` meaning no origin shielding if not set. Refer to the [POPs API endpoint](https://www.fastly.com/documentation/reference/api/utils/pops/) to get a list of available POPs used for shielding.',
required => '0',
},
'type' => {
data_type => 'int',
description => 'What type of load balance group to use.',
required => '0',
},
'retries' => {
data_type => 'int',
description => 'How many backends to search if it fails.',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'create_director' } = {
summary => 'Create a director',
params => $params,
returns => 'DirectorResponse',
};
}
# @return DirectorResponse
#
sub create_director {
my ($self, %args) = @_;
# verify the required parameter 'service_id' is set
unless (exists $args{'service_id'}) {
croak("Missing the required parameter 'service_id' when calling create_director");
}
# verify the required parameter 'version_id' is set
unless (exists $args{'version_id'}) {
croak("Missing the required parameter 'version_id' when calling create_director");
}
# parse inputs
my $_resource_path = '/service/{service_id}/version/{version_id}/director';
my $_method = 'POST';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
# path params
if ( exists $args{'service_id'}) {
my $_base_variable = "{" . "service_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'version_id'}) {
my $_base_variable = "{" . "version_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# form params
if ( exists $args{'backends'} ) {
$form_params->{'backends'} = $self->{api_client}->to_form_value($args{'backends'});
}
# form params
if ( exists $args{'capacity'} ) {
$form_params->{'capacity'} = $self->{api_client}->to_form_value($args{'capacity'});
}
# form params
if ( exists $args{'comment'} ) {
$form_params->{'comment'} = $self->{api_client}->to_form_value($args{'comment'});
}
# form params
if ( exists $args{'name'} ) {
$form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
}
# form params
if ( exists $args{'quorum'} ) {
$form_params->{'quorum'} = $self->{api_client}->to_form_value($args{'quorum'});
}
# form params
if ( exists $args{'shield'} ) {
$form_params->{'shield'} = $self->{api_client}->to_form_value($args{'shield'});
}
# form params
if ( exists $args{'type'} ) {
$form_params->{'type'} = $self->{api_client}->to_form_value($args{'type'});
}
# form params
if ( exists $args{'retries'} ) {
$form_params->{'retries'} = $self->{api_client}->to_form_value($args{'retries'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(token )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('DirectorResponse', $response);
return $_response_object;
}
#
# delete_director
#
# Delete a director
#
# @param string $service_id Alphanumeric string identifying the service. (required)
# @param int $version_id Integer identifying a service version. (required)
# @param string $director_name Name for the Director. (required)
{
my $params = {
'service_id' => {
data_type => 'string',
description => 'Alphanumeric string identifying the service.',
required => '1',
},
'version_id' => {
data_type => 'int',
description => 'Integer identifying a service version.',
required => '1',
},
'director_name' => {
data_type => 'string',
description => 'Name for the Director.',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'delete_director' } = {
summary => 'Delete a director',
params => $params,
returns => 'InlineResponse200',
};
}
# @return InlineResponse200
#
sub delete_director {
my ($self, %args) = @_;
# verify the required parameter 'service_id' is set
unless (exists $args{'service_id'}) {
croak("Missing the required parameter 'service_id' when calling delete_director");
}
# verify the required parameter 'version_id' is set
unless (exists $args{'version_id'}) {
croak("Missing the required parameter 'version_id' when calling delete_director");
}
# verify the required parameter 'director_name' is set
unless (exists $args{'director_name'}) {
croak("Missing the required parameter 'director_name' when calling delete_director");
}
# parse inputs
my $_resource_path = '/service/{service_id}/version/{version_id}/director/{director_name}';
my $_method = 'DELETE';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'service_id'}) {
my $_base_variable = "{" . "service_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'version_id'}) {
my $_base_variable = "{" . "version_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'director_name'}) {
my $_base_variable = "{" . "director_name" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'director_name'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(token )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response);
return $_response_object;
}
#
# get_director
#
# Get a director
#
# @param string $service_id Alphanumeric string identifying the service. (required)
# @param int $version_id Integer identifying a service version. (required)
# @param string $director_name Name for the Director. (required)
{
my $params = {
'service_id' => {
data_type => 'string',
description => 'Alphanumeric string identifying the service.',
required => '1',
},
'version_id' => {
data_type => 'int',
description => 'Integer identifying a service version.',
required => '1',
},
'director_name' => {
data_type => 'string',
description => 'Name for the Director.',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'get_director' } = {
summary => 'Get a director',
params => $params,
returns => 'DirectorResponse',
};
}
# @return DirectorResponse
#
sub get_director {
my ($self, %args) = @_;
# verify the required parameter 'service_id' is set
unless (exists $args{'service_id'}) {
croak("Missing the required parameter 'service_id' when calling get_director");
}
# verify the required parameter 'version_id' is set
unless (exists $args{'version_id'}) {
croak("Missing the required parameter 'version_id' when calling get_director");
}
# verify the required parameter 'director_name' is set
unless (exists $args{'director_name'}) {
croak("Missing the required parameter 'director_name' when calling get_director");
}
# parse inputs
my $_resource_path = '/service/{service_id}/version/{version_id}/director/{director_name}';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'service_id'}) {
my $_base_variable = "{" . "service_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'version_id'}) {
my $_base_variable = "{" . "version_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'director_name'}) {
my $_base_variable = "{" . "director_name" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'director_name'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(token )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('DirectorResponse', $response);
return $_response_object;
}
#
# list_directors
#
# List directors
#
# @param string $service_id Alphanumeric string identifying the service. (required)
# @param int $version_id Integer identifying a service version. (required)
{
my $params = {
'service_id' => {
data_type => 'string',
description => 'Alphanumeric string identifying the service.',
required => '1',
},
'version_id' => {
data_type => 'int',
description => 'Integer identifying a service version.',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'list_directors' } = {
summary => 'List directors',
params => $params,
returns => 'ARRAY[DirectorResponse]',
};
}
# @return ARRAY[DirectorResponse]
#
sub list_directors {
my ($self, %args) = @_;
# verify the required parameter 'service_id' is set
unless (exists $args{'service_id'}) {
croak("Missing the required parameter 'service_id' when calling list_directors");
}
# verify the required parameter 'version_id' is set
unless (exists $args{'version_id'}) {
croak("Missing the required parameter 'version_id' when calling list_directors");
}
# parse inputs
my $_resource_path = '/service/{service_id}/version/{version_id}/director';
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'service_id'}) {
my $_base_variable = "{" . "service_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'version_id'}) {
my $_base_variable = "{" . "version_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(token )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[DirectorResponse]', $response);
return $_response_object;
}
#
# update_director
#
# Update a director
#
# @param string $service_id Alphanumeric string identifying the service. (required)
# @param int $version_id Integer identifying a service version. (required)
# @param string $director_name Name for the Director. (required)
{
my $params = {
'service_id' => {
data_type => 'string',
description => 'Alphanumeric string identifying the service.',
required => '1',
},
'version_id' => {
data_type => 'int',
description => 'Integer identifying a service version.',
required => '1',
},
'director_name' => {
data_type => 'string',
description => 'Name for the Director.',
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'update_director' } = {
summary => 'Update a director',
params => $params,
returns => 'DirectorResponse',
};
}
# @return DirectorResponse
#
sub update_director {
my ($self, %args) = @_;
# verify the required parameter 'service_id' is set
unless (exists $args{'service_id'}) {
croak("Missing the required parameter 'service_id' when calling update_director");
}
# verify the required parameter 'version_id' is set
unless (exists $args{'version_id'}) {
croak("Missing the required parameter 'version_id' when calling update_director");
}
# verify the required parameter 'director_name' is set
unless (exists $args{'director_name'}) {
croak("Missing the required parameter 'director_name' when calling update_director");
}
# parse inputs
my $_resource_path = '/service/{service_id}/version/{version_id}/director/{director_name}';
my $_method = 'PUT';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
# path params
if ( exists $args{'service_id'}) {
my $_base_variable = "{" . "service_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'version_id'}) {
my $_base_variable = "{" . "version_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'version_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# path params
if ( exists $args{'director_name'}) {
my $_base_variable = "{" . "director_name" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'director_name'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(token )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('DirectorResponse', $response);
return $_response_object;
}
1;