"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from lambdadb.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import List, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict


class FieldsSelector2TypedDict(TypedDict):
    exclude: List[str]
    r"""List of field names to exclude in the result."""
    include: NotRequired[List[str]]
    r"""List of field names to include in the result."""


class FieldsSelector2(BaseModel):
    exclude: List[str]
    r"""List of field names to exclude in the result."""

    include: Optional[List[str]] = None
    r"""List of field names to include in the result."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["include"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class FieldsSelector1TypedDict(TypedDict):
    include: List[str]
    r"""List of field names to include in the result."""
    exclude: NotRequired[List[str]]
    r"""List of field names to exclude in the result."""


class FieldsSelector1(BaseModel):
    include: List[str]
    r"""List of field names to include in the result."""

    exclude: Optional[List[str]] = None
    r"""List of field names to exclude in the result."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["exclude"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


FieldsSelectorUnionTypedDict = TypeAliasType(
    "FieldsSelectorUnionTypedDict",
    Union[FieldsSelector1TypedDict, FieldsSelector2TypedDict],
)
r"""An object to specify a list of field names to include and/or exclude in the result."""


FieldsSelectorUnion = TypeAliasType(
    "FieldsSelectorUnion", Union[FieldsSelector1, FieldsSelector2]
)
r"""An object to specify a list of field names to include and/or exclude in the result."""
