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

from __future__ import annotations

import datetime as dt
import typing

import pydantic
import typing_extensions
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .role import Role
from .service_account_key import ServiceAccountKey


class FhirProviderCreateRequestAuth_Jwt(UniversalBaseModel):
    auth_method: typing.Literal["jwt"] = "jwt"
    client_id: str
    credential_expiry: typing.Optional[dt.datetime] = None
    role: typing.Optional[Role] = None
    scopes: 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 FhirProviderCreateRequestAuth_ClientSecret(UniversalBaseModel):
    auth_method: typing.Literal["client_secret"] = "client_secret"
    client_id: str
    client_secret: str
    role: typing.Optional[Role] = None
    scopes: 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 FhirProviderCreateRequestAuth_OnBehalfOf(UniversalBaseModel):
    auth_method: typing.Literal["on_behalf_of"] = "on_behalf_of"
    client_id: str
    client_secret: str
    role: typing.Optional[Role] = None
    scopes: 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 FhirProviderCreateRequestAuth_GoogleHealthcare(UniversalBaseModel):
    auth_method: typing.Literal["google_healthcare"] = "google_healthcare"
    service_account_key: ServiceAccountKey

    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 FhirProviderCreateRequestAuth_TokenPassthrough(UniversalBaseModel):
    auth_method: typing.Literal["token_passthrough"] = "token_passthrough"

    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 FhirProviderCreateRequestAuth_None(UniversalBaseModel):
    auth_method: typing.Literal["none"] = "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


FhirProviderCreateRequestAuth = typing_extensions.Annotated[
    typing.Union[
        FhirProviderCreateRequestAuth_Jwt,
        FhirProviderCreateRequestAuth_ClientSecret,
        FhirProviderCreateRequestAuth_OnBehalfOf,
        FhirProviderCreateRequestAuth_GoogleHealthcare,
        FhirProviderCreateRequestAuth_TokenPassthrough,
        FhirProviderCreateRequestAuth_None,
    ],
    pydantic.Field(discriminator="auth_method"),
]
