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

from __future__ import annotations
from .list_view import ListView, ListViewTypedDict
from attio.types import BaseModel, Nullable, UNSET_SENTINEL
from attio.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import List, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class GetV2ListsListViewsRequestTypedDict(TypedDict):
    list_id: str
    show_archived: NotRequired[bool]
    limit: NotRequired[int]
    cursor: NotRequired[str]


class GetV2ListsListViewsRequest(BaseModel):
    list_id: Annotated[
        str,
        pydantic.Field(alias="list"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]

    show_archived: Annotated[
        Optional[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = False

    limit: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 500

    cursor: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

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


GetV2ListsListViewsType = Literal["invalid_request_error",]


GetV2ListsListViewsCode = Literal["not_found",]


class GetV2ListsListViewsPaginationTypedDict(TypedDict):
    next_cursor: Nullable[str]


class GetV2ListsListViewsPagination(BaseModel):
    next_cursor: Nullable[str]

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

        return m


class GetV2ListsListViewsResponseTypedDict(TypedDict):
    r"""Success"""

    data: List[ListViewTypedDict]
    pagination: GetV2ListsListViewsPaginationTypedDict


class GetV2ListsListViewsResponse(BaseModel):
    r"""Success"""

    data: List[ListView]

    pagination: GetV2ListsListViewsPagination
