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

from __future__ import annotations
from .directionenum import DirectionEnum
from .layoutresponsedtosortfield import LayoutResponseDtoSortField
from .listlayoutresponsedto import ListLayoutResponseDto, ListLayoutResponseDtoTypedDict
from novu_py.types import BaseModel, UNSET_SENTINEL
from novu_py.utils import FieldMetadata, HeaderMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class LayoutsControllerListRequestTypedDict(TypedDict):
    limit: NotRequired[float]
    r"""Number of items to return per page"""
    offset: NotRequired[float]
    r"""Number of items to skip before starting to return results"""
    order_direction: NotRequired[DirectionEnum]
    r"""Direction of sorting"""
    order_by: NotRequired[LayoutResponseDtoSortField]
    r"""Field to sort the results by"""
    query: NotRequired[str]
    r"""Search query to filter layouts"""
    idempotency_key: NotRequired[str]
    r"""A header for idempotency purposes"""


class LayoutsControllerListRequest(BaseModel):
    limit: Annotated[
        Optional[float],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Number of items to return per page"""

    offset: Annotated[
        Optional[float],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Number of items to skip before starting to return results"""

    order_direction: Annotated[
        Optional[DirectionEnum],
        pydantic.Field(alias="orderDirection"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Direction of sorting"""

    order_by: Annotated[
        Optional[LayoutResponseDtoSortField],
        pydantic.Field(alias="orderBy"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Field to sort the results by"""

    query: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Search query to filter layouts"""

    idempotency_key: Annotated[
        Optional[str],
        pydantic.Field(alias="idempotency-key"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ] = None
    r"""A header for idempotency purposes"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["limit", "offset", "orderDirection", "orderBy", "query", "idempotency-key"]
        )
        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 LayoutsControllerListResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: ListLayoutResponseDtoTypedDict


class LayoutsControllerListResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: ListLayoutResponseDto
