# 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 ...common.types.operator import Operator
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ...core.serialization import FieldMetadata


class Filter_String(UniversalBaseModel):
    field_type: typing_extensions.Annotated[typing.Literal["string"], FieldMetadata(alias="fieldType")] = "string"
    field: str
    operator: Operator
    value: 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 Filter_Number(UniversalBaseModel):
    field_type: typing_extensions.Annotated[typing.Literal["number"], FieldMetadata(alias="fieldType")] = "number"
    field: str
    operator: Operator
    value: int

    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 Filter_Boolean(UniversalBaseModel):
    field_type: typing_extensions.Annotated[typing.Literal["boolean"], FieldMetadata(alias="fieldType")] = "boolean"
    field: str
    operator: typing.Literal["=="] = "=="
    value: bool

    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 Filter_Datetime(UniversalBaseModel):
    field_type: typing_extensions.Annotated[typing.Literal["datetime"], FieldMetadata(alias="fieldType")] = "datetime"
    field: str
    operator: Operator
    value: dt.date

    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


Filter = typing.Union[Filter_String, Filter_Number, Filter_Boolean, Filter_Datetime]
