# 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, Optional, Union
from pydantic.v1 import BaseModel, Field, StrictBool, StrictFloat, StrictInt, StrictStr

class LegacyImageGenerationRequest(BaseModel):
    """
    Model input data type.  # noqa: E501
    """
    prompt: StrictStr = Field(...)
    prompt_2: Optional[StrictStr] = None
    negative_prompt: Optional[StrictStr] = None
    negative_prompt_2: Optional[StrictStr] = None
    model: Optional[StrictStr] = None
    loras: Optional[Any] = None
    sampler: Optional[StrictStr] = 'DDIM'
    height: Optional[StrictInt] = 1024
    width: Optional[StrictInt] = 1024
    cfg_scale: Optional[Union[StrictFloat, StrictInt]] = 12.0
    steps: Optional[StrictInt] = 30
    num_images: Optional[StrictInt] = 1
    seed: Optional[StrictInt] = None
    init_image: Optional[StrictStr] = None
    strength: Optional[Union[StrictFloat, StrictInt]] = 0.8
    style_preset: Optional[StrictStr] = None
    use_refiner: Optional[StrictBool] = True
    high_noise_frac: Optional[Union[StrictFloat, StrictInt]] = 0.8
    enable_safety: Optional[StrictBool] = False
    output_type: Optional[StrictStr] = 'jpg'
    __properties = ["prompt", "prompt_2", "negative_prompt", "negative_prompt_2", "model", "loras", "sampler", "height", "width", "cfg_scale", "steps", "num_images", "seed", "init_image", "strength", "style_preset", "use_refiner", "high_noise_frac", "enable_safety", "output_type"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

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

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of loras
        if self.loras:
            _dict['loras'] = self.loras.to_dict()
        # set to None if prompt_2 (nullable) is None
        # and __fields_set__ contains the field
        if self.prompt_2 is None and "prompt_2" in self.__fields_set__:
            _dict['prompt_2'] = None

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

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

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

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

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

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

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

        return _dict

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

        if not isinstance(obj, dict):
            return LegacyImageGenerationRequest.parse_obj(obj)

        _obj = LegacyImageGenerationRequest.parse_obj({
            "prompt": obj.get("prompt"),
            "prompt_2": obj.get("prompt_2"),
            "negative_prompt": obj.get("negative_prompt"),
            "negative_prompt_2": obj.get("negative_prompt_2"),
            "model": obj.get("model"),
            "loras": AnyOf.from_dict(obj.get("loras")) if obj.get("loras") is not None else None,
            "sampler": obj.get("sampler") if obj.get("sampler") is not None else 'DDIM',
            "height": obj.get("height") if obj.get("height") is not None else 1024,
            "width": obj.get("width") if obj.get("width") is not None else 1024,
            "cfg_scale": obj.get("cfg_scale") if obj.get("cfg_scale") is not None else 12.0,
            "steps": obj.get("steps") if obj.get("steps") is not None else 30,
            "num_images": obj.get("num_images") if obj.get("num_images") is not None else 1,
            "seed": obj.get("seed"),
            "init_image": obj.get("init_image"),
            "strength": obj.get("strength") if obj.get("strength") is not None else 0.8,
            "style_preset": obj.get("style_preset"),
            "use_refiner": obj.get("use_refiner") if obj.get("use_refiner") is not None else True,
            "high_noise_frac": obj.get("high_noise_frac") if obj.get("high_noise_frac") is not None else 0.8,
            "enable_safety": obj.get("enable_safety") if obj.get("enable_safety") is not None else False,
            "output_type": obj.get("output_type") if obj.get("output_type") is not None else 'jpg'
        })
        return _obj


