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

from __future__ import annotations
import warnings
from lambdadb.types import BaseModel, UNSET_SENTINEL
from lambdadb.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ListDocsRequestTypedDict(TypedDict):
    collection_name: str
    r"""Collection name."""
    size: NotRequired[int]
    r"""Max number of documents to return at once."""
    page_token: NotRequired[str]
    r"""Next page token."""


class ListDocsRequest(BaseModel):
    collection_name: Annotated[
        str,
        pydantic.Field(alias="collectionName"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""Collection name."""

    size: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Max number of documents to return at once."""

    page_token: Annotated[
        Optional[str],
        pydantic.Field(alias="pageToken"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Next page token."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["size", "pageToken"])
        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 ListDocsResponseTypedDict(TypedDict):
    r"""Documents list."""

    total: int
    results: List[Dict[str, Any]]
    r"""List of result items (documents or items with 'doc' key)."""
    next_page_token: NotRequired[str]


class ListDocsResponse(BaseModel):
    r"""Documents list."""

    total: int

    results: Annotated[
        List[Dict[str, Any]],
        pydantic.Field(alias="docs"),
    ]
    r"""List of result items (documents or items with 'doc' key)."""

    next_page_token: Annotated[Optional[str], pydantic.Field(alias="nextPageToken")] = (
        None
    )

    @property
    def docs(self) -> List[Dict[str, Any]]:
        """Deprecated: use .results instead. List of result items."""
        warnings.warn(
            "ListDocsResponse.docs is deprecated; use .results instead.",
            DeprecationWarning,
            stacklevel=2,
        )
        return self.results

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