"""Protocols.""" from __future__ import annotations from typing import Any, Protocol, runtime_checkable class RequestContext(Protocol): """RequestContext keeps track of request-level data during a request.""" authorization: str | None = None identity_id: str | None = None profile_id: int | None = None profile_type: str | None = None class M2MTokenManager(Protocol): """M2MTokenManager gets an authorization token.""" def get_token_string(self) -> str: """Return a string.""" ... class AsyncM2MTokenManager(Protocol): """AsyncM2MTokenManager gets an authorization token.""" async def get_token_string(self) -> str: """Return a string.""" ... class SecretsManager(Protocol): """SecretsManager gets a secret string.""" def get_secret(self, secret_name: str) -> str | dict[str, Any]: """Return a string.""" ... @runtime_checkable class Cache(Protocol): """Cache protocol compatible with cachelib.""" def get(self, key: str) -> Any: """Get key value from cache.""" ... def set(self, key: str, value: Any, *, timeout: int | None = None) -> bool | None: """Set key with value to cache.""" ... @runtime_checkable class AsyncCache(Protocol): """Async cache protocol compatible with aiocache.""" async def get(self, key: str) -> Any: """Get key value from cache.""" ... async def set( self, key: str, value: Any, ttl: Any = None, **kwargs: Any ) -> bool | None: """Set key with value to cache.""" ...