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

    image_id: str
    r"""The ID of the image, supports generated images, variation images, and init images."""
    is_init_image: NotRequired[Nullable[bool]]
    r"""If it is an init image uploaded by the user. This image is uploaded from endpoint: Upload init image."""
    is_public: NotRequired[Nullable[bool]]
    r"""Whether the generation is public or not"""
    is_variation: NotRequired[Nullable[bool]]
    r"""If it is a variation image."""
    motion_strength: NotRequired[Nullable[int]]
    r"""The motion strength."""


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

    image_id: Annotated[str, pydantic.Field(alias="imageId")]
    r"""The ID of the image, supports generated images, variation images, and init images."""

    is_init_image: Annotated[
        OptionalNullable[bool], pydantic.Field(alias="isInitImage")
    ] = UNSET
    r"""If it is an init image uploaded by the user. This image is uploaded from endpoint: Upload init image."""

    is_public: Annotated[OptionalNullable[bool], pydantic.Field(alias="isPublic")] = (
        UNSET
    )
    r"""Whether the generation is public or not"""

    is_variation: Annotated[
        OptionalNullable[bool], pydantic.Field(alias="isVariation")
    ] = UNSET
    r"""If it is a variation image."""

    motion_strength: Annotated[
        OptionalNullable[int], pydantic.Field(alias="motionStrength")
    ] = UNSET
    r"""The motion strength."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["isInitImage", "isPublic", "isVariation", "motionStrength"]
        nullable_fields = ["isInitImage", "isPublic", "isVariation", "motionStrength"]
        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 MotionSvdGenerationOutputTypedDict(TypedDict):
    api_credit_cost: NotRequired[Nullable[int]]
    r"""API credits cost, available for Production API users."""
    generation_id: NotRequired[str]


class MotionSvdGenerationOutput(BaseModel):
    api_credit_cost: Annotated[
        OptionalNullable[int], pydantic.Field(alias="apiCreditCost")
    ] = UNSET
    r"""API credits cost, available for Production API users."""

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["apiCreditCost", "generationId"]
        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 CreateSVDMotionGenerationResponseBodyTypedDict(TypedDict):
    r"""Responses for POST /generations-motion-svd"""

    sd_generation_job: NotRequired[Nullable[MotionSvdGenerationOutputTypedDict]]


class CreateSVDMotionGenerationResponseBody(BaseModel):
    r"""Responses for POST /generations-motion-svd"""

    sd_generation_job: Annotated[
        OptionalNullable[MotionSvdGenerationOutput],
        pydantic.Field(alias="sdGenerationJob"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["sdGenerationJob"]
        nullable_fields = ["sdGenerationJob"]
        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 CreateSVDMotionGenerationResponseTypedDict(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[CreateSVDMotionGenerationResponseBodyTypedDict]
    r"""Responses for POST /generations-motion-svd"""


class CreateSVDMotionGenerationResponse(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[CreateSVDMotionGenerationResponseBody] = None
    r"""Responses for POST /generations-motion-svd"""
