doc: Add authentication examples
Change-Id: I0bafc73e6d2e8cdf4d0b354488f5db4abfe6cfda
This commit is contained in:
parent
add8ec1d80
commit
c5fdda72dc
|
@ -11,9 +11,27 @@ Usage
|
|||
|
||||
To use gnocchiclient in a project::
|
||||
|
||||
>>> from gnocchiclient import auth
|
||||
>>> from gnocchiclient.v1 import client
|
||||
>>> gnocchi = client.Client(...)
|
||||
>>> gnocchi.resource.list("instance")
|
||||
>>>
|
||||
>>> auth_plugin = auth.GnocchiBasicPlugin(user="admin",
|
||||
>>> endpoint="http://localhost:8041")
|
||||
>>> gnocchi = client.Client(session_options={'auth': auth_plugin})
|
||||
>>> gnocchi.resource.list("generic")
|
||||
|
||||
With authentication from a keystoneauth1 plugins::
|
||||
|
||||
>>> from keystoneauth1 import loading
|
||||
>>> from oslo_config import cfg
|
||||
>>> from gnocchiclient import auth
|
||||
>>> from gnocchiclient.v1 import client
|
||||
>>>
|
||||
>>> conf = cfg.ConfigOpts()
|
||||
>>> ...
|
||||
>>> auth_plugin = loading.load_auth_from_conf_options(conf, "gnocchi_credentials")
|
||||
>>> gnocchi = client.Client(session_options={'auth': auth_plugin})
|
||||
>>> gnocchi.resource.list("generic")
|
||||
|
||||
|
||||
Reference
|
||||
---------
|
||||
|
|
Loading…
Reference in New Issue