# 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.update_o_auth_2_jwt_request_algorithm import UpdateOAuth2JwtRequestAlgorithm
from ....types.update_o_auth_2_jwt_request_token_response_field import UpdateOAuth2JwtRequestTokenResponseField


class AuthConnectionsUpdateRequestBody_Oauth2ClientCredentials(UncheckedBaseModel):
    """
    Updated auth connection fields
    """

    auth_type: typing.Literal["oauth2_client_credentials"] = "oauth2_client_credentials"
    provider: typing.Optional[str] = None
    client_id: typing.Optional[str] = None
    scopes: typing.Optional[typing.List[str]] = None
    extra_params: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None
    basic_auth_in_header: typing.Optional[bool] = None
    client_secret: typing.Optional[str] = None
    custom_headers: typing.Optional[typing.Dict[str, 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 AuthConnectionsUpdateRequestBody_BasicAuth(UncheckedBaseModel):
    """
    Updated auth connection fields
    """

    auth_type: typing.Literal["basic_auth"] = "basic_auth"
    provider: typing.Optional[str] = None
    username: typing.Optional[str] = None
    password: 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 AuthConnectionsUpdateRequestBody_Oauth2Jwt(UncheckedBaseModel):
    """
    Updated auth connection fields
    """

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


AuthConnectionsUpdateRequestBody = typing_extensions.Annotated[
    typing.Union[
        AuthConnectionsUpdateRequestBody_Oauth2ClientCredentials,
        AuthConnectionsUpdateRequestBody_BasicAuth,
        AuthConnectionsUpdateRequestBody_Oauth2Jwt,
    ],
    UnionMetadata(discriminant="auth_type"),
]
