API-Vultr
view release on metacpan or search on metacpan
lib/API/Vultr.pm view on Meta::CPAN
sub get_instance_neighbours {
my ( $self, $id ) = @_;
croak qq{Expected scalar id as second argument, instead got $id.}
unless defined $id;
return $self->_request( 'get',
$self->_make_uri( '/instances/' . $id . '/neighbours' ) );
}
sub get_instance_iso_status {
my ( $self, $id ) = @_;
croak qq{Expected scalar id as second argument, instead got $id.}
unless defined $id;
return $self->_request( 'get',
$self->_make_uri( '/instances/' . $id . '/iso' ) );
}
sub detach_iso_from_instance {
my ( $self, $id ) = @_;
croak qq{Expected scalar id as second argument, instead got $id.}
unless defined $id;
return $self->_request( 'post',
$self->_make_uri( '/instances/' . $id . '/iso/detach' ) );
}
sub attach_iso_to_instance {
my ( $self, $id, $iso_id ) = @_;
croak qq{Expected scalar id as second argument, instead got $id.}
unless defined $id;
croak qq{Expected scalar iso_id as second argument, instead got $iso_id.}
unless defined $iso_id;
return $self->_request(
'post',
$self->_make_uri( '/instances/' . $id . '/iso/attach' ),
{ iso_id => $iso_id }
);
}
# ISO #
sub get_isos {
my ( $self, %query ) = @_;
return $self->_request( $self->_make_uri( '/iso', %query ) );
}
sub create_iso {
my ( $self, %body ) = @_;
return $self->_request( $self->_make_uri('/iso'), {%body} );
}
1;
=encoding utf8
=head1 Name
API::Vultr
=head1 Synopsis
A simple, and inuitive interface to the L<Vultr Api|https://https://www.vultr.com/api> using L<LWP::UserAgent>.
This does not cover the entire Vultr API, but instead intends to be very
extendible allowing for easy contributions. Basically, I have what I need,
if you need more feel free to add it!
=head1 Example
use API::Vultr;
use Data::Dumper qw(Dumper);
my $vultr_api = API::Vultr->new(api_key => $ENV{VULTR_API_KEY});
my $create_response = $vultr_api->create_instance(
region => 'ewr',
plan => 'vc2-6c-16gb',
label => 'My Instance',
os_id => 215,
user_data => 'QmFzZTY4EVsw32WfsGGHsjKJI',
backups => 'enabled',
hostname => 'hostname'
);
if ($create_response->is_success) {
print Dumper($create_response->decoded_content);
}
else {
die $create_response->status_line;
}
=head1 API
=head2 ua
Set, or get the L<LWP::UserAgent> associated L<API::Vultr> instance.
=head2 api_key
Set, or get the Vultr API key associated with the L<API::Vultr> instance.
=head2 get_account_info
Retrieve the account information associated with your API key.
L<Vultr API Reference|https://www.vultr.com/api/#tag/account/operation/get-account>
=head2 get_applications
Retrieve applications associated with your API key.
L<Vultr API Reference|https://www.vultr.com/api/#tag/application/operation/list-applications>
=head2 get_backups
( run in 0.987 second using v1.01-cache-2.11-cpan-39bf76dae61 )