xyzspaces.iml.apis.api module¶
This module implements base class for low level api client.
- class xyzspaces.iml.apis.api.Api(access_token, proxies=None)[source]¶
Bases:
object
Base class for low level api calls.
- Parameters
proxies (Optional[dict]) –
- property headers: dict¶
Return HTTP request headers with Bearer token in
Authorization
field.- Returns
authorization tokens
- get(url, params=None, headers=None, **kwargs)[source]¶
Perform a get request of an API at a specified URL with backoff.
- Parameters
url (str) – URL of the API.
params (Optional[dict]) – Parameters to pass to the API.
headers (Optional[dict]) – Request headers. Defaults to the Api headers property.
kwargs – Optional arguments that request takes.
- Returns
response from the API.
- Return type
requests.models.Response
- head(url, params=None, headers=None, **kwargs)[source]¶
Perform a head request of an API at specified URL.
- Parameters
url (str) – URL of the API.
params (Optional[dict]) – Parameters to pass to the API.
headers (Optional[dict]) – Request headers. Defaults to the api headers property.
kwargs – Optional arguments that request takes.
- Returns
response from the API.
- Return type
requests.models.Response
- post(url, data=None, params=None, headers=None, **kwargs)[source]¶
Perform a post request of an API at a specified URL with backoff.
- Parameters
url (str) – URL of the API.
data (Optional[Union[dict, list, bytes, str]]) – Post data for http request.
params (Optional[dict]) – Parameters to pass to the API.
headers (Optional[dict]) – Request headers. Defaults to the api headers property.
kwargs – Optional arguments that request takes.
- Returns
response from the API.
- Return type
requests.models.Response
- put(url, data=None, params=None, headers=None, **kwargs)[source]¶
Perform a put request of an API at a specified URL with backoff.
- Parameters
url (str) – URL of the API
data (Optional[Union[dict, bytes]]) – Put data for http request.
params (Optional[dict]) – Parameters to pass to the API.
headers (Optional[dict]) – Request headers. Defaults to the api headers property.
kwargs – Optional arguments that request takes.
- Returns
response from the API.
- Return type
requests.models.Response
- patch(url, data=None, params=None, headers=None, **kwargs)[source]¶
Perform a patch request of an API at a specified URL with backoff.
- Parameters
url (str) – URL of the API
data (Optional[Union[dict, bytes, str]]) – Patch data for http request.
params (Optional[dict]) – Parameters to pass to the API.
headers (Optional[dict]) – Request headers. Defaults to the api headers property.
kwargs – Optional arguments that request takes.
- Returns
response from the API.
- Return type
requests.models.Response
- delete(url, params=None, headers=None, **kwargs)[source]¶
Perform a delete request of an API at a specified URL with backoff.
- Parameters
url (str) – URL of the API
params (Optional[Dict]) – parameters to pass to the API.
headers (Optional[dict]) – Request headers. Defaults to the api headers property.
kwargs – Optional arguments that request takes.
- Returns
response from the API.
- Return type
requests.models.Response
- static raise_response_exception(resp)[source]¶
Parse HTTP errors status code and raise necessary exceptions.
- Parameters
resp (requests.models.Response) – An HTTP response to parse.
- Raises
TooManyRequestsException – If platform responds with HTTP 429.
AuthenticationException – If platform responds with HTTP 401 or 403.
RequestEntityTooLargeException – If platform responds with HTTP 413.
PayloadTooLargeException – If platform responds with HTTP 513.
Exception – If client responds with any other exception.
- Return type
None