# ABSTRACT: Volumes
# ---
# This class is auto-generated by bin/get_hetzner_info.pl
# ---
use v5.24;
use Moo;
use Types::Standard qw(:all);
use Mojo::Base -strict, -signatures;
use utf8;
our $VERSION = '0.0.3'; # VERSION
has endpoint => ( is => 'ro', isa => Str, default => sub { 'volumes' } );
sub list ($self, %params) {
my $request_params = {
'label_selector' => {
'in' => 'query',
'required' => 0,
'validate' => 'string',
},
'name' => {
'in' => 'query',
'required' => 0,
'validate' => 'string',
},
'sort' => {
'in' => 'query',
'required' => 0,
'validate' => 'string',
},
'status' => {
'in' => 'query',
'required' => 0,
'validate' => 'string',
},
};
return $self->_request( '', \%params, $request_params, { type => 'get', oid => '/volumes#get' } );
}
sub create ($self, %params) {
my $request_params = {};
return $self->_request( '', \%params, $request_params, { type => 'post', oid => '/volumes#post' } );
}
sub delete ($self, %params) {
my $request_params = {
'id' => {
'in' => 'path',
'required' => 1,
'validate' => 'int64',
},
};
return $self->_request( '/:id', \%params, $request_params, { type => 'delete', oid => '/volumes/{id}#delete' } );
}
sub get ($self, %params) {
my $request_params = {
'id' => {
'in' => 'path',
'required' => 1,
'validate' => 'int64',
},
};
return $self->_request( '/:id', \%params, $request_params, { type => 'get', oid => '/volumes/{id}#get' } );
}
sub put ($self, %params) {
my $request_params = {
'id' => {
'in' => 'path',
'required' => 1,
'validate' => 'int64',
},
};
return $self->_request( '/:id', \%params, $request_params, { type => 'put', oid => '/volumes/{id}#put' } );
}
sub list_actions ($self, %params) {
my $request_params = {
'id' => {
'in' => 'path',
'required' => 1,
'validate' => 'int64',
},
'sort' => {
'in' => 'query',
'required' => 0,
'validate' => 'string',
},
'status' => {
'in' => 'query',
'required' => 0,
'validate' => 'string',
},
};
return $self->_request( '/:id/actions', \%params, $request_params, { type => 'get', oid => '/volumes/{id}/actions#get' } );
}
sub attach ($self, %params) {
my $request_params = {
'id' => {
'in' => 'path',
'required' => 1,
'validate' => 'int64',
},
};
return $self->_request( '/:id/actions/attach', \%params, $request_params, { type => 'post', oid => '/volumes/{id}/actions/attach#post' } );
}
sub change_protection ($self, %params) {
my $request_params = {
'id' => {
'in' => 'path',
'required' => 1,
'validate' => 'int64',
},
};
return $self->_request( '/:id/actions/change_protection', \%params, $request_params, { type => 'post', oid => '/volumes/{id}/actions/change_protection#post' } );
}
sub detach ($self, %params) {
my $request_params = {
'id' => {
'in' => 'path',
'required' => 1,
'validate' => 'int64',
},
};
return $self->_request( '/:id/actions/detach', \%params, $request_params, { type => 'post', oid => '/volumes/{id}/actions/detach#post' } );
}
sub resize ($self, %params) {
my $request_params = {
'id' => {
'in' => 'path',
'required' => 1,
'validate' => 'int64',
},
};
return $self->_request( '/:id/actions/resize', \%params, $request_params, { type => 'post', oid => '/volumes/{id}/actions/resize#post' } );
}
sub get_actions ($self, %params) {
my $request_params = {
'action_id' => {
'in' => 'path',
'required' => 1,
'validate' => 'int64',
},
'id' => {
'in' => 'path',
'required' => 1,
'validate' => 'int64',
},
};
return $self->_request( '/:id/actions/:action_id', \%params, $request_params, { type => 'get', oid => '/volumes/{id}/actions/{action_id}#get' } );
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
VM::HetznerCloud::API::Volumes - Volumes
=head1 VERSION
version 0.0.3
=head1 SYNOPSIS
use VM::HetznerCloud;
my $api_key = '1234abc';
my $cloud = VM::HetznerCloud->new(
token => $api_key,
);
$cloud->records->create(
);
=head1 ATTRIBUTES
=over 4
=item * endpoint
=back
=head1 METHODS
=head2 list
Gets all existing Volumes that you have available.
$cloud->volumes->list(
label_selector => 'test',
name => 'test',
sort => 'test',
status => 'test',
);
=head2 create
Creates a new Volume attached to a Server. If you want to create a Volume that is not attached to a Server, you need to provide the `location` key instead of `server`. This can be either the ID or the name of the Location this Volume will be created in. Note that a Volume can be attached to a Server only in the same Location as the Volume itself.
Specifying the Server during Volume creation will automatically attach the Volume to that Server after it has been initialized. In that case, the `next_actions` key in the response is an array which contains a single `attach_volume` action.
The minimum Volume size is 10GB and the maximum size is 10TB (10240GB).
A volume’s name can consist of alphanumeric characters, dashes, underscores, and dots, but has to start and end with an alphanumeric character. The total length is limited to 64 characters. Volume names must be unique per Project.
#### Call specific error codes
| Code | Description |
|-------------------------------------|-----------------------------------------------------|
| `no_space_left_in_location` | There is no volume space left in the given location |
$cloud->volumes->create();
=head2 delete
Deletes a volume. All Volume data is irreversibly destroyed. The Volume must not be attached to a Server and it must not have delete protection enabled.
$cloud->volumes->delete(
id => 'test',
);
=head2 get
Gets a specific Volume object.
$cloud->volumes->get(
id => 'test',
);
=head2 put
Updates the Volume properties.
Note that when updating labels, the volume’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.
$cloud->volumes->put(
id => 'test',
);
=head2 list_actions
Returns all Action objects for a Volume. You can `sort` the results by using the sort URI parameter, and filter them with the `status` parameter.
$cloud->volumes->list_actions(
id => 'test',
sort => 'test',
status => 'test',
);
=head2 attach
Attaches a Volume to a Server. Works only if the Server is in the same Location as the Volume.
$cloud->volumes->attach(
id => 'test',
);
=head2 change_protection
Changes the protection configuration of a Volume.
$cloud->volumes->change_protection(
id => 'test',
);
=head2 detach
Detaches a Volume from the Server it’s attached to. You may attach it to a Server again at a later time.
$cloud->volumes->detach(
id => 'test',
);
=head2 resize
Changes the size of a Volume. Note that downsizing a Volume is not possible.
$cloud->volumes->resize(
id => 'test',
);
=head2 get_actions
Returns a specific Action for a Volume.
$cloud->volumes->get_actions(
action_id => 'test',
id => 'test',
);
=head1 AUTHOR
Renee Baecker <reneeb@cpan.org>
=head1 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)
=cut