Python wrapper for Digital Ocean API v2
Project description
Python library for managing your Digital Ocean account API v2
This library starts with a python wrapper for the API and aims to build tools to make it easier to manage, provision, and deploy to Digital Ocean.
Setup
pip install -U poseidon
To run the unit tests make sure you have the ‘pytest’ module. If not, run
pip install -U pytest
Examples
Setup authentication by generating an API key and exporting it as the value of the “DIGITALOCEAN_API_KEY” environment variable:
export DIGITALOCEAN_API_KEY=<value>
Connect to API
import poseidon.api as po
client = po.connect() # or po.connect(api_key=<KEY>) for custom api key
Create a droplet
image_id = 135123 # replace with your own
droplet = client.droplets.create(name='test', region='sfo1', size='512mb',
image=image_id)
droplet.wait() # waits until pending creation is complete
Programmatically create a snapshot
droplet.power_off() # snapshots are only allowed while powered off
droplet.wait() # waits until powered off
droplet.take_snapshot('test-snapshot')
droplet.wait()
Other simple droplet commands
droplet.reboot()
droplet.shutdown()
droplet.power_on()
droplet.power_cycle()
droplet.password_reset()
droplet.enable_ipv6()
droplet.disable_backups()
droplet.enable_private_networking()
Waiting for pending actions to complete
droplet.wait() # polls every 5 seconds until no more in-progress actions
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
poseidon-0.1.0.tar.gz
(7.2 kB
view hashes)