The troveclient.apiclient.client Module

The troveclient.apiclient.client Module

OpenStack Client interface. Handles the REST calls and responses.

class troveclient.apiclient.client.BaseClient(http_client, extensions=None)

Bases: object

Top-level object to access the OpenStack API.

This client uses HTTPClient to send requests. HTTPClient will handle a bunch of issues such as authentication.

cached_endpoint = None
client_request(method, url, **kwargs)
delete(url, **kwargs)
endpoint_type = None
get(url, **kwargs)
static get_class(api_name, version, version_map)

Returns the client class for the requested API version

Parameters:
  • api_name – the name of the API, e.g. ‘compute’, ‘image’, etc
  • version – the requested API version
  • version_map – a dict of client classes keyed by version
Return type:

a client class for the requested API version

head(url, **kwargs)
patch(url, **kwargs)
post(url, **kwargs)
put(url, **kwargs)
service_type = None
class troveclient.apiclient.client.HTTPClient(auth_plugin, region_name=None, endpoint_type='publicURL', original_ip=None, verify=True, cert=None, timeout=None, timings=False, keyring_saver=None, debug=False, user_agent=None, http=None)

Bases: object

This client handles sending HTTP requests to OpenStack servers.

Features:

  • share authentication information between several clients to different services (e.g., for compute and image clients);
  • reissue authentication request for expired tokens;
  • encode/decode JSON bodies;
  • raise exceptions on HTTP errors;
  • pluggable authentication;
  • store authentication information in a keyring;
  • store time spent for requests;
  • register clients for particular services, so one can use http_client.identity or http_client.compute;
  • log requests and responses in a format that is easy to copy-and-paste into terminal and send the same request with curl.
add_client(base_client_instance)

Add a new instance of BaseClient descendant.

self will store a reference to base_client_instance.

Example:

>>> def test_clients():
...     from keystoneclient.auth import keystone
...     from openstack.common.apiclient import client
...     auth = keystone.KeystoneAuthPlugin(
...         username="user", password="pass", tenant_name="tenant",
...         auth_url="http://auth:5000/v2.0")
...     openstack_client = client.HTTPClient(auth)
...     # create nova client
...     from novaclient.v1_1 import client
...     client.Client(openstack_client)
...     # create keystone client
...     from keystoneclient.v2_0 import client
...     client.Client(openstack_client)
...     # use them
...     openstack_client.identity.tenants.list()
...     openstack_client.compute.servers.list()
authenticate()
client_request(client, method, url, **kwargs)

Send an http request using client’s endpoint and specified url.

If request was rejected as unauthorized (possibly because the token is expired), issue one authorization attempt and send the request once again.

Parameters:
  • client – instance of BaseClient descendant
  • method – method of HTTP request
  • url – URL of HTTP request
  • kwargs – any other parameter that can be passed to HTTPClient.request
static concat_url(endpoint, url)

Concatenate endpoint and final URL.

E.g., “http://keystone/v2.0/” and “/tokens” are concatenated to “http://keystone/v2.0/tokens”.

Parameters:
  • endpoint – the base URL
  • url – the final URL
get_timings()
request(method, url, **kwargs)

Send an http request with the specified characteristics.

Wrapper around requests.Session.request to handle tasks such as setting headers, JSON encoding/decoding, and error handling.

Parameters:
  • method – method of HTTP request
  • url – URL of HTTP request
  • kwargs – any other parameter that can be passed to requests.Session.request (such as headers) or json that will be encoded as JSON and used as data argument
reset_timings()
serialize(kwargs)
user_agent = 'troveclient.apiclient'
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

python-troveclient 2.14.1.dev7