Merge "Update Client examples to use sessions"
This commit is contained in:
@@ -93,11 +93,15 @@ class Client(httpclient.HTTPClient):
|
|||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
|
>>> from keystoneauth1.identity import v2
|
||||||
|
>>> from keystoneauth1 import session
|
||||||
>>> from keystoneclient.v2_0 import client
|
>>> from keystoneclient.v2_0 import client
|
||||||
>>> keystone = client.Client(username=USER,
|
>>> auth = v2.Password(auth_url=KEYSTONE_URL,
|
||||||
... password=PASS,
|
... username=USER,
|
||||||
... tenant_name=TENANT_NAME,
|
... password=PASS,
|
||||||
... auth_url=KEYSTONE_URL)
|
... tenant_name=TENANT_NAME)
|
||||||
|
>>> sess = session.Session(auth=auth)
|
||||||
|
>>> keystone = client.Client(session=sess)
|
||||||
>>> keystone.tenants.list()
|
>>> keystone.tenants.list()
|
||||||
...
|
...
|
||||||
>>> user = keystone.users.get(USER_ID)
|
>>> user = keystone.users.get(USER_ID)
|
||||||
@@ -108,11 +112,15 @@ class Client(httpclient.HTTPClient):
|
|||||||
returns as a dictionary-like-object so that you can export and
|
returns as a dictionary-like-object so that you can export and
|
||||||
cache it, re-using it when initiating another client::
|
cache it, re-using it when initiating another client::
|
||||||
|
|
||||||
|
>>> from keystoneauth1.identity import v2
|
||||||
|
>>> from keystoneauth1 import session
|
||||||
>>> from keystoneclient.v2_0 import client
|
>>> from keystoneclient.v2_0 import client
|
||||||
>>> keystone = client.Client(username=USER,
|
>>> auth = v2.Password(auth_url=KEYSTONE_URL,
|
||||||
... password=PASS,
|
... username=USER,
|
||||||
... tenant_name=TENANT_NAME,
|
... password=PASS,
|
||||||
... auth_url=KEYSTONE_URL)
|
... tenant_name=TENANT_NAME)
|
||||||
|
>>> sess = session.Session(auth=auth)
|
||||||
|
>>> keystone = client.Client(session=sess)
|
||||||
>>> auth_ref = keystone.auth_ref
|
>>> auth_ref = keystone.auth_ref
|
||||||
>>> # pickle or whatever you like here
|
>>> # pickle or whatever you like here
|
||||||
>>> new_client = client.Client(auth_ref=auth_ref)
|
>>> new_client = client.Client(auth_ref=auth_ref)
|
||||||
@@ -124,11 +132,14 @@ class Client(httpclient.HTTPClient):
|
|||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
|
>>> from keystoneauth1.identity import v2
|
||||||
|
>>> from keystoneauth1 import session
|
||||||
>>> from keystoneclient.v2_0 import client
|
>>> from keystoneclient.v2_0 import client
|
||||||
>>> admin_client = client.Client(
|
>>> auth = v2.Token(auth_url='http://localhost:35357/v2.0',
|
||||||
... token='12345secret7890',
|
... token='12345secret7890')
|
||||||
... endpoint='http://localhost:35357/v2.0')
|
>>> sess = session.Session(auth=auth)
|
||||||
>>> admin_client.tenants.list()
|
>>> keystone = client.Client(session=sess)
|
||||||
|
>>> keystone.tenants.list()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@@ -94,14 +94,17 @@ class Client(httpclient.HTTPClient):
|
|||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
|
>>> from keystoneauth1.identity import v3
|
||||||
|
>>> from keystoneauth1 import session
|
||||||
>>> from keystoneclient.v3 import client
|
>>> from keystoneclient.v3 import client
|
||||||
>>> keystone = client.Client(user_domain_name=DOMAIN_NAME,
|
>>> auth = v3.Password(user_domain_name=DOMAIN_NAME,
|
||||||
... username=USER,
|
... username=USER,
|
||||||
... password=PASS,
|
... password=PASS,
|
||||||
... project_domain_name=PROJECT_DOMAIN_NAME,
|
... project_domain_name=PROJECT_DOMAIN_NAME,
|
||||||
... project_name=PROJECT_NAME,
|
... project_name=PROJECT_NAME,
|
||||||
... auth_url=KEYSTONE_URL)
|
... auth_url=KEYSTONE_URL)
|
||||||
...
|
>>> sess = session.Session(auth=auth)
|
||||||
|
>>> keystone = client.Client(session=sess)
|
||||||
>>> keystone.projects.list()
|
>>> keystone.projects.list()
|
||||||
...
|
...
|
||||||
>>> user = keystone.users.get(USER_ID)
|
>>> user = keystone.users.get(USER_ID)
|
||||||
|
Reference in New Issue
Block a user