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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
from .api_integration_o_auth_2_custom_app_response_scope_separator import (
    ApiIntegrationOAuth2CustomAppResponseScopeSeparator,
)
from .auth_connection_dependencies import AuthConnectionDependencies
from .o_auth_connection_status import OAuthConnectionStatus


class ApiIntegrationOAuth2CustomAppResponse(UncheckedBaseModel):
    """
    Response model for user-owned OAuth2 Custom App auth connections
    """

    name: str
    provider: str
    token_url: str
    scopes: typing.Optional[typing.List[str]] = None
    scope_separator: typing.Optional[ApiIntegrationOAuth2CustomAppResponseScopeSeparator] = pydantic.Field(default=None)
    """
    Separator for scopes
    """

    expires_at: str = pydantic.Field()
    """
    ISO 8601 timestamp of when the access token expires
    """

    integration_id: str
    credential_id: str
    status: typing.Optional[OAuthConnectionStatus] = pydantic.Field(default=None)
    """
    Current health status of the OAuth connection
    """

    status_detail: typing.Optional[str] = pydantic.Field(default=None)
    """
    Human-readable detail about the current status, e.g. the error message on refresh failure
    """

    status_updated_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    ISO 8601 timestamp of the last status change
    """

    client_id: str = pydantic.Field()
    """
    OAuth client ID (rendered from template if credential uses templated credentials, None for legacy connections)
    """

    id: str
    used_by: typing.Optional[AuthConnectionDependencies] = None

    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
