NAME

VM::HetznerCloud::API::LoadBalancers - LoadBalancers

VERSION

version 0.0.3

SYNOPSIS

use VM::HetznerCloud;

my $api_key = '1234abc';
my $cloud   = VM::HetznerCloud->new(
    token => $api_key,
);

$cloud->records->create(
);

ATTRIBUTES

  • endpoint

METHODS

list

Gets all existing Load Balancers that you have available.

$cloud->load_balancers->list(
    label_selector => 'test',
    name => 'test',
    sort => 'test',
);

create

Creates a Load Balancer.

#### Call specific error codes

| Code | Description | |-----------------------------------------|-------------------------------------------------------------------------------------------------------| | `cloud_resource_ip_not_allowed` | The IP you are trying to add as a target belongs to a Hetzner Cloud resource | | `ip_not_owned` | The IP is not owned by the owner of the project of the Load Balancer | | `load_balancer_not_attached_to_network` | The Load Balancer is not attached to a network | | `robot_unavailable` | Robot was not available. The caller may retry the operation after a short delay. | | `server_not_attached_to_network` | The server you are trying to add as a target is not attached to the same network as the Load Balancer | | `source_port_already_used` | The source port you are trying to add is already in use | | `target_already_defined` | The Load Balancer target you are trying to define is already defined |

$cloud->load_balancers->create();

delete

Deletes a Load Balancer.

$cloud->load_balancers->delete(
    id => 'test',
);

get

Gets a specific Load Balancer object.

$cloud->load_balancers->get(
    id => 'test',
);

put

Updates a Load Balancer. You can update a Load Balancer’s name and a Load Balancer’s labels.

Note that when updating labels, the Load Balancer’s current set of labels will be replaced with the labels provided in the request body. So, for example, if you want to add a new label, you have to provide all existing labels plus the new label in the request body.

Note: if the Load Balancer object changes during the request, the response will be a “conflict” error.

$cloud->load_balancers->put(
    id => 'test',
);

list_actions

Returns all Action objects for a Load Balancer. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter.

$cloud->load_balancers->list_actions(
    id => 'test',
    sort => 'test',
    status => 'test',
);

add_service

Adds a service to a Load Balancer.

#### Call specific error codes

| Code | Description | |----------------------------|---------------------------------------------------------| | `source_port_already_used` | The source port you are trying to add is already in use |

$cloud->load_balancers->add_service(
    id => 'test',
);

add_target

Adds a target to a Load Balancer.

#### Call specific error codes

| Code | Description | |-----------------------------------------|-------------------------------------------------------------------------------------------------------| | `cloud_resource_ip_not_allowed` | The IP you are trying to add as a target belongs to a Hetzner Cloud resource | | `ip_not_owned` | The IP you are trying to add as a target is not owned by the Project owner | | `load_balancer_not_attached_to_network` | The Load Balancer is not attached to a network | | `robot_unavailable` | Robot was not available. The caller may retry the operation after a short delay. | | `server_not_attached_to_network` | The server you are trying to add as a target is not attached to the same network as the Load Balancer | | `target_already_defined` | The Load Balancer target you are trying to define is already defined |

$cloud->load_balancers->add_target(
    id => 'test',
);

attach_to_network

Attach a Load Balancer to a Network.

**Call specific error codes**

| Code | Description | |----------------------------------|-----------------------------------------------------------------------| | `load_balancer_already_attached` | The Load Balancer is already attached to a network | | `ip_not_available` | The provided Network IP is not available | | `no_subnet_available` | No Subnet or IP is available for the Load Balancer within the network |

$cloud->load_balancers->attach_to_network(
    id => 'test',
);

change_algorithm

Change the algorithm that determines to which target new requests are sent.

$cloud->load_balancers->change_algorithm(
    id => 'test',
);

change_dns_ptr

Changes the hostname that will appear when getting the hostname belonging to the public IPs (IPv4 and IPv6) of this Load Balancer.

Floating IPs assigned to the Server are not affected by this.

$cloud->load_balancers->change_dns_ptr(
    id => 'test',
);

change_protection

Changes the protection configuration of a Load Balancer.

$cloud->load_balancers->change_protection(
    id => 'test',
);

change_type

Changes the type (Max Services, Max Targets and Max Connections) of a Load Balancer.

**Call specific error codes**

| Code | Description | |------------------------------|-----------------------------------------------------------------| | `invalid_load_balancer_type` | The Load Balancer type does not fit for the given Load Balancer |

$cloud->load_balancers->change_type(
    id => 'test',
);

delete_service

Delete a service of a Load Balancer.

$cloud->load_balancers->delete_service(
    id => 'test',
);

detach_from_network

Detaches a Load Balancer from a network.

$cloud->load_balancers->detach_from_network(
    id => 'test',
);

disable_public_interface

Disable the public interface of a Load Balancer. The Load Balancer will be not accessible from the internet via its public IPs.

#### Call specific error codes

| Code | Description | |-------------------------------------------|--------------------------------------------------------------------------------| | `load_balancer_not_attached_to_network` | The Load Balancer is not attached to a network | | `targets_without_use_private_ip` | The Load Balancer has targets that use the public IP instead of the private IP |

$cloud->load_balancers->disable_public_interface(
    id => 'test',
);

enable_public_interface

Enable the public interface of a Load Balancer. The Load Balancer will be accessible from the internet via its public IPs.

$cloud->load_balancers->enable_public_interface(
    id => 'test',
);

remove_target

Removes a target from a Load Balancer.

$cloud->load_balancers->remove_target(
    id => 'test',
);

update_service

Updates a Load Balancer Service.

#### Call specific error codes

| Code | Description | |----------------------------|---------------------------------------------------------| | `source_port_already_used` | The source port you are trying to add is already in use |

$cloud->load_balancers->update_service(
    id => 'test',
);

get_actions

Returns a specific Action for a Load Balancer.

$cloud->load_balancers->get_actions(
    action_id => 'test',
    id => 'test',
);

list_metrics

You must specify the type of metric to get: `open_connections`, `connections_per_second`, `requests_per_second` or `bandwidth`. You can also specify more than one type by comma separation, e.g. `requests_per_second,bandwidth`.

Depending on the type you will get different time series data:

|Type | Timeseries | Unit | Description | |---- |------------|------|-------------| | open_connections | open_connections | number | Open connections | | connections_per_second | connections_per_second | connections/s | Connections per second | | requests_per_second | requests_per_second | requests/s | Requests per second | | bandwidth | bandwidth.in | bytes/s | Ingress bandwidth | || bandwidth.out | bytes/s | Egress bandwidth |

Metrics are available for the last 30 days only.

If you do not provide the step argument we will automatically adjust it so that 200 samples are returned.

We limit the number of samples to a maximum of 500 and will adjust the step parameter accordingly.

$cloud->load_balancers->list_metrics(
    end => 'test',
    id => 'test',
    start => 'test',
    step => 'test',
    type => 'test',
);

AUTHOR

Renee Baecker <reneeb@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 by Renee Baecker.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)