# 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.create_o_auth_2_jwt_request_algorithm import CreateOAuth2JwtRequestAlgorithm
from ....types.create_o_auth_2_jwt_request_token_response_field import CreateOAuth2JwtRequestTokenResponseField
from ....types.create_private_key_jwt_request_algorithm import CreatePrivateKeyJwtRequestAlgorithm


class AuthConnectionsCreateRequestBody_Oauth2ClientCredentials(UncheckedBaseModel):
    """
    Auth connection to create
    """

    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
    client_secret: str
    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 AuthConnectionsCreateRequestBody_CustomHeaderAuth(UncheckedBaseModel):
    """
    Auth connection to create
    """

    auth_type: typing.Literal["custom_header_auth"] = "custom_header_auth"
    name: str
    provider: str
    header_name: str
    token: str

    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 AuthConnectionsCreateRequestBody_BasicAuth(UncheckedBaseModel):
    """
    Auth connection to create
    """

    auth_type: typing.Literal["basic_auth"] = "basic_auth"
    name: str
    provider: str
    username: str
    password: str

    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 AuthConnectionsCreateRequestBody_BearerAuth(UncheckedBaseModel):
    """
    Auth connection to create
    """

    auth_type: typing.Literal["bearer_auth"] = "bearer_auth"
    name: str
    provider: str
    token: str

    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 AuthConnectionsCreateRequestBody_Oauth2Jwt(UncheckedBaseModel):
    """
    Auth connection to create
    """

    auth_type: typing.Literal["oauth2_jwt"] = "oauth2_jwt"
    name: str
    provider: str
    algorithm: typing.Optional[CreateOAuth2JwtRequestAlgorithm] = 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[CreateOAuth2JwtRequestTokenResponseField] = None
    secret_key: str

    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 AuthConnectionsCreateRequestBody_PrivateKeyJwt(UncheckedBaseModel):
    """
    Auth connection to create
    """

    auth_type: typing.Literal["private_key_jwt"] = "private_key_jwt"
    name: str
    provider: str
    algorithm: typing.Optional[CreatePrivateKeyJwtRequestAlgorithm] = 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
    secret_key: str

    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 AuthConnectionsCreateRequestBody_Mtls(UncheckedBaseModel):
    """
    Auth connection to create
    """

    auth_type: typing.Literal["mtls"] = "mtls"
    name: str
    provider: str
    client_certificate: str
    client_key: str
    ca_certificate: typing.Optional[str] = None
    key_passphrase: 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


AuthConnectionsCreateRequestBody = typing_extensions.Annotated[
    typing.Union[
        AuthConnectionsCreateRequestBody_Oauth2ClientCredentials,
        AuthConnectionsCreateRequestBody_CustomHeaderAuth,
        AuthConnectionsCreateRequestBody_BasicAuth,
        AuthConnectionsCreateRequestBody_BearerAuth,
        AuthConnectionsCreateRequestBody_Oauth2Jwt,
        AuthConnectionsCreateRequestBody_PrivateKeyJwt,
        AuthConnectionsCreateRequestBody_Mtls,
    ],
    UnionMetadata(discriminant="auth_type"),
]
