Advanced#

Custom HTTP Client Adaptor#

Aiodynamo is not strongly tied to any HTTP client library or version thereof. Default adaptors for httpx and aiohttp are provided, but it is perfectly valid to use your own adaptor that uses a different library or versions of httpx or aiohttp not supported by the default adaptors.

An HTTP client adaptor is a callable which takes a aiodynamo.http.types.Request as input and either returns a aiodynamo.http.types.Response.

If the request fails due to a connection error or some other client error, the adaptor should raise a aiodynamo.http.types.RequestFailed with the client exception as the first argument. If the HTTP client library handles timeouts, those timeouts should raise an asyncio.TimeoutError exception.

class aiodynamo.http.types.Request(
method: Literal['GET'] | Literal['POST'] | Literal['PUT'],
url: str,
headers: Dict[str, str] | None,
body: bytes | None,
)#
method: Literal['GET'] | Literal['POST']#
url: str#
headers: Dict[str, str] | None#
body: bytes | None#
class aiodynamo.http.types.Response(status: int, body: bytes)#
status: int#
body: bytes#
exception aiodynamo.http.types.RequestFailed(inner: Exception)#

Custom Credentials Loader#

If the methods to load credentials provided by aiodynamo are not sufficient for your use case, you can tell aiodynamo how to load credentials by creating a class which conforms to the aiodynamo.credentials.Credentials interface.

class aiodynamo.credentials.Credentials#
abstract async get_key(
http: Callable[[Request], Awaitable[Response]],
) Key | None#

Return a Key if one could be found.

abstract invalidate() bool#

Invalidate the credentials if possible and return whether credentials got invalidated or not.

abstract is_disabled() bool#

Indicate if this credentials provider is disabled. Used by ChainCredentials to ignore providers that won’t ever find a key.

If the status could change over the lifetime of a program, return True.