# coding: utf-8

"""
    FastAPI

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 0.1.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel
from pydantic import Field
from clients.image_gen.models.fixed_random_seed1 import FixedRandomSeed1
from clients.image_gen.models.output_video_animation_height import OutputVideoAnimationHeight
from clients.image_gen.models.output_video_animation_width import OutputVideoAnimationWidth
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class VideoGenerationRequest(BaseModel):
    """
    Generate one video/animation based on the given parameters.
    """ # noqa: E501
    image: Optional[Any] = Field(description="Starting point image encoded in base64 string.")
    height: Optional[OutputVideoAnimationHeight] = None
    width: Optional[OutputVideoAnimationWidth] = None
    cfg_scale: Optional[Any] = Field(default=None, description="Floating-point number represeting how closely to adhere to 'image'. Must be a positive number no greater than 10.0.")
    steps: Optional[Any] = Field(default=None, description="Integer repreenting how many steps of diffusion to run. Must be greater than 0 and less than or equal to 50.")
    motion_scale: Optional[Any] = Field(default=None, description="A floating point number between 0.0 and 5.0 indicating how much motion should be in the generated video/animation.")
    noise_aug_strength: Optional[Any] = Field(default=None, description="A floating point number between 0.0 and 1.0 indicatiing how much noise to add to the initial image. Higher values encourage creativity.")
    num_videos: Optional[Any] = Field(default=None, description="Integer representing how many output videos/animations to generate with a single 'image' and configuration.")
    fps: Optional[Any] = Field(default=None, description="Integer representing how fast the generated frames should play back.")
    seed: Optional[FixedRandomSeed1] = None
    enable_safety: Optional[Any] = Field(default=None, description="Boolean defining whether to use safety checker system on generated outputs or not.")
    force_asset_download: Optional[Any] = Field(default=None, description="[Internal] Boolean defining if assets must be re-downloaded into the cache even if present.")
    force_asset_gpu_copy: Optional[Any] = Field(default=None, description="[Internal] Boolean defining if assets must to be copied into the GPU even if present.")
    additional_properties: Dict[str, Any] = {}
    __properties: ClassVar[List[str]] = ["image", "height", "width", "cfg_scale", "steps", "motion_scale", "noise_aug_strength", "num_videos", "fps", "seed", "enable_safety", "force_asset_download", "force_asset_gpu_copy"]

    model_config = {
        "populate_by_name": True,
        "validate_assignment": True,
        "protected_namespaces": (),
    }


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Self:
        """Create an instance of VideoGenerationRequest from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        * Fields in `self.additional_properties` are added to the output dict.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
                "additional_properties",
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of height
        if self.height:
            _dict['height'] = self.height.to_dict()
        # override the default output from pydantic by calling `to_dict()` of width
        if self.width:
            _dict['width'] = self.width.to_dict()
        # override the default output from pydantic by calling `to_dict()` of seed
        if self.seed:
            _dict['seed'] = self.seed.to_dict()
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

        # set to None if image (nullable) is None
        # and model_fields_set contains the field
        if self.image is None and "image" in self.model_fields_set:
            _dict['image'] = None

        # set to None if cfg_scale (nullable) is None
        # and model_fields_set contains the field
        if self.cfg_scale is None and "cfg_scale" in self.model_fields_set:
            _dict['cfg_scale'] = None

        # set to None if steps (nullable) is None
        # and model_fields_set contains the field
        if self.steps is None and "steps" in self.model_fields_set:
            _dict['steps'] = None

        # set to None if motion_scale (nullable) is None
        # and model_fields_set contains the field
        if self.motion_scale is None and "motion_scale" in self.model_fields_set:
            _dict['motion_scale'] = None

        # set to None if noise_aug_strength (nullable) is None
        # and model_fields_set contains the field
        if self.noise_aug_strength is None and "noise_aug_strength" in self.model_fields_set:
            _dict['noise_aug_strength'] = None

        # set to None if num_videos (nullable) is None
        # and model_fields_set contains the field
        if self.num_videos is None and "num_videos" in self.model_fields_set:
            _dict['num_videos'] = None

        # set to None if fps (nullable) is None
        # and model_fields_set contains the field
        if self.fps is None and "fps" in self.model_fields_set:
            _dict['fps'] = None

        # set to None if enable_safety (nullable) is None
        # and model_fields_set contains the field
        if self.enable_safety is None and "enable_safety" in self.model_fields_set:
            _dict['enable_safety'] = None

        # set to None if force_asset_download (nullable) is None
        # and model_fields_set contains the field
        if self.force_asset_download is None and "force_asset_download" in self.model_fields_set:
            _dict['force_asset_download'] = None

        # set to None if force_asset_gpu_copy (nullable) is None
        # and model_fields_set contains the field
        if self.force_asset_gpu_copy is None and "force_asset_gpu_copy" in self.model_fields_set:
            _dict['force_asset_gpu_copy'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of VideoGenerationRequest from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "image": obj.get("image"),
            "height": OutputVideoAnimationHeight.from_dict(obj.get("height")) if obj.get("height") is not None else None,
            "width": OutputVideoAnimationWidth.from_dict(obj.get("width")) if obj.get("width") is not None else None,
            "cfg_scale": obj.get("cfg_scale"),
            "steps": obj.get("steps"),
            "motion_scale": obj.get("motion_scale"),
            "noise_aug_strength": obj.get("noise_aug_strength"),
            "num_videos": obj.get("num_videos"),
            "fps": obj.get("fps"),
            "seed": FixedRandomSeed1.from_dict(obj.get("seed")) if obj.get("seed") is not None else None,
            "enable_safety": obj.get("enable_safety"),
            "force_asset_download": obj.get("force_asset_download"),
            "force_asset_gpu_copy": obj.get("force_asset_gpu_copy")
        })
        # store additional fields in additional_properties
        for _key in obj.keys():
            if _key not in cls.__properties:
                _obj.additional_properties[_key] = obj.get(_key)

        return _obj


