Digital Ocean API
This gem is a simple and easy-to-use wrapper for Digital Ocean's API.
Add this line to your application's Gemfile:
And then execute:
$ bundle install
Or install it yourself as:
$ gem install digital-ocean
To use the API methods, you'll need to retrieve your client ID and API key from Digital Ocean after logging in. You can then instantiate a new client and use the API methods.
# Create a new client client = DigitalOcean.client( :client_id => "202cd122bd857fb65d80bf804ef47fde", :api_key => "cd7d64f341654411eadb4b32e2c6a2ae" )
Retrieve a list of your droplets
This method returns an array of droplets each with the following attributes: backups_active, created_at, id, image_id, ip_address, locked, name, private_ip_address, region_id, size_id, status
client.droplets # => #<Hashie::Mash droplets=[#<Hashie::Mash backups_active=false cre...
Retrieve a droplet by its ID
This method retrieves a single droplet by its ID.
Create a new droplet
This method creates a new droplet. It takes the following parameters:
:nameRequired, String, this is the name of the droplet - must be formatted by hostname rules.
:size_idRequired, Numeric, this is the id of the size you would like the droplet created at.
:image_idRequired, Numeric, this is the id of the image you would like the droplet created with.
:region_idRequired, Numeric, this is the id of the region you would like your server in.
:ssh_key_idsOptional, Numeric CSV, comma separated list of ssh_key_ids that you would like to be added to the server.
:private_networkingOptional, Boolean, enables a private network interface if the region supports private networking.
client.new_droplet( :name => 'test.example.com', :size_id => 63, :region_id => 4, :ssh_key_ids => "ssh-key rsa e5ab78..,ssh-key rsa...", :private_networking => true )
Retrieve a list of available regions
This method returns a list of regions that are available to create a new droplet in with info about each location.
Retrieve a list of available sizes
This method retrieves a list of available sizes for a new droplet along with information about each size.
- 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