Management

DigitalOcean API

class doto.connect_d0(path=None, log_flag=True, client_id=None, api_key=None)
create_domain(name=None, ip_addr=None)

This method creates a new domain name with an A record for the specified [ip_address].

Parameters:
  • size – The NAME of the domain
  • size – ip address for the domain’s initial a record.

https://api.digitalocean.com/domains/new? client_id=[your_client_id]&api_key=[your_api_key]&name=[domain]&ip_address=[ip_address]

create_droplet(name=None, size_id=None, image_id=None, region_id=None, ssh_key_ids=None, private_networking=None)

Creates a droplet

Parameters:name (string) – The NAME of the droplet (name will be used as a reference

on D0’s servers)

Parameters:size_id (int) – The ID corresponding to requested size of the image (see

connect_d0.get_sizes)

Parameters:image_id (int) – The ID corresponding to the requested image (see

connect_d0.images)

Parameters:region_id (int) – The ID corresponding to the requested region (see

connect_d0.region_id)

Parameters:ssh_key_ids (int) – An optional list of comma separated IDs corresponding

to the requested ssh_keys to be added to the server (see connect_d0.get_ssh_keys)

Parameters:private_networking (int) – An optional bool which enables a private network interface

if the region supports private networking

droplet = d0.create_droplet(name=’Random’,
size_id=66, #512MB image_id=1341147, #Docker 0.7 Ubuntu 13.04 x64 region_id=1, #New York ssh_key_ids=18669 )
create_key_pair(ssh_key_name=None, cli=False, dry_run=False)

Method to create a key pair and store the public key on Digital Ocean’s servers. SSH Keys are store in ~/.ssh/

NOTE: All key names are prepended with d0 to help disambiguate Digital Ocean keys

Parameters:
  • ssh_key_name (string) – The name of the new keypair
  • dry_run (cli) – Set to True if you are using the cli utility and want the path defined

~/.ssh/my_new_key

Parameters:dry_run (bool) – Set to True if the operation should not actually run.
Return type:dict
Returns:Dictionary of SSH key info and local path

https://api.digitalocean.com/ssh_keys/new/?name=[ssh_key_name]&ssh_pub_key=[ssh_public_key]& client_id=[your_client_id]&api_key=[your_api_key]

delete_key_pair(ssh_key_id=None)

Delete the SSH key from your account.

Parameters:ssh_key_id (int) – The ID of the public key

https://api.digitalocean.com/ssh_keys/[ssh_key_id]/destroy/? client_id=[your_client_id]&api_key=[your_api_key]

get_all_domains(filters=None, status_check=None, table=False, raw_data=False)

This method returns all active droplets that are currently running in your account. All available API information is presented for each droplet.

https://api.digitalocean.com/droplets/? client_id=[your_client_id]&api_key=[your_api_key]

Return type:list
Returns:A list of doto.Droplet
get_all_droplets(filters=None, status_check=None, table=False, raw_data=False)

This method returns all active droplets that are currently running in your account. All available API information is presented for each droplet.

https://api.digitalocean.com/droplets/? client_id=[your_client_id]&api_key=[your_api_key]

Return type:list
Returns:A list of doto.Droplet
get_all_images(filters=None, status_check=False, table=False, raw_data=False)

Convenience method to get Digital Ocean’s list of public images and users current private images using EC2 style filtering

https://api.digitalocean.com/sizes/?client_id=[your_client_id]&api_key=[your_api_key]

Parameters:filters (dict) – Optional filters that can be used to limit the results returned. Filters are provided in the form of a dictionary consisting of filter names as the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the DigitalOcean API guide for details.
Return type:list
Returns:A list of doto.Image objects

https://api.digitalocean.com/images/? client_id=[your_client_id]&api_key=[your_api_key]

get_all_regions(status_check=None, table=False)

This method will return all the available regions within the DigitalOcean cloud.

https://api.digitalocean.com/sizes/? client_id=[your_client_id]&api_key=[your_api_key]

get_all_ssh_keys(status_check=None, table=False)

This method lists all the available public SSH keys in your account that can be added to a droplet.

https://api.digitalocean.com/ssh_keys/? client_id=[your_client_id]&api_key=[your_api_key]

get_domain(domain_id=None)

This method displays the attributes of an image.

Parameters:image_id (int) – The ID of the image
Return type:doto.Image
Returns:The newly created doto.Image.

https://api.digitalocean.com/domains/[domain_id]? client_id=[your_client_id]&api_key=[your_api_key]

get_domains(status_check=None, table=False)

This method returns all of your current domains.

https://api.digitalocean.com/domains/? client_id=[your_client_id]&api_key=[your_api_key]

get_droplet(id=None, raw_data=False)

This method returns full information for a specific droplet ID that is passed in the URL.

Parameters:id (int) – ID of the droplet

https://api.digitalocean.com/droplets/[droplet_id]? client_id=[your_client_id]&api_key=[your_api_key]

get_droplet_by_name(name)

Convenience method to make it easy to select a droplet by name

get_image(image_id=None)

This method displays the attributes of an image.

Parameters:image_id (int) – The ID of the image
Return type:doto.Image
Returns:The newly created doto.Image.

https://api.digitalocean.com/images/[image_id]/? client_id=[your_client_id]&api_key=[your_api_key]

get_image_by_name(name)

Convenience method to make it easy to select a droplet by name

get_sizes(status_check=None, table=False)

This method returns all the available sizes that can be used to create a droplet.

https://api.digitalocean.com/sizes/? client_id=[your_client_id]&api_key=[your_api_key]

get_ssh_key(ssh_key_id=None)

Delete the SSH key from your account.

Parameters:ssh_key_id (int) – The ID of the public key

https://api.digitalocean.com/ssh_keys/[ssh_key_id]/destroy/? client_id=[your_client_id]&api_key=[your_api_key]