Service client¶
- class apiron.client.Timeout(connection_timeout, read_timeout)¶
Bases:
tupleCreate new instance of Timeout(connection_timeout, read_timeout)
- connection_timeout¶
Alias for field number 0
- read_timeout¶
Alias for field number 1
- apiron.client.call(service: apiron.Service, endpoint: apiron.Endpoint, method: str | None = None, session: requests.Session | None = None, params: dict[str, Any] | None = None, data: dict[str, Any] | None = None, files: dict[str, str] | None = None, json: dict[str, Any] | None = None, headers: dict[str, Any] | None = None, cookies: dict[str, Any] | None = None, auth: Any | None = None, encoding: str | None = None, retry_spec: retry.Retry | None = None, timeout_spec: Timeout | None = None, logger: logging.Logger | None = None, allow_redirects: bool = True, return_raw_response_object: bool | None = None, **kwargs)¶
- Parameters:
service (Service) – The service that hosts the endpoint being called
endpoint (Endpoint) – The endpoint being called
method (str) – The HTTP method to use for the call
session (requests.Session) – (optional) An existing session, useful for making many calls in a single session (default
None)params (dict) – (optional)
GETparameters to send to the endpoint (defaultNone)data (dict) – (optional)
POSTdata to send to the endpoint. Adictwill be form-encoded, while astrwill be sent raw (defaultNone)files (dict) – (optional) Dictionary of
'filename': file-like-objectsfor multipart encoding upload. (defaultNone)json (dict) – (optional) A JSON-serializable dictionary that will be sent as the
POSTbody (defaultNone)headers (dict) – HTTP Headers to send to the endpoint (default
None)cookies (dict) – Cookies to send to the endpoint (default
None)auth – An object suitable for the
requests.Requestobject’sauthargumentencoding (str) – The codec to use when decoding the response. Default behavior is to have
requestsguess the codec. (defaultNone)retry_spec (urllib3.util.retry.Retry) – (optional) An override of the retry behavior for this call. (default
None)timeout_spec (Timeout) – (optional) An override of the timeout behavior for this call. (default
None)logger (logging.Logger) – (optional) An existing logger for logging from the proper caller for better correlation
allow_redirects (bool) – (optional) Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection (default
True)return_raw_response_object (bool) – Whether to return a
requests.Responseobject or callformat_response()on it first. (DefaultFalse)**kwargs – Arguments to be formatted into the
endpointargument’spathattribute
- Returns:
The result of
endpoint’sformat_response()- Return type:
The type returned by
endpoint’sformat_response()- Raises:
requests.RetryError – if retry threshold exceeded due to bad HTTP codes (default 500 range)
requests.ConnectionError – if retry threshold exceeded due to connection or request timeouts