epicsarchiver.common.async_service

Module to cover the ServiceClient for doing http calls.

Attributes

LOG

Classes

ServiceClient

An async and sync http service client.

Module Contents

epicsarchiver.common.async_service.LOG: logging.Logger[source]
class epicsarchiver.common.async_service.ServiceClient(base_url: str)[source]

An async and sync http service client.

For doing basic GET POST http calls.

base_url[source]
_session: aiohttp.ClientSession | None = None[source]
property session: aiohttp.ClientSession[source]

Return the aiohttp session.

Returns:

The session.

Return type:

ClientSession

async close() None[source]

Close the Service (closes the session).

async __aenter__() typing_extensions.Self[source]

Asynchronous enter.

Returns:

self

Return type:

Self

async __aexit__(exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None) None[source]

Asynchronous exit, closes any sessions.

async _get(endpoint: str, params: collections.abc.Mapping[str, str] | None = None) aiohttp.ClientResponse[source]

Send a GET request to the given endpoint.

Parameters:
  • endpoint – API endpoint (relative or absolute)

  • params – parameters to be sent

Returns:

ClientResponse object

async _get_json(endpoint: str, params: collections.abc.Mapping[str, str] | None = None) Any[source]

Send a GET request to the given endpoint and return the json.

Parameters:
  • endpoint – API endpoint (relative or absolute)

  • params – parameters to be sent

Returns:

ClientResponse object

async _post(endpoint: str, params: collections.abc.Mapping[str, str] | None = None, data: Any = None, json: Any = None) aiohttp.ClientResponse[source]

Send a POST request to the given endpoint.

Parameters:
  • endpoint – API endpoint (relative or absolute)

  • params – parameters to be sent

  • data – Data to send

  • json – Alternative to data

Returns:

ClientResponse object