# 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
from .api_key_scope import ApiKeyScope


class ApiKeyResponse(UniversalBaseModel):
    """
    Response model for API key (excludes sensitive data).
    """

    created_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    When the key was created.
    """

    created_by: str = pydantic.Field()
    """
    member_id of the creator.
    """

    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Optional description.
    """

    id: str = pydantic.Field()
    """
    The unique identifier of the API key.
    """

    key_prefix: str = pydantic.Field()
    """
    Display prefix (e.g., 'sk_tu_abc...').
    """

    last_used_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    When the key was last used.
    """

    name: str = pydantic.Field()
    """
    Human-readable name for the API key.
    """

    org_id: str = pydantic.Field()
    """
    WorkOS organization ID.
    """

    revoked_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    When the key was revoked (soft delete).
    """

    scopes: typing.Optional[typing.List[ApiKeyScope]] = pydantic.Field(default=None)
    """
    List of resource scopes for this API key.
    """

    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
