NAME

WWW::Hetzner::Cloud::API::LoadBalancers - Hetzner Cloud Load Balancers API

VERSION

version 0.002

SYNOPSIS

my $cloud = WWW::Hetzner::Cloud->new(token => $token);

# List load balancers
my $lbs = $cloud->load_balancers->list;

# Create load balancer
my $lb = $cloud->load_balancers->create(
    name               => 'my-lb',
    load_balancer_type => 'lb11',
    location           => 'fsn1',
);

# Add target
$cloud->load_balancers->add_target($lb->id,
    type   => 'server',
    server => { id => 123 },
);

# Add service
$cloud->load_balancers->add_service($lb->id,
    protocol         => 'http',
    listen_port      => 80,
    destination_port => 8080,
);

# Delete
$cloud->load_balancers->delete($lb->id);

DESCRIPTION

This module provides the API for managing Hetzner Cloud load balancers. All methods return WWW::Hetzner::Cloud::LoadBalancer objects.

list

my $lbs = $cloud->load_balancers->list;
my $lbs = $cloud->load_balancers->list(label_selector => 'env=prod');

Returns arrayref of WWW::Hetzner::Cloud::LoadBalancer objects.

get

my $lb = $cloud->load_balancers->get($id);

Returns WWW::Hetzner::Cloud::LoadBalancer object.

create

my $lb = $cloud->load_balancers->create(
    name               => 'my-lb',       # required
    load_balancer_type => 'lb11',        # required
    location           => 'fsn1',        # required
    algorithm          => { type => 'round_robin' },  # optional
    labels             => { ... },       # optional
    network            => $network_id,   # optional
    network_zone       => 'eu-central',  # optional
    public_interface   => 1,             # optional
    services           => [ ... ],       # optional
    targets            => [ ... ],       # optional
);

Creates load balancer. Returns WWW::Hetzner::Cloud::LoadBalancer object.

update

$cloud->load_balancers->update($id, name => 'new-name', labels => { ... });

Updates load balancer. Returns WWW::Hetzner::Cloud::LoadBalancer object.

delete

$cloud->load_balancers->delete($id);

Deletes load balancer.

add_target

$cloud->load_balancers->add_target($id,
    type   => 'server',
    server => { id => 123 },
);

Add a target to the load balancer.

remove_target

$cloud->load_balancers->remove_target($id,
    type   => 'server',
    server => { id => 123 },
);

Remove a target from the load balancer.

add_service

$cloud->load_balancers->add_service($id,
    protocol         => 'http',
    listen_port      => 80,
    destination_port => 8080,
);

Add a service to the load balancer.

delete_service

$cloud->load_balancers->delete_service($id, $listen_port);

Delete a service from the load balancer.

attach_to_network

$cloud->load_balancers->attach_to_network($id, $network_id, ip => '10.0.0.5');

Attach load balancer to a network.

detach_from_network

$cloud->load_balancers->detach_from_network($id, $network_id);

Detach load balancer from a network.

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-hetzner/issues.

IRC

Join #kubernetes on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.