Client¶
Kelvin API Client.
This module provides synchronous and asynchronous clients for interacting with the Kelvin platform REST API (API version 3).
Example
>>> from kelvin.api.client import Client
>>> client = Client()
>>> assets = client.assets.list()
Client Implementation¶
Kelvin API Client.
- class kelvin.api.client.client.Client(*, url=None, username=None, client_id=None, client_secret=None, password=None, totp=None, access_token=None, retries=None, timeout=None, verbose=None, plugins=None)[source]¶
Bases:
SyncBaseClientKelvin API Client.
Synchronous client for interacting with the Kelvin API.
- Parameters:
password (
Optional[str]) – Password for obtaining access token.totp (
Optional[int]) – Time-based one-time password for 2FA.verbose (
Optional[bool]) – If True, log requests and responses.url (Optional[AnyUrl])
username (Optional[str])
client_id (Optional[str])
client_secret (Optional[str])
access_token (Optional[str])
retries (Optional[int])
plugins (Optional[list[Union[RequestHistory, ResponseHistory, object]]])
- class kelvin.api.client.client.AsyncClient(*, url=None, username=None, client_id=None, client_secret=None, password=None, totp=None, access_token=None, retries=None, timeout=None, verbose=None, plugins=None)[source]¶
Bases:
AsyncBaseClientKelvin API Async Client.
Asynchronous client for interacting with the Kelvin API.
- Parameters:
password (
Optional[str]) – Password for obtaining access token.totp (
Optional[int]) – Time-based one-time password for 2FA.verbose (
Optional[bool]) – If True, log requests and responses.url (Optional[AnyUrl])
username (Optional[str])
client_id (Optional[str])
client_secret (Optional[str])
access_token (Optional[str])
retries (Optional[int])
plugins (Optional[list[Union[RequestHistory, ResponseHistory, object]]])
HTTP Tools¶
HTTP Tools Module.
This module provides classes for storing and managing HTTP tools.
- class kelvin.api.base.http_tools.ResponseHistory(maxlen=100)[source]¶
A history of HTTP responses.
This class provides methods to retrieve information about the responses stored in the history, such as status codes, successful responses, and error responses.
- Parameters:
maxlen (int)
- get_successful_responses()[source]¶
Get all successful responses (status codes 2xx).
- Return type:
list[Response]- Returns:
A list of T objects with successful status codes.
- get_error_responses()[source]¶
Get all error responses (status codes 4xx and 5xx).
- Return type:
list[Response]- Returns:
A list of T objects with error status codes.
Errors¶
Errors.