Skip to content

Tokens

API models for the tokens endpoint.

GetTokenResponse

A model response from ravyapi.api.endpoints.tokens.Tokens.get_token.

Attributes

data: dict[str, Any] The raw data returned from the Ravy API. user: str The user ID associated with the token. access: list[str] A list of valid permission nodes for the token. application: int The application ID registered to the token. token_type: Literal["ravy", "ksoft"] The type of the token, either "ravy" or "ksoft."

Source code in ravyapi/api/models/tokens.py
class GetTokenResponse:
    """A model response from `ravyapi.api.endpoints.tokens.Tokens.get_token`.

    Attributes
    ----------
    data: dict[str, Any]
        The raw data returned from the Ravy API.
    user: str
        The user ID associated with the token.
    access: list[str]
        A list of valid permission nodes for the token.
    application: int
        The application ID registered to the token.
    token_type: Literal["ravy", "ksoft"]
        The type of the token, either "ravy" or "ksoft."
    """

    __slots__: tuple[str, ...] = (
        "_data",
        "_user",
        "_access",
        "_application",
        "_token_type",
    )

    def __init__(self, data: dict[str, Any]) -> None:
        self._data: dict[str, Any] = data
        self._user: int = int(data["user"])
        self._access: list[str] = data["access"]
        self._application: int = int(data["application"])
        self._token_type: Literal["ravy", "ksoft"] = data["type"]

    def __repr__(self) -> str:
        return (
            f"{self.__class__.__module__}.{self.__class__.__qualname__}"
            f"(user={self.user!r}, access={self.access!r}, application={self.application!r}, "
            f"token_type={self.token_type!r})"
        )

    @property
    def data(self) -> dict[str, Any]:
        """The raw data returned from the Ravy API."""
        return self._data

    @property
    def user(self) -> int:
        """The user ID associated with the token."""
        return self._user

    @property
    def access(self) -> list[str]:
        """A list of valid permission nodes for the token."""
        return self._access

    @property
    def application(self) -> int:
        """The application ID registered to the token."""
        return self._application

    @property
    def token_type(self) -> Literal["ravy", "ksoft"]:
        """The type of the token, either "ravy" or "ksoft.\" """
        return self._token_type

access: list[str] property

A list of valid permission nodes for the token.

application: int property

The application ID registered to the token.

data: dict[str, Any] property

The raw data returned from the Ravy API.

token_type: Literal['ravy', 'ksoft'] property

The type of the token, either "ravy" or "ksoft."

user: int property

The user ID associated with the token.