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


class ListPlatformModelsGeneratedImagesTypedDict(TypedDict):
    r"""columns and relationships of \"generated_images\" """

    id: NotRequired[Nullable[str]]
    url: NotRequired[str]


class ListPlatformModelsGeneratedImages(BaseModel):
    r"""columns and relationships of \"generated_images\" """

    id: OptionalNullable[str] = UNSET

    url: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["id", "url"]
        nullable_fields = ["id"]
        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 ListPlatformModelsCustomModelsTypedDict(TypedDict):
    r"""columns and relationships of \"custom_models\" """

    description: NotRequired[str]
    featured: NotRequired[bool]
    generated_image: NotRequired[Nullable[ListPlatformModelsGeneratedImagesTypedDict]]
    r"""columns and relationships of \"generated_images\" """
    id: NotRequired[Nullable[str]]
    name: NotRequired[str]
    nsfw: NotRequired[bool]


class ListPlatformModelsCustomModels(BaseModel):
    r"""columns and relationships of \"custom_models\" """

    description: Optional[str] = None

    featured: Optional[bool] = None

    generated_image: OptionalNullable[ListPlatformModelsGeneratedImages] = UNSET
    r"""columns and relationships of \"generated_images\" """

    id: OptionalNullable[str] = UNSET

    name: Optional[str] = None

    nsfw: Optional[bool] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "description",
            "featured",
            "generated_image",
            "id",
            "name",
            "nsfw",
        ]
        nullable_fields = ["generated_image", "id"]
        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 ListPlatformModelsResponseBodyTypedDict(TypedDict):
    r"""Responses for GET /api/rest/v1/platformModels"""

    custom_models: NotRequired[List[ListPlatformModelsCustomModelsTypedDict]]


class ListPlatformModelsResponseBody(BaseModel):
    r"""Responses for GET /api/rest/v1/platformModels"""

    custom_models: Optional[List[ListPlatformModelsCustomModels]] = None


class ListPlatformModelsResponseTypedDict(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[ListPlatformModelsResponseBodyTypedDict]
    r"""Responses for GET /api/rest/v1/platformModels"""


class ListPlatformModelsResponse(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[ListPlatformModelsResponseBody] = None
    r"""Responses for GET /api/rest/v1/platformModels"""
