DOP: Digital Ocean API Python Wrapper

https://badge.fury.io/py/dop.png https://pypip.in/d/dop/badge.png

DOP is a MIT licensed Python wrapper for Digital Ocean's API.

Features

Full support for all methods listed here

Installation

To install dop, simply:

$ pip install dop

Example

It is pretty easy to use:

from dop.client import Client

client = Client('client_id', 'api_key')

# Print regions.
regions = client.regions()
for region in regions:
    print(region.to_json())

# Print sizes.
sizes = client.sizes()
for size in sizes:
    print(size.to_json())

# Print public global images.
images = client.images()
for image in images:
    print(image.to_json())

# Print your private images.
images = client.images(filter='my_images')
for image in images:
    print(image.to_json())

# Create a droplet
conf = {
    'name': 'test',
    'size': {'size_slug': '512MB'},
    'image': {'image_slug': 'ubuntu-13-04-x64'},
    'region': {'region_slug': 'nyc1'},
}
droplet = client.create_droplet(**conf)

To create a droplet, you can use the data fetched from regions, sizes and images methods to fill the dictionary properly.

How to initialise with client_id and api_key stored in creds file

Easy:

from dop.client import Client

client = Client.fromCredsFile('/home/user/.do.creds')

Contribute

Pull requests and improvements are welcome.



DOP: Digital Ocean API Python Wrapper

https://badge.fury.io/py/dop.png https://pypip.in/d/dop/badge.png

DOP是数字海洋API的MIT许可Python包装器

功能

全面支持此处列出的所有方法

安装

要安装dop,只需:

$ pip install dop

示例

很容易使用:

from dop.client import Client

client = Client('client_id', 'api_key')

Print regions.

regions = client.regions() for region in regions: print(region.to_json())

Print sizes.

sizes = client.sizes() for size in sizes: print(size.to_json())

Print public global images.

images = client.images() for image in images: print(image.to_json())

Print your private images.

images = client.images(filter='my_images') for image in images: print(image.to_json())

Create a droplet

conf = { 'name': 'test', 'size': {'size_slug': '512MB'}, 'image': {'image_slug': 'ubuntu-13-04-x64'}, 'region': {'region_slug': 'nyc1'}, } droplet = client.create_droplet(**conf)

要创建一个液滴,您可以使用从区域,大小和图像方法获取的数据来正确填充字典。

如何使用存储在creds文件中的client_id和api_key进行初始化

简单:

from dop.client import Client

client = Client.fromCredsFile('/home/user/.do.creds')

贡献

欢迎提出请求和改进。




相关问题推荐