# coding: utf-8

"""
    Civitai Orchestration Consumer API

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

    The version of the OpenAPI document: v1
    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 pydantic import ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from civitai_py.models.job_request import JobRequest
from civitai_py.models.job_request_priority import JobRequestPriority
from civitai_py.models.provider import Provider
from civitai_py.models.time_span import TimeSpan
from typing import Optional, Set
from typing_extensions import Self


class ImageEmbeddingJobRequest(JobRequest):
    """
    ImageEmbeddingJobRequest
    """  # noqa: E501
    image_url: Optional[StrictStr] = Field(
        default=None, description="The url of the image to get embeddings for", alias="imageUrl")
    __properties: ClassVar[List[str]] = ["$type", "name", "priority", "providers",
                                         "expireAt", "properties", "callbackUrl", "timeout", "retries", "dependencies"]

    model_config = ConfigDict(
        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) -> Optional[Self]:
        """Create an instance of ImageEmbeddingJobRequest 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.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of priority
        if self.priority:
            _dict['priority'] = self.priority.to_dict()
        # override the default output from pydantic by calling `to_dict()` of timeout
        if self.timeout:
            _dict['timeout'] = self.timeout.to_dict()
        # set to None if name (nullable) is None
        # and model_fields_set contains the field
        if self.name is None and "name" in self.model_fields_set:
            _dict['name'] = None

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

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

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ImageEmbeddingJobRequest from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "$type": obj.get("$type"),
            "name": obj.get("name"),
            "priority": JobRequestPriority.from_dict(obj["priority"]) if obj.get("priority") is not None else None,
            "providers": obj.get("providers"),
            "expireAt": obj.get("expireAt"),
            "properties": obj.get("properties"),
            "callbackUrl": obj.get("callbackUrl"),
            "timeout": TimeSpan.from_dict(obj["timeout"]) if obj.get("timeout") is not None else None,
            "retries": obj.get("retries"),
            "dependencies": obj.get("dependencies")
        })
        return _obj
