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

from __future__ import annotations
from .attribute import Attribute, AttributeTypedDict
from attio.types import BaseModel, UNSET_SENTINEL
from attio.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
from pydantic import model_serializer
from typing import List, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


GetV2TargetIdentifierAttributesTarget = Literal[
    "objects",
    "lists",
]
r"""Whether the attributes are on an object or a list."""


class GetV2TargetIdentifierAttributesRequestTypedDict(TypedDict):
    target: GetV2TargetIdentifierAttributesTarget
    r"""Whether the attributes are on an object or a list."""
    identifier: str
    limit: NotRequired[int]
    offset: NotRequired[int]
    show_archived: NotRequired[bool]


class GetV2TargetIdentifierAttributesRequest(BaseModel):
    target: Annotated[
        GetV2TargetIdentifierAttributesTarget,
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""Whether the attributes are on an object or a list."""

    identifier: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]

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

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

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

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


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

    data: List[AttributeTypedDict]


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

    data: List[Attribute]
