Service client

class apiron.client.Timeout(connection_timeout, read_timeout)

Bases: tuple

Create 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) GET parameters to send to the endpoint (default None)

  • data (dict) – (optional) POST data to send to the endpoint. A dict will be form-encoded, while a str will be sent raw (default None)

  • files (dict) – (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload. (default None)

  • json (dict) – (optional) A JSON-serializable dictionary that will be sent as the POST body (default None)

  • 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’s auth argument

  • encoding (str) – The codec to use when decoding the response. Default behavior is to have requests guess the codec. (default None)

  • 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 call format_response() on it first. (Default False)

  • **kwargs – Arguments to be formatted into the endpoint argument’s path attribute

Returns:

The result of endpoint’s format_response()

Return type:

The type returned by endpoint’s format_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