Sebastien Delisle 6424eb419a Keyston Session can be used to instantiate client
The session is used to fetch the almanach url from keystone

Change-Id: I7122c5870624985dc122a9b78ffebdb4a925235d
2017-06-29 16:25:08 -04:00

2.6 KiB

Almanach Python API

almanachclient

almanachclient

Usage

First, create an Almanach Client instance by providing a Keystone session and your AUTH_TOKEN:

>>> from keystoneauth1 import loading
>>> from keystoneauth1 import session
>>> from almanachclient.v1.client import Client

>>> loader = loading.get_plugin_loader('password')
>>> auth = loader.load_from_options(auth_url=AUTH_URL,
...                                 username=USERNAME,
...                                 password=PASSWORD,
...                                 project_name=PROJECT_NAME,
...                                 project_domain_name="Default",
...                                 user_domain_name="Default")
>>> sess = session.Session(auth=auth)

>>> almanach = Client(session=sess, token=AUTH_TOKEN)

Here ALMANACH_URL will be a string that represents the url of Almanach API. AUTH_TOKEN will be the authorization token you use to access the API.

You can also create a Keystone Client instance to fetch Almanach API endpoint:

>>> from almanachclient.keystone_client import KeystoneClient
>>> keystone_client = KeystoneClient(KEYSTONE_URL, USERNAME, PASSWORD, SERVICE, REGION)
>>> almanach_url = keystone_client.get_endpoint_url()

In this case KEYSTONE_URL will be a string that represents the url of your keystone catalog. The nature of USERNAME and PASSWORD speak for themselves. SERVICE will be a string you use to identify the "almanach" service. REGION is used to determine which region the "almanach" service is being used in.

Examples

>>> import datetime >>> from almanachclient.v1.client import Client

>>> start_date = datetime.datetime(2017, 01, 05) >>> end_date = datetime.datetime(2017, 02, 05)

>>> almanach = Client('http://api.region.example.org', 'myApiAuthorizationToken') >>> almanach.get_info()

>>> almanach.get_volume_types() >>> almanach.get_volume_type('f1c2db7b-946e-47a4-b443-914a669a6673') >>> almanach.create_volume_type('f1c2db7b-946e-47a4-b443-914a669a5555', 'VolumeTypeName') >>> almanach.delete_volume_type('f1c2db7b-946e-47a4-b443-914a669a5555')

>>> almanach.get_tenant_entities('my-tenant-uuid', start_date, end_date)

>>> almanach.delete_instance('f1c2db7b-946e-47a4-b443-914a669a3333') >>> almanach.update_instance_entity(instance_id='f1c2db7b-946e-47a4-b443-914a669a2222', start=start_date, end=end_date)

Reference

For more information, see the reference:

api/autoindex