class documentation

Simple bearer wrapper that attaches a static name to another bearer.

This may be used in some wrapper providers to cache the results of the shared receiver, or to report diagnostics.

This name should reflect the unique configuration of the underlying bearer.

Example

Wrap a custom bearer with a name and file cache:

from nebius.sdk import SDK
from nebius.aio.token.token import NamedBearer, Bearer, Receiver, Token
from nebius.aio.token.file_cache.async_renewable_bearer import (
    AsynchronousRenewableFileCacheBearer
)

class SomeCustomHeavyLoadBearer(Bearer):
    def receiver(self) -> Receiver:
        return SomeReceiver()

class SomeReceiver(Receiver):
    async def _fetch(self, timeout=None, options=None) -> Token:
        # Simulate heavy load token fetch
        return Token("heavy-token")

    def can_retry(self, err, options=None) -> bool:
        return False

custom_bearer = SomeCustomHeavyLoadBearer()
named_bearer = NamedBearer(custom_bearer, "heavy-load-bearer")
cached_bearer = AsynchronousRenewableFileCacheBearer(named_bearer)

sdk = SDK(credentials=cached_bearer)
Parameters
wrappedThe inner bearer to delegate to.
nameThe name that reflects the configuration of the underlying bearer.
Method __init__ Wrap the passed-in bearer, attaching a name to it.
Method receiver Delegate to the wrapped bearer to obtain a receiver.
Property name Return the configured name for this bearer.
Property wrapped Return the wrapped bearer.
Instance Variable _name Undocumented
Instance Variable _wrapped Undocumented

Inherited from Bearer:

Async Method close Close the bearer and any wrapped resources.
def __init__(self, wrapped: Bearer, name: str): (source)

Wrap the passed-in bearer, attaching a name to it.

This name should reflect the unique configuration of the underlying bearer.

def receiver(self) -> Receiver: (source)

Delegate to the wrapped bearer to obtain a receiver.

Returns
ReceiverA Receiver obtained from the wrapped bearer.

Return the configured name for this bearer.

Returns
Always returns a name.

Return the wrapped bearer.

Undocumented

_wrapped = (source)

Undocumented