# 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 json
import pprint
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
from typing import Any, List, Optional
from civitai_py.models.clear_asset_request import ClearAssetRequest
from civitai_py.models.comfy_job_request import ComfyJobRequest
from civitai_py.models.copy_asset_request import CopyAssetRequest
from civitai_py.models.delete_blob_request import DeleteBlobRequest
from civitai_py.models.get_blob_request import GetBlobRequest
from civitai_py.models.image_embedding_job_request import ImageEmbeddingJobRequest
from civitai_py.models.image_resource_training_job_request import ImageResourceTrainingJobRequest
from civitai_py.models.image_transform_job_request import ImageTransformJobRequest
from civitai_py.models.media_tagging_job_request import MediaTaggingJobRequest
from civitai_py.models.pin_blob_request import PinBlobRequest
from civitai_py.models.prepare_model_job_request import PrepareModelJobRequest
from civitai_py.models.reboot_worker_job_request import RebootWorkerJobRequest
from civitai_py.models.text_to_image_job_request import TextToImageJobRequest
from civitai_py.models.unpin_blob_request import UnpinBlobRequest
from civitai_py.models.upload_blob_request import UploadBlobRequest
from civitai_py.models.wd_tagging_job_request import WDTaggingJobRequest
from pydantic import StrictStr, Field
from typing import Union, List, Set, Optional, Dict
from typing_extensions import Literal, Self

JOBTEMPLATELISTJOBSINNER_ONE_OF_SCHEMAS = ["ClearAssetRequest", "ComfyJobRequest", "CopyAssetRequest", "DeleteBlobRequest", "GetBlobRequest", "ImageEmbeddingJobRequest", "ImageResourceTrainingJobRequest",
                                           "ImageTransformJobRequest", "MediaTaggingJobRequest", "PinBlobRequest", "PrepareModelJobRequest", "RebootWorkerJobRequest", "TextToImageJobRequest", "UnpinBlobRequest", "UploadBlobRequest", "WDTaggingJobRequest"]


