ResponseBody
(response, body=None)[source]¶Class that wraps an http response and dict body into a single value.
Callers that receive this object will normally use it as a dict but can extract the response if needed.
ResponseBodyData
(response, data)[source]¶Class that wraps an http response and string data into a single value.
ResponseBodyList
(response, body=None)[source]¶Class that wraps an http response and list body into a single value.
Callers that receive this object will normally use it as a list but can extract the response if needed.
RestClient
(auth_provider, service, region, endpoint_type='publicURL', build_interval=1, build_timeout=60, disable_ssl_certificate_validation=False, ca_certs=None, trace_requests='', name=None, http_timeout=None)[source]¶Unified OpenStack RestClient class
This class is used for building openstack api clients on top of. It is intended to provide a base layer for wrapping outgoing http requests in keystone auth as well as providing response code checking and error handling.
Parameters: |
|
---|
copy
(url, headers=None, extra_headers=False)[source]¶Send a HTTP COPY request using keystone service catalog and auth
Parameters: |
|
---|---|
Returns: | a tuple with the first entry containing the response headers and the second the response body |
Return type: | tuple |
delete
(url, headers=None, body=None, extra_headers=False)[source]¶Send a HTTP DELETE request using keystone service catalog and auth
Parameters: |
|
---|---|
Returns: | a tuple with the first entry containing the response headers and the second the response body |
Return type: | tuple |
expected_success
(expected_code, read_code)[source]¶Check expected success response code against the http response
Parameters: |
|
---|---|
Raises: |
|
get
(url, headers=None, extra_headers=False)[source]¶Send a HTTP GET request using keystone service catalog and auth
Parameters: |
|
---|---|
Returns: | a tuple with the first entry containing the response headers and the second the response body |
Return type: | tuple |
get_headers
(accept_type=None, send_type=None)[source]¶Return the default headers which will be used with outgoing requests
Parameters: |
|
---|---|
Return type: | dict |
Returns: | The dictionary of headers which can be used in the headers dict for outgoing request |
get_versions
()[source]¶Get the versions on a endpoint from the keystone catalog
This method will make a GET request on the baseurl from the keystone catalog to return a list of API versions. It is expected that a GET on the endpoint in the catalog will return a list of supported API versions.
:return tuple with response headers and list of version numbers :rtype: tuple
head
(url, headers=None, extra_headers=False)[source]¶Send a HTTP HEAD request using keystone service catalog and auth
Parameters: |
|
---|---|
Returns: | a tuple with the first entry containing the response headers and the second the response body |
Return type: | tuple |
password
¶The password being used for requests
Return type: | string |
---|---|
Returns: | The password being used for requests |
patch
(url, body, headers=None, extra_headers=False)[source]¶Send a HTTP PATCH request using keystone service catalog and auth
Parameters: |
|
---|---|
Returns: | a tuple with the first entry containing the response headers and the second the response body |
Return type: | tuple |
post
(url, body, headers=None, extra_headers=False, chunked=False)[source]¶Send a HTTP POST request using keystone auth
Parameters: |
|
---|---|
Returns: | a tuple with the first entry containing the response headers and the second the response body |
Return type: | tuple |
put
(url, body, headers=None, extra_headers=False, chunked=False)[source]¶Send a HTTP PUT request using keystone service catalog and auth
Parameters: |
|
---|---|
Returns: | a tuple with the first entry containing the response headers and the second the response body |
Return type: | tuple |
raw_request
(url, method, headers=None, body=None, chunked=False)[source]¶Send a raw HTTP request without the keystone catalog or auth
This method sends a HTTP request in the same manner as the request() method, however it does so without using keystone auth or the catalog to determine the base url. Additionally no response handling is done the results from the request are just returned.
Parameters: |
|
---|---|
Return type: | tuple |
Returns: | a tuple with the first entry containing the response headers and the second the response body |
request
(method, url, extra_headers=False, headers=None, body=None, chunked=False)[source]¶Send a HTTP request with keystone auth and using the catalog
This method will send an HTTP request using keystone auth in the headers and the catalog to determine the endpoint to use for the baseurl to send the request to. Additionally
When a response is received it will check it to see if an error response was received. If it was an exception will be raised to enable it to be handled quickly.
This method will also handle rate-limiting, if a 413 response code is received it will retry the request after waiting the 'retry-after' duration from the header.
Parameters: |
|
---|---|
Return type: | tuple |
Returns: | a tuple with the first entry containing the response headers and the second the response body |
Raises: |
|
resource_type
¶Returns the primary type of resource this client works with.
response_checker
(method, resp, resp_body)[source]¶A sanity check on the response from a HTTP request
This method does a sanity check on whether the response from an HTTP request conforms the HTTP RFC.
Parameters: |
|
---|---|
Raises: |
|
tenant_id
¶The tenant/project id being used for requests
Return type: | string |
---|---|
Returns: | The tenant/project id being used for requests |
tenant_name
¶The tenant/project being used for requests
Return type: | string |
---|---|
Returns: | The tenant/project name being used for requests |
user
¶The username used for requests
Return type: | string |
---|---|
Returns: | The username being used for requests |
user_id
¶The user_id used for requests
Return type: | string |
---|---|
Returns: | The user id being used for requests |
wait_for_resource_deletion
(id)[source]¶Waits for a resource to be deleted
This method will loop over is_resource_deleted until either is_resource_deleted returns True or the build timeout is reached. This depends on is_resource_deleted being implemented
Parameters: | id (str) -- The id of the resource to check |
---|---|
Raises: | TimeoutException -- If the build_timeout has elapsed and the resource still hasn't been deleted |
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.