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

from __future__ import annotations
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
from unkey.py.types import BaseModel, UNSET_SENTINEL


class V2IdentitiesListIdentitiesRequestBodyTypedDict(TypedDict):
    limit: NotRequired[int]
    r"""The maximum number of identities to return in a single request. Use this to control response size and loading performance."""
    cursor: NotRequired[str]
    r"""Pagination cursor from a previous response. Use this to fetch subsequent pages of results when the response contains a cursor value."""


class V2IdentitiesListIdentitiesRequestBody(BaseModel):
    limit: Optional[int] = 100
    r"""The maximum number of identities to return in a single request. Use this to control response size and loading performance."""

    cursor: Optional[str] = None
    r"""Pagination cursor from a previous response. Use this to fetch subsequent pages of results when the response contains a cursor value."""

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

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

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

        return m
