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

from __future__ import annotations
import httpx
from leonardo_ai_sdk.models.shared import (
    job_status as shared_job_status,
    variation_type as shared_variation_type,
)
from leonardo_ai_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from leonardo_ai_sdk.utils import FieldMetadata, PathParamMetadata
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class GetVariationByIDRequestTypedDict(TypedDict):
    id: str
    r"""\"id\" is required"""


class GetVariationByIDRequest(BaseModel):
    id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""\"id\" is required"""


class GeneratedImageVariationGenericTypedDict(TypedDict):
    r"""columns and relationships of \"generated_image_variation_generic\" """

    created_at: NotRequired[str]
    id: NotRequired[Nullable[str]]
    status: NotRequired[shared_job_status.JobStatus]
    r"""The status of the current task."""
    transform_type: NotRequired[shared_variation_type.VariationType]
    r"""The type of variation."""
    url: NotRequired[Nullable[str]]


class GeneratedImageVariationGeneric(BaseModel):
    r"""columns and relationships of \"generated_image_variation_generic\" """

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

    id: OptionalNullable[str] = UNSET

    status: Optional[shared_job_status.JobStatus] = None
    r"""The status of the current task."""

    transform_type: Annotated[
        Optional[shared_variation_type.VariationType],
        pydantic.Field(alias="transformType"),
    ] = None
    r"""The type of variation."""

    url: OptionalNullable[str] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["createdAt", "id", "status", "transformType", "url"]
        nullable_fields = ["id", "url"]
        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 GetVariationByIDResponseBodyTypedDict(TypedDict):
    r"""Responses for GET /variations/{id}"""

    generated_image_variation_generic: NotRequired[
        List[GeneratedImageVariationGenericTypedDict]
    ]


class GetVariationByIDResponseBody(BaseModel):
    r"""Responses for GET /variations/{id}"""

    generated_image_variation_generic: Optional[
        List[GeneratedImageVariationGeneric]
    ] = None


class GetVariationByIDResponseTypedDict(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[GetVariationByIDResponseBodyTypedDict]
    r"""Responses for GET /variations/{id}"""


class GetVariationByIDResponse(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[GetVariationByIDResponseBody] = None
    r"""Responses for GET /variations/{id}"""
