DigitalOcean::Droplet - Represents a Droplet object in the DigitalOcean API
Version 0.03
use DigitalOcean; my $do = DigitalOcean->new(client_id=> $client_id, api_key => $api_key); my $droplet = $do->droplet(56789); $droplet->reboot; $droplet->power_cycle; $droplet->power_off(wait_on_event => 1); $droplet->snapshot(wait_on event => 1); $droplet->power_on(wait_on_event => 1); #same as last three statements $droplet->snapshot_reboot;
Below is a list of getters that will return the information as set by Digital Ocean.
id
name
image_id
size_id
region_id
backups_active
backups
snapshots
ip_address
private_ip_address
locked
status
Example use:
my $droplet_id = $droplet->id; my $droplet_name = $droplet->name; #returns an arrayref of backups associated with the droplet my $backups = $droplet->backups; #returns an arrayref of snapshots associated with the droplet my $snapshots = $droplet->snapshots;
This method allows you to reboot a droplet. This is the preferred method to use if a server is not responding.
$droplet->reboot;
This method allows you to power cycle a droplet. This will turn off the droplet and then turn it back on.
$droplet->power_cycle;
This method allows you to shutdown a running droplet. The droplet will remain in your account.
$droplet->shutdown;
This method allows you to poweroff a running droplet. The droplet will remain in your account.
$droplet->power_off;
This method allows you to poweron a powered off droplet.
$droplet->power_on;
This method will reset the root password for a droplet. Please be aware that this will reboot the droplet to allow resetting the password.
$droplet->password_reset;
This method allows you to resize a specific droplet to a different size. This will affect the number of processors and memory allocated to the droplet.
size_id Required, Numeric, this is the id of the size you would like the droplet to be resized to
$droplet->resize(size_id => 62);
In order to resize your droplet, it must first be powered off, and you must wait for the droplet to be powered off before you can call resize on the droplet. Making the call accurately would look something like this:
$droplet->power_off(wait_on_event => 1); $droplet->resize(size_id => 62, wait_on_event => 1); $droplet->power_on(wait_on_event => 1);
If your droplet is already on and you essentially want to resize it and boot your droplet back up, you can call resize_reboot to do the above code for you.
If your droplet is already running, this method makes a call to resize for you and powers off your droplet, and then powers it on after it is done resizing and handles waiting on each event to finish so you do not have to write this code. This is essentially the code that resize_reboot performs for you:
This method allows you to take a snapshot of the droplet once it has been powered off, which can later be restored or used to create a new droplet from the same image.
name Optional, String, this is the name of the new snapshot you want to create. If not set, the snapshot name will default to date/time
In order to take a snapshot of your droplet, it must first be powered off, and you must wait for the droplet to be powered off before you can call snapshot on the droplet. Making the call accurately would look something like this:
$droplet->power_off(wait_on_event => 1); $droplet->snapshot(wait_on_event => 1); $droplet->power_on(wait_on_event => 1);
If your droplet is already on and you essentially want to take a snapshot and boot your droplet back up, you can call snapshot_reboot to do the above code for you.
If your droplet is already running, this method makes a call to snapshot for you and powers off your droplet, and then powers it on after it is done taking a snapshot and handles waiting on each event to finish so you do not have to write this code. This is essentially the code that snapshot_reboot performs for you:
This method allows you to restore a droplet with a previous image or snapshot. This will be a mirror copy of the image or snapshot to your droplet. Be sure you have backed up any necessary information prior to restore.
image_id Required, Numeric, this is the id of the image you would like to use to restore your droplet with
$droplet->restore(image_id => 56789);
This method allows you to reinstall a droplet with a default image. This is useful if you want to start again but retain the same IP address for your droplet.
$droplet->rebuild(image_id => 56789);
This method enables bakcups on your droplet.
$droplet->enable_backups;
This method disables bakcups on your droplet.
$droplet->disable_backups;
This method renames the droplet to the specified name. The new name is reflected in the droplet object.
name Required, String, new name of the droplet
$droplet->rename(name => 'my_new_droplet_name');
This method destroys your droplet - this is irreversible.
$droplet->destroy;
Adam Hopkins, <srchulo at cpan.org>
<srchulo at cpan.org>
Please report any bugs or feature requests to bug-webservice-digitalocean at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DigitalOcean. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-webservice-digitalocean at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc DigitalOcean
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=DigitalOcean
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/DigitalOcean
CPAN Ratings
http://cpanratings.perl.org/d/DigitalOcean
Search CPAN
http://search.cpan.org/dist/DigitalOcean/
Copyright 2013 Adam Hopkins.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
To install DigitalOcean, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DigitalOcean
CPAN shell
perl -MCPAN -e shell install DigitalOcean
For more information on module installation, please visit the detailed CPAN module installation guide.