class JobTemplateListJobsInner(BaseModel):
    """
    JobTemplateListJobsInner
    """
    # data type: TextToImageJobRequest
    oneof_schema_1_validator: Optional[TextToImageJobRequest] = None
    # data type: ImageResourceTrainingJobRequest
    oneof_schema_2_validator: Optional[ImageResourceTrainingJobRequest] = None
    # data type: UploadBlobRequest
    oneof_schema_3_validator: Optional[UploadBlobRequest] = None
    # data type: GetBlobRequest
    oneof_schema_4_validator: Optional[GetBlobRequest] = None
    # data type: PinBlobRequest
    oneof_schema_5_validator: Optional[PinBlobRequest] = None
    # data type: UnpinBlobRequest
    oneof_schema_6_validator: Optional[UnpinBlobRequest] = None
    # data type: DeleteBlobRequest
    oneof_schema_7_validator: Optional[DeleteBlobRequest] = None
    # data type: ImageTransformJobRequest
    oneof_schema_8_validator: Optional[ImageTransformJobRequest] = None
    # data type: CopyAssetRequest
    oneof_schema_9_validator: Optional[CopyAssetRequest] = None
    # data type: ClearAssetRequest
    oneof_schema_10_validator: Optional[ClearAssetRequest] = None
    # data type: WDTaggingJobRequest
    oneof_schema_11_validator: Optional[WDTaggingJobRequest] = None
    # data type: MediaTaggingJobRequest
    oneof_schema_12_validator: Optional[MediaTaggingJobRequest] = None
    # data type: PrepareModelJobRequest
    oneof_schema_13_validator: Optional[PrepareModelJobRequest] = None
    # data type: ComfyJobRequest
    oneof_schema_14_validator: Optional[ComfyJobRequest] = None
    # data type: ImageEmbeddingJobRequest
    oneof_schema_15_validator: Optional[ImageEmbeddingJobRequest] = None
    # data type: RebootWorkerJobRequest
    oneof_schema_16_validator: Optional[RebootWorkerJobRequest] = None
    actual_instance: Optional[Union[ClearAssetRequest, ComfyJobRequest, CopyAssetRequest, DeleteBlobRequest, GetBlobRequest, ImageEmbeddingJobRequest, ImageResourceTrainingJobRequest,
                                    ImageTransformJobRequest, MediaTaggingJobRequest, PinBlobRequest, PrepareModelJobRequest, RebootWorkerJobRequest, TextToImageJobRequest, UnpinBlobRequest, UploadBlobRequest, WDTaggingJobRequest]] = None
    one_of_schemas: Set[str] = {"ClearAssetRequest", "ComfyJobRequest", "CopyAssetRequest", "DeleteBlobRequest", "GetBlobRequest", "ImageEmbeddingJobRequest", "ImageResourceTrainingJobRequest",
                                "ImageTransformJobRequest", "MediaTaggingJobRequest", "PinBlobRequest", "PrepareModelJobRequest", "RebootWorkerJobRequest", "TextToImageJobRequest", "UnpinBlobRequest", "UploadBlobRequest", "WDTaggingJobRequest"}

    model_config = ConfigDict(
        validate_assignment=True,
        protected_namespaces=(),
    )

    discriminator_value_class_map: Dict[str, str] = {
    }

    def __init__(self, *args, **kwargs) -> None:
        if args:
            if len(args) > 1:
                raise ValueError(
                    "If a position argument is used, only 1 is allowed to set `actual_instance`")
            if kwargs:
                raise ValueError(
                    "If a position argument is used, keyword arguments cannot be used.")
            super().__init__(actual_instance=args[0])
        else:
            super().__init__(**kwargs)

    @field_validator('actual_instance')
    def actual_instance_must_validate_oneof(cls, v):
        instance = JobTemplateListJobsInner.model_construct()
        error_messages = []
        match = 0
        # validate data type: TextToImageJobRequest
        if not isinstance(v, TextToImageJobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `TextToImageJobRequest`")
        else:
            match += 1
        # validate data type: ImageResourceTrainingJobRequest
        if not isinstance(v, ImageResourceTrainingJobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ImageResourceTrainingJobRequest`")
        else:
            match += 1
        # validate data type: UploadBlobRequest
        if not isinstance(v, UploadBlobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `UploadBlobRequest`")
        else:
            match += 1
        # validate data type: GetBlobRequest
        if not isinstance(v, GetBlobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlobRequest`")
        else:
            match += 1
        # validate data type: PinBlobRequest
        if not isinstance(v, PinBlobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `PinBlobRequest`")
        else:
            match += 1
        # validate data type: UnpinBlobRequest
        if not isinstance(v, UnpinBlobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `UnpinBlobRequest`")
        else:
            match += 1
        # validate data type: DeleteBlobRequest
        if not isinstance(v, DeleteBlobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `DeleteBlobRequest`")
        else:
            match += 1
        # validate data type: ImageTransformJobRequest
        if not isinstance(v, ImageTransformJobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ImageTransformJobRequest`")
        else:
            match += 1
        # validate data type: CopyAssetRequest
        if not isinstance(v, CopyAssetRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `CopyAssetRequest`")
        else:
            match += 1
        # validate data type: ClearAssetRequest
        if not isinstance(v, ClearAssetRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ClearAssetRequest`")
        else:
            match += 1
        # validate data type: WDTaggingJobRequest
        if not isinstance(v, WDTaggingJobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WDTaggingJobRequest`")
        else:
            match += 1
        # validate data type: MediaTaggingJobRequest
        if not isinstance(v, MediaTaggingJobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `MediaTaggingJobRequest`")
        else:
            match += 1
        # validate data type: PrepareModelJobRequest
        if not isinstance(v, PrepareModelJobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `PrepareModelJobRequest`")
        else:
            match += 1
        # validate data type: ComfyJobRequest
        if not isinstance(v, ComfyJobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ComfyJobRequest`")
        else:
            match += 1
        # validate data type: ImageEmbeddingJobRequest
        if not isinstance(v, ImageEmbeddingJobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ImageEmbeddingJobRequest`")
        else:
            match += 1
        # validate data type: RebootWorkerJobRequest
        if not isinstance(v, RebootWorkerJobRequest):
            error_messages.append(f"Error! Input type `{type(v)}` is not `RebootWorkerJobRequest`")
        else:
            match += 1
        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when setting `actual_instance` in JobTemplateListJobsInner with oneOf schemas: ClearAssetRequest, ComfyJobRequest, CopyAssetRequest, DeleteBlobRequest, GetBlobRequest, ImageEmbeddingJobRequest, ImageResourceTrainingJobRequest, ImageTransformJobRequest, MediaTaggingJobRequest, PinBlobRequest, PrepareModelJobRequest, RebootWorkerJobRequest, TextToImageJobRequest, UnpinBlobRequest, UploadBlobRequest, WDTaggingJobRequest. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when setting `actual_instance` in JobTemplateListJobsInner with oneOf schemas: ClearAssetRequest, ComfyJobRequest, CopyAssetRequest, DeleteBlobRequest, GetBlobRequest, ImageEmbeddingJobRequest, ImageResourceTrainingJobRequest, ImageTransformJobRequest, MediaTaggingJobRequest, PinBlobRequest, PrepareModelJobRequest, RebootWorkerJobRequest, TextToImageJobRequest, UnpinBlobRequest, UploadBlobRequest, WDTaggingJobRequest. Details: " + ", ".join(error_messages))
        else:
            return v

    @classmethod
    def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
        return cls.from_json(json.dumps(obj))

    @classmethod
    def from_json(cls, json_str: str) -> Self:
        """Returns the object represented by the json string"""
        instance = cls.model_construct()
        error_messages = []
        match = 0

        # deserialize data into TextToImageJobRequest
        try:
            instance.actual_instance = TextToImageJobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ImageResourceTrainingJobRequest
        try:
            instance.actual_instance = ImageResourceTrainingJobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into UploadBlobRequest
        try:
            instance.actual_instance = UploadBlobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlobRequest
        try:
            instance.actual_instance = GetBlobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into PinBlobRequest
        try:
            instance.actual_instance = PinBlobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into UnpinBlobRequest
        try:
            instance.actual_instance = UnpinBlobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into DeleteBlobRequest
        try:
            instance.actual_instance = DeleteBlobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ImageTransformJobRequest
        try:
            instance.actual_instance = ImageTransformJobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into CopyAssetRequest
        try:
            instance.actual_instance = CopyAssetRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ClearAssetRequest
        try:
            instance.actual_instance = ClearAssetRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WDTaggingJobRequest
        try:
            instance.actual_instance = WDTaggingJobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into MediaTaggingJobRequest
        try:
            instance.actual_instance = MediaTaggingJobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into PrepareModelJobRequest
        try:
            instance.actual_instance = PrepareModelJobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ComfyJobRequest
        try:
            instance.actual_instance = ComfyJobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ImageEmbeddingJobRequest
        try:
            instance.actual_instance = ImageEmbeddingJobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into RebootWorkerJobRequest
        try:
            instance.actual_instance = RebootWorkerJobRequest.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))

        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when deserializing the JSON string into JobTemplateListJobsInner with oneOf schemas: ClearAssetRequest, ComfyJobRequest, CopyAssetRequest, DeleteBlobRequest, GetBlobRequest, ImageEmbeddingJobRequest, ImageResourceTrainingJobRequest, ImageTransformJobRequest, MediaTaggingJobRequest, PinBlobRequest, PrepareModelJobRequest, RebootWorkerJobRequest, TextToImageJobRequest, UnpinBlobRequest, UploadBlobRequest, WDTaggingJobRequest. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when deserializing the JSON string into JobTemplateListJobsInner with oneOf schemas: ClearAssetRequest, ComfyJobRequest, CopyAssetRequest, DeleteBlobRequest, GetBlobRequest, ImageEmbeddingJobRequest, ImageResourceTrainingJobRequest, ImageTransformJobRequest, MediaTaggingJobRequest, PinBlobRequest, PrepareModelJobRequest, RebootWorkerJobRequest, TextToImageJobRequest, UnpinBlobRequest, UploadBlobRequest, WDTaggingJobRequest. Details: " + ", ".join(error_messages))
        else:
            return instance

    def to_json(self) -> str:
        """Returns the JSON representation of the actual instance"""
        if self.actual_instance is None:
            return "null"

        if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
            return self.actual_instance.to_json()
        else:
            return json.dumps(self.actual_instance)

    def to_dict(self) -> Optional[Union[Dict[str, Any], ClearAssetRequest, ComfyJobRequest, CopyAssetRequest, DeleteBlobRequest, GetBlobRequest, ImageEmbeddingJobRequest, ImageResourceTrainingJobRequest, ImageTransformJobRequest, MediaTaggingJobRequest, PinBlobRequest, PrepareModelJobRequest, RebootWorkerJobRequest, TextToImageJobRequest, UnpinBlobRequest, UploadBlobRequest, WDTaggingJobRequest]]:
        """Returns the dict representation of the actual instance"""
        if self.actual_instance is None:
            return None

        if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
            return self.actual_instance.to_dict()
        else:
            # primitive type
            return self.actual_instance

    def to_str(self) -> str:
        """Returns the string representation of the actual instance"""
        return pprint.pformat(self.model_dump())
