Skip to main content

Python wrapper for Digital Ocean API V2

Project description

Python wrapper for Digital Ocean API V2.

Latest Version

Number of PyPI downloads

Installation

pip install dosa

Usage

import dosa

API_KEY = 'Your API Key'
dosa.set_debug()  # enables debug logs

client = dosa.Client(api_key=API_KEY)

# Droplets
client.droplets.list()
status, result = client.droplets.create(name='terminator', region='nyc2',\
    size='512mb', image='ubuntu-14-04-x32', ssh_keys=[12345])
new_droplet_id = result['id']

# Droplet
new_droplet = client.Droplet(new_droplet_id)
print(new_droplet.info())
## shortcuts
new_droplet.status()
new_droplet.ip_addresses()
client.droplets.delete(new_droplet_id)

# SSH Keys
pub_key = open('~/.ssh/id_rsa.pub').read()
client.keys.create(name='RSA key', public_key=pub_key)
client.keys.list()

# Images
client.images.list()
client.images.all()
client.images.search('ubuntu', 'sgp1', show_op=True)

# Extras
# $ ls keys/
# rsa_pub1.id  rsa_pub2.key  rsa_pub3.key
keys_dir = 'keys'
client.sync_ssh_keys(keys_dir)

Notes

Image search:

>>> client.images.search('ubuntu', region='sgp1', show_op=True)

Above code snippets searches for images containing ubuntu in description or slug. Since region is specified (sgp1), only images in sgp1 region would be considered. If no region is specified all regions are included.

Credits

Created while working on Scroll.in’s project.

Dosa?

"Paper Masala Dosa" by SteveR- - http://www.flickr.com/photos/git/3936135033/. Licensed under Creative Commons Attribution 2.0 via Wikimedia Commons

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dosa-0.7.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file dosa-0.7.tar.gz.

File metadata

  • Download URL: dosa-0.7.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dosa-0.7.tar.gz
Algorithm Hash digest
SHA256 1783305820fc3f0ed87ff5510be63e3c86130c5295e7d6f8b82ca89aec00d887
MD5 7a87b5b5fa347eee36aa6c9f4400314b
BLAKE2b-256 27e39bc40a1e69075ae84e24dc66e58a1f11f3a5644ffdbc3c51bfa6625a2a65

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page