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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .fallback_model import FallbackModel
from .fallback_when import FallbackWhen


class FallbackRule(UniversalBaseModel):
    """
    +label=Fallback Rule
    """

    id: str = pydantic.Field()
    """
    +usage=Unique identifier for the rule
    +uiProps={"descriptionInline":true}
    +sort=1
    +label=Rule ID
    """

    when: FallbackWhen
    fallback_models: typing.List[FallbackModel] = pydantic.Field()
    """
    +usage=List of fallback models to try in sequence
    +uiProps={"descriptionInline":true}
    +sort=3
    +label=Fallback Models
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow")  # type: ignore # Pydantic v2
    else:

        class Config:
            smart_union = True
            extra = pydantic.Extra.allow
