# 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 .auth_connection_status import AuthConnectionStatus


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
    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
    status: typing.Optional[AuthConnectionStatus] = None
    status_detail: typing.Optional[str] = None
    status_updated_at: typing.Optional[str] = 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
