class documentation

Fetch a token from one IMDS HTTP endpoint for a single SDK request.

Method __init__ Undocumented
Method can_retry Decide whether a failed authentication attempt should be retried.
Async Method _fetch Low-level asynchronous fetch implementation.
Async Method _fetch_with_retries Undocumented
Instance Variable _endpoint Undocumented
Instance Variable _fetches Undocumented
Instance Variable _invalid_token Undocumented
Instance Variable _metric_attempt Undocumented

Inherited from Receiver:

Async Method fetch Fetch a token and record it as the latest value.
Property latest Return the latest fetched token or None.
Instance Variable _latest The most recently fetched token, or None if no token has been fetched yet. Implementations may update this to support inspection or caching by callers.
def __init__(self, endpoint: str): (source)

Undocumented

def can_retry(self, err: Exception, options: dict[str, str] | None = None) -> bool: (source)

Decide whether a failed authentication attempt should be retried.

Inspect err and optional options. Return whether a new fetch call is likely to succeed, for example after credential refresh.

Default implementations should return False.

Parameters
err:ExceptionThe exception that triggered the retry decision.
options:dict[str, str] or NoneOptional implementation-specific options.
Returns
boolTrue when a retry is advisable, otherwise False.
async def _fetch(self, timeout: float | None = None, options: dict[str, str] | None = None) -> Token: (source)

Low-level asynchronous fetch implementation.

Subclasses must implement this token-retrieval method. Call fetch instead of this internal method. fetch records the result in _latest.

Parameters
timeout:optional floatOptional timeout in seconds for the fetch operation.
options:optional dict[str, str]Optional implementation-specific options forwarded by the request layer.
Returns
TokenA freshly fetched Token.
async def _fetch_with_retries(self) -> Token: (source)

Undocumented

_endpoint = (source)

Undocumented

_fetches: int = (source)

Undocumented

_invalid_token: str | None = (source)

Undocumented

_metric_attempt = (source)

Undocumented