esdc_api.client¶
This module contains the Danube Cloud API Client
class used to access the Danube Cloud HTTP API.
-
class
esdc_api.client.
Client
(api_url='https://danube.cloud/api', api_key=None, auth=None, timeout=None, ssl_verify=True)¶ Danube Cloud API HTTP client.
Parameters: - api_url (str) – Danube Cloud API base URL.
- api_key (str) – Optional API key used to perform authenticated requests.
- auth (tuple) – Optional auth tuple to enable Basic/Digest/Custom HTTP authentication.
- timeout (float) – How long to wait for the server to send data before giving up (default: None).
- ssl_verify (bool) – If True, the SSL cert will be verified (default: True).
-
is_authenticated
()¶ Return True if api_key is set or authorization token was saved by the
login()
method.
-
login
(username, password)¶ Login to Danube Cloud API (
POST
/accounts/login) using username and password.Parameters: - username (str) – Danube Cloud username.
- password (str) – Danube Cloud password.
-
request
(method, resource, timeout=None, stream=True, **params)¶ - Perform request to server and return
Response
or - raise an
ESAPIException
. This method is used by all public request methods in this class.
Parameters: - method (str) – HTTP method.
- resource (str) – Danube Cloud API resource beginning with a slash (e.g. /vm/<hostname>).
- timeout (int) – Optional timeout for the request (default None).
- stream (bool) – Whether to wait for asynchronous API calls to finish (default True).
- params (dict) – Request parameters internally translated into POST/PUT/DELETE JSON encoded data or GET query string.
Returns: Response object.
Return type: Raise: - Perform request to server and return