"""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,
)
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


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

    model_extension: NotRequired[str]
    name: NotRequired[Nullable[str]]


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

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

    name: OptionalNullable[str] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["modelExtension", "name"]
        nullable_fields = ["name"]
        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 ModelAssetUploadOutputTypedDict(TypedDict):
    model_fields_: NotRequired[Nullable[str]]
    model_id: NotRequired[Nullable[str]]
    model_key: NotRequired[Nullable[str]]
    model_url: NotRequired[Nullable[str]]


class ModelAssetUploadOutput(BaseModel):
    model_fields_: Annotated[
        OptionalNullable[str], pydantic.Field(alias="modelFields")
    ] = UNSET

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

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["modelFields", "modelId", "modelKey", "modelUrl"]
        nullable_fields = ["modelFields", "modelId", "modelKey", "modelUrl"]
        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 UploadModelAssetResponseBodyTypedDict(TypedDict):
    r"""Responses for POST /api/rest/v1/models-3d/upload"""

    upload_model_asset: NotRequired[Nullable[ModelAssetUploadOutputTypedDict]]


class UploadModelAssetResponseBody(BaseModel):
    r"""Responses for POST /api/rest/v1/models-3d/upload"""

    upload_model_asset: Annotated[
        OptionalNullable[ModelAssetUploadOutput],
        pydantic.Field(alias="uploadModelAsset"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["uploadModelAsset"]
        nullable_fields = ["uploadModelAsset"]
        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 UploadModelAssetResponseTypedDict(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[UploadModelAssetResponseBodyTypedDict]
    r"""Responses for POST /api/rest/v1/models-3d/upload"""


class UploadModelAssetResponse(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[UploadModelAssetResponseBody] = None
    r"""Responses for POST /api/rest/v1/models-3d/upload"""
