"""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 CreateVariationUpscaleRequestBodyTypedDict(TypedDict):
    r"""Query parameters are provided in the request body as a JSON object"""

    id: str


class CreateVariationUpscaleRequestBody(BaseModel):
    r"""Query parameters are provided in the request body as a JSON object"""

    id: str


class CreateVariationUpscaleSDUpscaleJobOutputTypedDict(TypedDict):
    api_credit_cost: NotRequired[Nullable[int]]
    r"""API Credits Cost for Upscale Variation. Available for Production API Users."""
    id: NotRequired[str]


class CreateVariationUpscaleSDUpscaleJobOutput(BaseModel):
    api_credit_cost: Annotated[
        OptionalNullable[int], pydantic.Field(alias="apiCreditCost")
    ] = UNSET
    r"""API Credits Cost for Upscale Variation. Available for Production API Users."""

    id: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["apiCreditCost", "id"]
        nullable_fields = ["apiCreditCost"]
        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 CreateVariationUpscaleResponseBodyTypedDict(TypedDict):
    r"""Responses for POST /variations/upscale"""

    sd_upscale_job: NotRequired[
        Nullable[CreateVariationUpscaleSDUpscaleJobOutputTypedDict]
    ]


class CreateVariationUpscaleResponseBody(BaseModel):
    r"""Responses for POST /variations/upscale"""

    sd_upscale_job: Annotated[
        OptionalNullable[CreateVariationUpscaleSDUpscaleJobOutput],
        pydantic.Field(alias="sdUpscaleJob"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["sdUpscaleJob"]
        nullable_fields = ["sdUpscaleJob"]
        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 CreateVariationUpscaleResponseTypedDict(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[CreateVariationUpscaleResponseBodyTypedDict]
    r"""Responses for POST /variations/upscale"""


class CreateVariationUpscaleResponse(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[CreateVariationUpscaleResponseBody] = None
    r"""Responses for POST /variations/upscale"""
