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

from ......core.unchecked_base_model import UncheckedBaseModel
import typing
from ...base.types.timestamp import Timestamp
import pydantic
import datetime as dt
from .token_type_id import TokenTypeId
from ......core.pydantic_utilities import IS_PYDANTIC_V2


class Token(UncheckedBaseModel):
    """
    The Token object is the base object for representing tokens, API keys, and authentication credentials used across different contexts. This object provides common attributes for all token types, including protocol-specific authentication tokens (Kerberos, OIDC, SAML) and API/client tokens used for service authentication. When to use this object: Use the base <code>token</code> object directly in API activity events to represent API tokens, client tokens, or API keys used to authenticate API requests. Examples include: Okta API tokens, Microsoft Entra ID Application Registration client secrets, Stripe API keys, AWS API keys. When NOT to use this object: Do NOT use the base <code>token</code> object for protocol-specific authentication tokens in authentication events - use <code>authentication_token</code> instead (which extends this object). Do NOT use <code>token</code> for tracking credential lifecycle and usage patterns - use <code>programmatic_credential</code> instead.
    """

    created_time: typing.Optional[Timestamp] = pydantic.Field(default=None)
    """
    The time that the token was created.
    """

    created_time_dt: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    The time that the token was created.
    """

    expiration_time: typing.Optional[Timestamp] = pydantic.Field(default=None)
    """
    The expiration time of the token.
    """

    expiration_time_dt: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    The expiration time of the token.
    """

    is_renewable: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Indicates whether the token is renewable.
    """

    modified_time: typing.Optional[Timestamp] = pydantic.Field(default=None)
    """
    The last time the token was updated.
    """

    modified_time_dt: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    The last time the token was updated.
    """

    name: typing.Optional[str] = pydantic.Field(default=None)
    """
    The human-friendly name of a token or key, if available, such as the <code>name</code> from the Okta API Token API.
    """

    tenant_uid: typing.Optional[str] = pydantic.Field(default=None)
    """
    The unique identifier of the tenant or organization that owns the token or key, or the tenant context in which the token is authorized for use. This is particularly relevant in multi-tenant Identity Provider scenarios where tokens are scoped to specific tenants.
    """

    type: typing.Optional[str] = pydantic.Field(default=None)
    """
    The type of the token, normalized to the caption of the <code>type_id</code> value. This indicates whether the token is a Client Token, API Token, or one of the protocol-specific token types.
    """

    type_id: typing.Optional[TokenTypeId] = pydantic.Field(default=None)
    """
    The normalized token type identifier. Valid values: 0 (Unknown), 1 (Ticket Granting Ticket - Kerberos), 2 (Service Ticket - Kerberos), 3 (Identity Token - OIDC), 4 (Refresh Token - OIDC), 5 (SAML Assertion), 6 (Client Token - IdP-issued), 7 (API Token - generic API keys), 99 (Other).
    """

    uid: typing.Optional[str] = pydantic.Field(default=None)
    """
    The unique ID of a token or key, if available, such as the <code>Secret ID</code> of Entra ID Application Registration Client Secrets.
    """

    zone: typing.Optional[str] = pydantic.Field(default=None)
    """
    The network zone or geographic region that the token or key is authorized to be used from. This may represent network-based access restrictions, geographic limitations, or other zone-based authorization policies. Examples include Okta's network zone restrictions or cloud provider region restrictions.
    """

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

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