Service client¶
- class apiron.client.Timeout(connection_timeout, read_timeout)¶
Bases:
tuple
Create new instance of Timeout(connection_timeout, read_timeout)
- property connection_timeout¶
Alias for field number 0
- property read_timeout¶
Alias for field number 1
- apiron.client.call(service: apiron.Service, endpoint: apiron.Endpoint, method: Optional[str] = None, session: Optional[requests.Session] = None, params: Optional[Dict[str, Any]] = None, data: Optional[Dict[str, Any]] = None, files: Optional[Dict[str, str]] = None, json: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, Any]] = None, cookies: Optional[Dict[str, Any]] = None, auth: Optional[Any] = None, encoding: Optional[str] = None, retry_spec: Optional[retry.Retry] = None, timeout_spec: Optional[Timeout] = None, logger: Optional[logging.Logger] = None, allow_redirects: bool = True, return_raw_response_object: Optional[bool] = 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)
GET
parameters to send to the endpoint (defaultNone
)data (dict) – (optional)
POST
data to send to the endpoint. Adict
will be form-encoded, while astr
will be sent raw (defaultNone
)files (dict) – (optional) Dictionary of
'filename': file-like-objects
for multipart encoding upload. (defaultNone
)json (dict) – (optional) A JSON-serializable dictionary that will be sent as the
POST
body (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.Request
object’sauth
argumentencoding (str) – The codec to use when decoding the response. Default behavior is to have
requests
guess 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.Response
object or callformat_response()
on it first. (DefaultFalse
)**kwargs – Arguments to be formatted into the
endpoint
argument’spath
attribute
- 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