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

from __future__ import annotations
import httpx
from leonardo_ai_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from leonardo_ai_sdk.utils import (
    FieldMetadata,
    PathParamMetadata,
    QueryParamMetadata,
    RequestMetadata,
)
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class Get3DModelsByUserIDRequestBodyTypedDict(TypedDict):
    r"""Query parameters can also be provided in the request body as a JSON object"""

    user_id: NotRequired[Nullable[str]]


class Get3DModelsByUserIDRequestBody(BaseModel):
    r"""Query parameters can also be provided in the request body as a JSON object"""

    user_id: Annotated[OptionalNullable[str], pydantic.Field(alias="userId")] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["userId"]
        nullable_fields = ["userId"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class Get3DModelsByUserIDRequestTypedDict(TypedDict):
    user_id: str
    request_body: NotRequired[Get3DModelsByUserIDRequestBodyTypedDict]
    r"""Query parameters can also be provided in the request body as a JSON object"""
    limit: NotRequired[int]
    offset: NotRequired[int]


class Get3DModelsByUserIDRequest(BaseModel):
    user_id: Annotated[
        str,
        pydantic.Field(alias="userId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]

    request_body: Annotated[
        Optional[Get3DModelsByUserIDRequestBody],
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ] = None
    r"""Query parameters can also be provided in the request body as a JSON object"""

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

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


class Get3DModelsByUserIDModelAssetsTypedDict(TypedDict):
    r"""columns and relationships of \"model_assets\" """

    created_at: NotRequired[str]
    id: NotRequired[Nullable[str]]
    mesh_url: NotRequired[str]
    name: NotRequired[Nullable[str]]
    updated_at: NotRequired[str]
    user_id: NotRequired[Nullable[str]]


class Get3DModelsByUserIDModelAssets(BaseModel):
    r"""columns and relationships of \"model_assets\" """

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

    id: OptionalNullable[str] = UNSET

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

    name: OptionalNullable[str] = UNSET

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

    user_id: Annotated[OptionalNullable[str], pydantic.Field(alias="userId")] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["createdAt", "id", "meshUrl", "name", "updatedAt", "userId"]
        nullable_fields = ["id", "name", "userId"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class Get3DModelsByUserIDResponseBodyTypedDict(TypedDict):
    r"""Responses for GET /api/rest/v1/models-3d/user/{userId}"""

    model_assets: NotRequired[List[Get3DModelsByUserIDModelAssetsTypedDict]]


class Get3DModelsByUserIDResponseBody(BaseModel):
    r"""Responses for GET /api/rest/v1/models-3d/user/{userId}"""

    model_assets: Optional[List[Get3DModelsByUserIDModelAssets]] = None


class Get3DModelsByUserIDResponseTypedDict(TypedDict):
    content_type: str
    r"""HTTP response content type for this operation"""
    status_code: int
    r"""HTTP response status code for this operation"""
    raw_response: httpx.Response
    r"""Raw HTTP response; suitable for custom response parsing"""
    object: NotRequired[Get3DModelsByUserIDResponseBodyTypedDict]
    r"""Responses for GET /api/rest/v1/models-3d/user/{userId}"""


class Get3DModelsByUserIDResponse(BaseModel):
    content_type: str
    r"""HTTP response content type for this operation"""

    status_code: int
    r"""HTTP response status code for this operation"""

    raw_response: httpx.Response
    r"""Raw HTTP response; suitable for custom response parsing"""

    object: Optional[Get3DModelsByUserIDResponseBody] = None
    r"""Responses for GET /api/rest/v1/models-3d/user/{userId}"""
