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) -> 'None'
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
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
login
CloudEndureAPI.login(self, username: 'str' = '', password: 'str' = '', token: 'str' = '') -> 'bool'
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') -> 'str'
Build the endpoint path.
Returns: str: The CloudEndure API endpoint to be used.
api_call
CloudEndureAPI.api_call(self, path: 'str', method: 'str' = 'get', data: 'Dict[str, Any]' = None) -> 'Response'
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(self, login: 'bool' = True) -> 'Dict[str, str]'
Check the credential TTL.
post_endpoint
CloudEndureAPI.post_endpoint(self, path: 'str' = '') -> 'Response'
Create a POST request against the specified path.
get_projects
CloudEndureAPI.get_projects(self, current_project: 'str' = '') -> 'List[Any]'
Get the CloudEndure projects associated with the authenticated account.
docs
CloudEndureAPI.docs() -> 'str'
Open the CloudEndure API documentation page.