Debian Codegraph @

doc/source/reference/index.rst

raw
1 ==========================
2 Python Library Reference
3 ==========================
4
5 In order to use the python api directly, you must first obtain an auth
6 token and identify which endpoint you wish to speak to. Once you have
7 done so, you can use the API like so::
8
9 >>> from glanceclient import Client
10 >>> glance = Client('1', endpoint=OS_IMAGE_ENDPOINT, token=OS_AUTH_TOKEN)
11 >>> image = glance.images.create(name="My Test Image")
12 >>> print image.status
13 'queued'
14 >>> image.update(data=open('/tmp/myimage.iso', 'rb'))
15 >>> print image.status
16 'active'
17 >>> image.update(properties=dict(my_custom_property='value'))
18 >>> with open('/tmp/copyimage.iso', 'wb') as f:
19 for chunk in image.data():
20 f.write(chunk)
21 >>> image.delete()
22
23 .. toctree::
24 :maxdepth: 2
25
26 Python API Reference <api/modules>
27 apiv2