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

from __future__ import annotations
from enum import Enum
from lambdadb.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class DataType(str, Enum):
    r"""Partition field data type."""

    KEYWORD = "keyword"


class PartitionConfigTypedDict(TypedDict):
    field_name: NotRequired[str]
    r"""Partition field name."""
    data_type: NotRequired[DataType]
    r"""Partition field data type."""
    num_partitions: NotRequired[int]
    r"""The number of partitions."""


class PartitionConfig(BaseModel):
    field_name: Annotated[Optional[str], pydantic.Field(alias="fieldName")] = None
    r"""Partition field name."""

    data_type: Annotated[Optional[DataType], pydantic.Field(alias="dataType")] = None
    r"""Partition field data type."""

    num_partitions: Annotated[Optional[int], pydantic.Field(alias="numPartitions")] = (
        None
    )
    r"""The number of partitions."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["fieldName", "dataType", "numPartitions"])
        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
