# 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.image_in_base64 import ImageInBase64
from clients.image_gen.models.safety_score import SafetyScore
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class ImageGeneration(BaseModel):
    """
    Represent a generated image.
    """ # noqa: E501
    image_b64: ImageInBase64
    removed_for_safety: Optional[Any] = Field(description="True if the image was removed for safety, False otherwise.")
    seed: Optional[Any] = Field(description="Seed used to generate the image. It can be used to recreate the generation.")
    safety_score: SafetyScore
    __properties: ClassVar[List[str]] = ["image_b64", "removed_for_safety", "seed", "safety_score"]

    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 ImageGeneration 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.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of image_b64
        if self.image_b64:
            _dict['image_b64'] = self.image_b64.to_dict()
        # override the default output from pydantic by calling `to_dict()` of safety_score
        if self.safety_score:
            _dict['safety_score'] = self.safety_score.to_dict()
        # set to None if removed_for_safety (nullable) is None
        # and model_fields_set contains the field
        if self.removed_for_safety is None and "removed_for_safety" in self.model_fields_set:
            _dict['removed_for_safety'] = None

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

        return _dict

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

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

        _obj = cls.model_validate({
            "image_b64": ImageInBase64.from_dict(obj.get("image_b64")) if obj.get("image_b64") is not None else None,
            "removed_for_safety": obj.get("removed_for_safety"),
            "seed": obj.get("seed"),
            "safety_score": SafetyScore.from_dict(obj.get("safety_score")) if obj.get("safety_score") is not None else None
        })
        return _obj


