loadero_python.api_client module
API client to access Loadero API
- class loadero_python.api_client.APIClient(*_, **__)[source]
Bases:
objectAPIClient allows to perform GET, POST, PUT, DELETE HTTP methods to Loadero API
The client will automatically set the appropriate headers and authorization.
- property access_token: str
Returns Loadero API access token of project.
- Returns:
str: Loadero API access token of project.
- property api_base: str
Returns Loadero API base URL.
- Returns:
str: Loadero API base URL.
- property auth_header: dict[str, str]
Returns Loadero API authentication header used for all requests.
- Returns:
- dict[str, str]: Loadero API authentication header used for all
requests.
- delete(route: str) None[source]
Sends a HTTP DELETE request to Loadero API.
- Args:
route (str): Loadero API route.
- Raises:
- APIException: When Loadero API returns non application/json content
response. This should never happen.
- APIException: When Loadero API request fails. Either because of
client error or server error.
- get(route: str, query_params: list[tuple[str, any]] | None = None) dict[source]
Sends a HTTP GET request to Loadero API.
- Args:
route (str): Loadero API route.
- Raises:
- APIException: When Loadero API returns non application/json content
response. This should never happen.
- APIException: When Loadero API request fails. Either because of
client error or server error.
- Returns:
- dict or None: API JSON response decoded as dictionary or None if
request returned nothing.
- get_raw(url, dest)[source]
Sends a HTTP GET request to Loadero API. Writes raw response to destination
- Args:
url (str): URL to a Loadero resource.
- dest: Destination where request response is going to be written.
Must implement write method from file interface.
- Raises:
- APIException: When Loadero API request fails. Either because of
client error or server error.
- post(route: str, body: dict) dict[source]
Sends a HTTP POST request to Loadero API.
- Args:
route (str): Loadero API route.
body (dict): Request JSON body decoded as dictionary.
- Raises:
- APIException: When Loadero API returns non application/json content
response. This should never happen.
- APIException: When Loadero API request fails. Either because of
client error or server error.
- Returns:
- dict or None: API JSON response decoded as dictionary or None if
request returned nothing.
- property project_id: int
Returns project ID that the APIClient is configured for.
- Returns:
int: Project ID that the APIClient is configured for.
- property project_route: str
Returns Loadero API URL to the project that APIClient is configured for.
- Returns:
- str: Loadero API URL to the project that APIClient is configured
for.
- put(route: str, body: dict)[source]
Sends a HTTP PUT request to Loadero API.
- Args:
route (str): Loadero API route.
body (dict): Request JSON body decoded as dictionary.
- Raises:
- APIException: When Loadero API returns non application/json content
response. This should never happen.
- APIException: When Loadero API request fails. Either because of
client error or server error.
- Returns:
- dict or None: API JSON response decoded as dictionary or None if
request returned nothing.