The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

VM::HetznerCloud::API::Networks - Networks

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 networks that you have available.

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

create

Creates a network with the specified `ip_range`.

You may specify one or more `subnets`. You can also add more Subnets later by using the [add subnet action](https://docs.hetzner.cloud/#network-actions-add-a-subnet-to-a-network). If you do not specify an `ip_range` in the subnet we will automatically pick the first available /24 range for you.

You may specify one or more routes in `routes`. You can also add more routes later by using the [add route action](https://docs.hetzner.cloud/#network-actions-add-a-route-to-a-network).

    $cloud->networks->create();

delete

Deletes a network. If there are Servers attached they will be detached in the background.

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

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

get

Gets a specific network object.

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

put

Updates the network properties.

Note that when updating labels, the network’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 network object changes during the request, the response will be a “conflict” error.

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

list_actions

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

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

add_route

Adds a route entry to a Network.

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

    $cloud->networks->add_route(
        id => 'test',
    );

add_subnet

Adds a new subnet object to the Network. If you do not specify an `ip_range` for the subnet we will automatically pick the first available /24 range for you if possible.

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

    $cloud->networks->add_subnet(
        id => 'test',
    );

change_ip_range

Changes the IP range of a Network. IP ranges can only be extended and never shrunk. You can only add IPs at the end of an existing IP range. This means that the IP part of your existing range must stay the same and you can only change its netmask.

For example if you have a range `10.0.0.0/16` you want to extend then your new range must also start with the IP `10.0.0.0`. Your CIDR netmask `/16` may change to a number that is smaller than `16` thereby increasing the IP range. So valid entries would be `10.0.0.0/15`, `10.0.0.0/14`, `10.0.0.0/13` and so on.

After changing the IP range you will have to adjust the routes on your connected Servers by either rebooting them or manually changing the routes to your private Network interface.

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

    $cloud->networks->change_ip_range(
        id => 'test',
    );

change_protection

Changes the protection configuration of a Network.

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

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

delete_route

Delete a route entry from a Network.

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

    $cloud->networks->delete_route(
        id => 'test',
    );

delete_subnet

Deletes a single subnet entry from a Network. You cannot delete subnets which still have Servers attached. If you have Servers attached you first need to detach all Servers that use IPs from this subnet before you can delete the subnet.

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

    $cloud->networks->delete_subnet(
        id => 'test',
    );

get_actions

Returns a specific Action for a Network.

    $cloud->networks->get_actions(
        action_id => 'test',
        id => '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)