python-doctl¶
A Python wrapper for the excellent doctl command-line utility, from Digital Ocean.
This documentation exists to guide you through the usage of the doctl Python library — a Pythonic wrapper around the doctl
command–line utility, for managing your DigitalOcean infrastructure.
Please enjoy!
Installation¶
Fist, ensure you have doctl
installed on your system, then you can add python-doctl
to your project with Pipenv:
$ pipenv install doctl
Introduction¶
The DIGITALOCEAN_ACCESS_TOKEN
environment variable will automatically be honored.
$ export DIGITALOCEAN_ACCESS_TOKEN=xxxx
>>> import doctl>>> for droplet in doctl.compute.droplet.list(): ... print(droplet['name']) pypi.kennethreitz.org code.kennethreitz.org build.kennethreitz.org …>>> for key in doctl.compute.ssh_key.list(): ... print(key['name']) Blink (iPad) thoth macbook
Alternatively, you can pass a token in explicitly:
>>> from doctl import DigitalOcean
>>> doctl = DigitalOcean(token="xxxxx")
Things to Know¶
- All reasonable
doctl
commands are available as methods on within thedoctl
module. Sub–commands are referenced with another method call (e.g.doctl.compute.ssh_key.list()
. - All methods return Python data structures, includinging timezone–aware Datetime objects.
Notes¶
Use of the DIGITALOCEAN_ACCESS_TOKEN
environment variable is recommended.
Available Namespaces¶
The entire API surface of doctl
is covered by this library, so the following
namespaces are available for your use and enjoyment:
compute.account
compute.action
compute.certificate
compute.domain
compute.domain_records
compute.droplet
compute.firewall
compute.floating_ip
compute.image
compute.image_action
compute.load_balancer
compute.plugin
compute.region_list
compute.size_list
compute.snapshot
compute.ssh_key
compute.tag
compute.volume
compute.volume_action
API Documentation¶
Main Interfaces¶
The Compute
class is the main interface to doctl
. A built in instance, doctl.compute
is available at the module–level.
This is also an Account class, for viewing your authentication information, as well as your rate–limiting. A built in instance, doctl.account
is available at the module–level.