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

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata
from .api_integration_o_auth_2_auth_code_response_scope_separator import (
    ApiIntegrationOAuth2AuthCodeResponseScopeSeparator,
)
from .api_integration_o_auth_2_custom_app_response_scope_separator import (
    ApiIntegrationOAuth2CustomAppResponseScopeSeparator,
)
from .auth_connection_dependencies import AuthConnectionDependencies
from .o_auth_2_jwt_response_algorithm import OAuth2JwtResponseAlgorithm
from .o_auth_2_jwt_response_token_response_field import OAuth2JwtResponseTokenResponseField
from .o_auth_connection_status import OAuthConnectionStatus
from .private_key_jwt_response_algorithm import PrivateKeyJwtResponseAlgorithm


class ListAuthConnectionsResponseAuthConnectionsItem_ApiIntegrationOauth2AuthCode(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["api_integration_oauth2_auth_code"] = "api_integration_oauth2_auth_code"
    name: str
    provider: str
    token_url: str
    scopes: typing.Optional[typing.List[str]] = None
    scope_separator: typing.Optional[ApiIntegrationOAuth2AuthCodeResponseScopeSeparator] = None
    expires_at: str
    integration_id: str
    credential_id: str
    status: typing.Optional[OAuthConnectionStatus] = None
    status_detail: typing.Optional[str] = None
    status_updated_at: typing.Optional[str] = None
    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


class ListAuthConnectionsResponseAuthConnectionsItem_ApiIntegrationOauth2CustomApp(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["api_integration_oauth2_custom_app"] = "api_integration_oauth2_custom_app"
    name: str
    provider: str
    token_url: str
    scopes: typing.Optional[typing.List[str]] = None
    scope_separator: typing.Optional[ApiIntegrationOAuth2CustomAppResponseScopeSeparator] = None
    expires_at: str
    integration_id: str
    credential_id: str
    status: typing.Optional[OAuthConnectionStatus] = None
    status_detail: typing.Optional[str] = None
    status_updated_at: typing.Optional[str] = None
    client_id: str
    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


class ListAuthConnectionsResponseAuthConnectionsItem_BasicAuth(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["basic_auth"] = "basic_auth"
    name: str
    provider: str
    username: str
    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


class ListAuthConnectionsResponseAuthConnectionsItem_BearerAuth(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["bearer_auth"] = "bearer_auth"
    name: str
    provider: str
    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


class ListAuthConnectionsResponseAuthConnectionsItem_CustomHeaderAuth(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["custom_header_auth"] = "custom_header_auth"
    name: str
    provider: str
    header_name: str
    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


class ListAuthConnectionsResponseAuthConnectionsItem_Mtls(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["mtls"] = "mtls"
    name: str
    provider: str
    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


class ListAuthConnectionsResponseAuthConnectionsItem_Oauth2ClientCredentials(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["oauth2_client_credentials"] = "oauth2_client_credentials"
    name: str
    provider: str
    client_id: str
    token_url: str
    scopes: typing.Optional[typing.List[str]] = None
    extra_params: typing.Optional[typing.Dict[str, str]] = None
    basic_auth_in_header: typing.Optional[bool] = None
    id: str
    used_by: typing.Optional[AuthConnectionDependencies] = None
    custom_headers: typing.Optional[typing.Dict[str, 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


class ListAuthConnectionsResponseAuthConnectionsItem_Oauth2Jwt(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["oauth2_jwt"] = "oauth2_jwt"
    name: str
    provider: str
    algorithm: typing.Optional[OAuth2JwtResponseAlgorithm] = None
    key_id: typing.Optional[str] = None
    issuer: str
    audience: str
    subject: str
    expiration_seconds: typing.Optional[int] = None
    extra_params: typing.Optional[typing.Dict[str, str]] = None
    token_url: str
    scopes: typing.Optional[typing.List[str]] = None
    token_response_field: typing.Optional[OAuth2JwtResponseTokenResponseField] = None
    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


class ListAuthConnectionsResponseAuthConnectionsItem_PrivateKeyJwt(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["private_key_jwt"] = "private_key_jwt"
    name: str
    provider: str
    algorithm: typing.Optional[PrivateKeyJwtResponseAlgorithm] = None
    key_id: typing.Optional[str] = None
    issuer: str
    audience: str
    subject: str
    expiration_seconds: typing.Optional[int] = None
    extra_params: typing.Optional[typing.Dict[str, str]] = None
    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


class ListAuthConnectionsResponseAuthConnectionsItem_SlackBotAuth(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["slack_bot_auth"] = "slack_bot_auth"
    name: str
    provider: typing.Optional[typing.Literal["Slack"]] = None
    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


class ListAuthConnectionsResponseAuthConnectionsItem_UrlSecret(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["url_secret"] = "url_secret"
    name: str
    provider: str
    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


class ListAuthConnectionsResponseAuthConnectionsItem_WhatsappAuth(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["whatsapp_auth"] = "whatsapp_auth"
    name: str
    provider: typing.Optional[typing.Literal["whatsapp"]] = None
    phone_number_id: str
    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


ListAuthConnectionsResponseAuthConnectionsItem = typing_extensions.Annotated[
    typing.Union[
        ListAuthConnectionsResponseAuthConnectionsItem_ApiIntegrationOauth2AuthCode,
        ListAuthConnectionsResponseAuthConnectionsItem_ApiIntegrationOauth2CustomApp,
        ListAuthConnectionsResponseAuthConnectionsItem_BasicAuth,
        ListAuthConnectionsResponseAuthConnectionsItem_BearerAuth,
        ListAuthConnectionsResponseAuthConnectionsItem_CustomHeaderAuth,
        ListAuthConnectionsResponseAuthConnectionsItem_Mtls,
        ListAuthConnectionsResponseAuthConnectionsItem_Oauth2ClientCredentials,
        ListAuthConnectionsResponseAuthConnectionsItem_Oauth2Jwt,
        ListAuthConnectionsResponseAuthConnectionsItem_PrivateKeyJwt,
        ListAuthConnectionsResponseAuthConnectionsItem_SlackBotAuth,
        ListAuthConnectionsResponseAuthConnectionsItem_UrlSecret,
        ListAuthConnectionsResponseAuthConnectionsItem_WhatsappAuth,
    ],
    UnionMetadata(discriminant="auth_type"),
]
