# 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 .get_phone_number_inbound_sip_trunk_config_response_model import GetPhoneNumberInboundSipTrunkConfigResponseModel
from .get_phone_number_outbound_sip_trunk_config_response_model import GetPhoneNumberOutboundSipTrunkConfigResponseModel
from .livekit_stack_type import LivekitStackType
from .phone_number_agent_info import PhoneNumberAgentInfo


class MergePreviewResponseModelPhoneNumbersItem_Exotel(UncheckedBaseModel):
    provider: typing.Literal["exotel"] = "exotel"
    phone_number: str
    label: str
    supports_inbound: typing.Optional[bool] = None
    supports_outbound: typing.Optional[bool] = None
    phone_number_id: str
    assigned_agent: typing.Optional[PhoneNumberAgentInfo] = 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 MergePreviewResponseModelPhoneNumbersItem_SipTrunk(UncheckedBaseModel):
    provider: typing.Literal["sip_trunk"] = "sip_trunk"
    phone_number: str
    label: str
    supports_inbound: typing.Optional[bool] = None
    supports_outbound: typing.Optional[bool] = None
    phone_number_id: str
    assigned_agent: typing.Optional[PhoneNumberAgentInfo] = None
    provider_config: typing.Optional[GetPhoneNumberOutboundSipTrunkConfigResponseModel] = None
    outbound_trunk: typing.Optional[GetPhoneNumberOutboundSipTrunkConfigResponseModel] = None
    inbound_trunk: typing.Optional[GetPhoneNumberInboundSipTrunkConfigResponseModel] = None
    livekit_stack: LivekitStackType
    store_sip_messages: typing.Optional[bool] = 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 MergePreviewResponseModelPhoneNumbersItem_Twilio(UncheckedBaseModel):
    provider: typing.Literal["twilio"] = "twilio"
    phone_number: str
    label: str
    supports_inbound: typing.Optional[bool] = None
    supports_outbound: typing.Optional[bool] = None
    phone_number_id: str
    assigned_agent: typing.Optional[PhoneNumberAgentInfo] = 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


MergePreviewResponseModelPhoneNumbersItem = typing_extensions.Annotated[
    typing.Union[
        MergePreviewResponseModelPhoneNumbersItem_Exotel,
        MergePreviewResponseModelPhoneNumbersItem_SipTrunk,
        MergePreviewResponseModelPhoneNumbersItem_Twilio,
    ],
    UnionMetadata(discriminant="provider"),
]
