Interact with the Digital Ocean API in an idiomatic ruby way.
DORB exposes the Digital Ocean API as Ruby objects, has a comprehensive test suite and supports the entire API.
Add this line to your application's Gemfile:
gem 'dorb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dorb
Require the library in your code as
require 'dorb'
Set your client key and API key
# This should be in an initializer or similar
DORB::Config.setup \
:client_key => 'YOUR_CLIENT_KEY_HERE',
:api_key => 'YOUR_API_KEY_HERE'
Any method that calls the Digital Ocean API will raise DORB::ConfigurationError if either Client Key or API Key are not configured
This method returns all active droplets that are currently running in your account.
DORB::Droplet.all
This method returns a droplet for a specific droplet id.
DORB::Droplet.find id
DORB::Droplet.find_by_ip_address ip_address
DORB::Droplet.find_all_by_name name
This method allows you to create a new droplet.
DORB::Droplet.create :name => name, :size => size, :image => image, :region => region, :ssh_keys => [keys]
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 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 power off a running droplet. The droplet will remain in your account
droplet.power_off
This method allows you to power on 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.
droplet.resize size
This method allows you to take a snapshot of the running droplet, which can later be restored or used to create a new droplet from the same image. Please be aware this may cause a reboot.
droplet.snapshot
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.
droplet.restore image
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
This method enables automatic backups which run in the background daily to backup your droplet's data.
droplet.enable_backups
This method disables automatic backups from running to backup your droplet's data.
droplet.disable_backups
This method destroys one of your droplets - this is irreversible.
droplet.destroy
This method returns all the available images that can be accessed by your client ID. You will have access to all public images by default, and any snapshots or backups that you have created in your own account.
DORB::Image.all
This method returns an image instance
DORB::Image.find id
DORB::Image.find_all_by_name name
This method allows you to destroy an image. There is no way to restore a deleted image so be careful and ensure your data is properly backed up.
image.destroy
This method lists all the available public SSH keys in your account that can be added to a droplet.
DORB::SSHKey.all
This method returns an SSHKey instance
DORB::SSHKey.find id
DORB::SSHKey.find_all_by_name name
This method allows you to add a new public SSH key to your account.
DORB::SSHKey.add name, ssh_key_pub
This method allows you to modify an existing public SSH key in your account.
ssh_key.edit ssh_key_pub
This method will delete the SSH key from your account.
ssh_key.destroy
This method returns all the available sizes that can be used to create a droplet.
DORB::Size.all
This method will return all the available regions within the Digital Ocean cloud.
DORB::Region.all
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request