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: Union[typing_extensions.Literal['GET'], typing_extensions.Literal['POST']], url: str, headers: Union[Dict[str, str], NoneType], body: Union[bytes, NoneType])
class aiodynamo.http.types.Response(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
get_key(http: aiodynamo.http.types.HttpImplementation) → Optional[aiodynamo.credentials.Key]

Return a Key if one could be found.

invalidate() → bool

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

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.