# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel


class ApiKeyResponse(UniversalBaseModel):
    """
    Response schema for API key (without sensitive data).
    """

    id: str = pydantic.Field()
    """
    API key ID
    """

    organization_id: str = pydantic.Field()
    """
    Organization ID
    """

    key_name: str = pydantic.Field()
    """
    Key name
    """

    key_prefix: str = pydantic.Field()
    """
    Key prefix for identification
    """

    is_active: bool = pydantic.Field()
    """
    Whether the key is active
    """

    is_paused: bool = pydantic.Field()
    """
    Whether the key is paused
    """

    usage_limit_chf: typing.Optional[float] = pydantic.Field(default=None)
    """
    Per-key spending limit
    """

    scopes: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Permission scopes
    """

    metadata: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Additional key metadata
    """

    created_by: str = pydantic.Field()
    """
    User ID who created the key
    """

    created_at: dt.datetime = pydantic.Field()
    """
    Creation timestamp
    """

    last_used_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Last use timestamp
    """

    expires_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Expiration timestamp
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
