# 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 ....types.api_integration_o_auth_2_auth_code_response_scope_separator import (
    ApiIntegrationOAuth2AuthCodeResponseScopeSeparator,
)
from ....types.api_integration_o_auth_2_custom_app_response_scope_separator import (
    ApiIntegrationOAuth2CustomAppResponseScopeSeparator,
)
from ....types.auth_connection_dependencies import AuthConnectionDependencies
from ....types.auth_connection_status import AuthConnectionStatus
from ....types.o_auth_2_jwt_response_algorithm import OAuth2JwtResponseAlgorithm
from ....types.o_auth_2_jwt_response_token_response_field import OAuth2JwtResponseTokenResponseField
from ....types.private_key_jwt_response_algorithm import PrivateKeyJwtResponseAlgorithm


class AuthConnectionsCreateResponse_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
    status: typing.Optional[AuthConnectionStatus] = None
    status_detail: typing.Optional[str] = None
    status_updated_at: typing.Optional[str] = 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 AuthConnectionsCreateResponse_RefreshTokenAuth(UncheckedBaseModel):
    """
    The type of auth connection config
    """

    auth_type: typing.Literal["refresh_token_auth"] = "refresh_token_auth"
    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
    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


class AuthConnectionsCreateResponse_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
    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


class AuthConnectionsCreateResponse_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
    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


class AuthConnectionsCreateResponse_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
    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


class AuthConnectionsCreateResponse_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
    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


class AuthConnectionsCreateResponse_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
    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


class AuthConnectionsCreateResponse_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
    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


class AuthConnectionsCreateResponse_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
    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


class AuthConnectionsCreateResponse_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
    client_id: str
    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


class AuthConnectionsCreateResponse_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
    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


class AuthConnectionsCreateResponse_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
    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


class AuthConnectionsCreateResponse_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
    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


AuthConnectionsCreateResponse = typing_extensions.Annotated[
    typing.Union[
        AuthConnectionsCreateResponse_Oauth2ClientCredentials,
        AuthConnectionsCreateResponse_RefreshTokenAuth,
        AuthConnectionsCreateResponse_BasicAuth,
        AuthConnectionsCreateResponse_BearerAuth,
        AuthConnectionsCreateResponse_Oauth2Jwt,
        AuthConnectionsCreateResponse_PrivateKeyJwt,
        AuthConnectionsCreateResponse_Mtls,
        AuthConnectionsCreateResponse_CustomHeaderAuth,
        AuthConnectionsCreateResponse_ApiIntegrationOauth2AuthCode,
        AuthConnectionsCreateResponse_ApiIntegrationOauth2CustomApp,
        AuthConnectionsCreateResponse_WhatsappAuth,
        AuthConnectionsCreateResponse_SlackBotAuth,
        AuthConnectionsCreateResponse_UrlSecret,
    ],
    UnionMetadata(discriminant="auth_type"),
]
