cloudendure.api
Define the CloudEndure API wrapper related logic.
Attributes: API_VERSION (str): The CloudEndure API version to be used. AUTH_TTL (str): The authentication token expiration in seconds. Defaults to: 3600. HOST (str): The CloudEndure API URI. Defaults to: https://console.cloudendure.com logger (logging.Logger): The default logger for the module.
CloudEndureAPI
CloudEndureAPI(self, config: 'CloudEndureConfig', *args, **kwargs)
Define the CloudEndure API base.
Attributes: api_endpoint (str): The CloudEndure API endpoint to be used for API calls. credentials (dict): The mapping of CloudEndure credentials. session (requests.Session): The requests Session to be used throughout the lifecycle of this API interaction.
TOP_LEVEL
login
CloudEndureAPI.login(username: 'str' = '',
password: 'str' = '',
token: 'str' = '')
Login to the CloudEndure API console.
Args: username (str): The CloudEndure username to be used. Defaults to the environment specific default. password (str): The CloudEndure password to be used. Defaults to the environment specific default. token (str): The CloudEndure token to be used. This argument takes precedence. If provided, username and password will not be used. Defaults to the environment specific default.
Attributes: endpoint (str): The CloudEndure API endpoint to be used. _username (str): The CloudEndure API username. _password (str): The CloudEndure API password. _token (str): The CloudEndure API token. _auth (dict): The CloudEndure API username/password dictionary map. response (requests.Response): The CloudEndure API login request response object. _xsrf_token (str): The XSRF token to be used for subsequent API requests.
TODO: * Verify default XSRF-Token TTL and check validity before performing subsequent authentication requests.
get_endpoint
CloudEndureAPI.get_endpoint(
path: 'str',
api_version: 'str' = 'latest',
host: 'str' = 'https://console.cloudendure.com')
Build the endpoint path.
Args: path (str): The path to be requested. api_version (str): The API version to be used. For example: v5 Defaults to: latest host (str): The API URL to be used. Defaults to: https://console.cloudendure.com
Returns: str: The CloudEndure API endpoint to be used.
api_call
CloudEndureAPI.api_call(path: 'str',
method: 'str' = 'get',
data: 'Dict[str, Any]' = None)
Handle CloudEndure API calls based on the defined parameters.
Args: path (str): The path to be used to perform the call.
Keyword Args: method (str): The API method call to be performed. i.e.: get, data (dict): The data dictionary to be used to perform the request.
Returns: requests.models.Response: The CloudEndure API response.
check_creds
CloudEndureAPI.check_creds(login: 'bool' = True)
Check the credential TTL.
post_endpoint
CloudEndureAPI.post_endpoint(path: 'str' = '')
Create a POST request against the specified path.
get_projects
CloudEndureAPI.get_projects(current_project: 'str' = '')
Get the CloudEndure projects associated with the authenticated account.
docs
CloudEndureAPI.docs()
Open the CloudEndure API documentation page.