# coding: utf-8

"""
    Rapidata Asset API

    The API for the Rapidata Asset service

    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 rapidata.api_client.models.i_validation_truth_attach_category_truth import IValidationTruthAttachCategoryTruth
from rapidata.api_client.models.i_validation_truth_bounding_box_truth import IValidationTruthBoundingBoxTruth
from rapidata.api_client.models.i_validation_truth_compare_truth import IValidationTruthCompareTruth
from rapidata.api_client.models.i_validation_truth_empty_validation_truth import IValidationTruthEmptyValidationTruth
from rapidata.api_client.models.i_validation_truth_line_truth import IValidationTruthLineTruth
from rapidata.api_client.models.i_validation_truth_locate_box_truth import IValidationTruthLocateBoxTruth
from rapidata.api_client.models.i_validation_truth_multi_compare_truth import IValidationTruthMultiCompareTruth
from rapidata.api_client.models.i_validation_truth_named_entity_truth import IValidationTruthNamedEntityTruth
from rapidata.api_client.models.i_validation_truth_polygon_truth import IValidationTruthPolygonTruth
from rapidata.api_client.models.i_validation_truth_scrub_truth import IValidationTruthScrubTruth
from rapidata.api_client.models.i_validation_truth_skip_truth import IValidationTruthSkipTruth
from rapidata.api_client.models.i_validation_truth_transcription_truth import IValidationTruthTranscriptionTruth
from pydantic import StrictStr, Field
from typing import Union, List, Set, Optional, Dict
from typing_extensions import Literal, Self

IVALIDATIONTRUTH_ONE_OF_SCHEMAS = ["IValidationTruthAttachCategoryTruth", "IValidationTruthBoundingBoxTruth", "IValidationTruthCompareTruth", "IValidationTruthEmptyValidationTruth", "IValidationTruthLineTruth", "IValidationTruthLocateBoxTruth", "IValidationTruthMultiCompareTruth", "IValidationTruthNamedEntityTruth", "IValidationTruthPolygonTruth", "IValidationTruthScrubTruth", "IValidationTruthSkipTruth", "IValidationTruthTranscriptionTruth"]

class IValidationTruth(BaseModel):
    """
    IValidationTruth
    """
    # data type: IValidationTruthTranscriptionTruth
    oneof_schema_1_validator: Optional[IValidationTruthTranscriptionTruth] = None
    # data type: IValidationTruthScrubTruth
    oneof_schema_2_validator: Optional[IValidationTruthScrubTruth] = None
    # data type: IValidationTruthPolygonTruth
    oneof_schema_3_validator: Optional[IValidationTruthPolygonTruth] = None
    # data type: IValidationTruthNamedEntityTruth
    oneof_schema_4_validator: Optional[IValidationTruthNamedEntityTruth] = None
    # data type: IValidationTruthLocateBoxTruth
    oneof_schema_5_validator: Optional[IValidationTruthLocateBoxTruth] = None
    # data type: IValidationTruthLineTruth
    oneof_schema_6_validator: Optional[IValidationTruthLineTruth] = None
    # data type: IValidationTruthEmptyValidationTruth
    oneof_schema_7_validator: Optional[IValidationTruthEmptyValidationTruth] = None
    # data type: IValidationTruthCompareTruth
    oneof_schema_8_validator: Optional[IValidationTruthCompareTruth] = None
    # data type: IValidationTruthMultiCompareTruth
    oneof_schema_9_validator: Optional[IValidationTruthMultiCompareTruth] = None
    # data type: IValidationTruthSkipTruth
    oneof_schema_10_validator: Optional[IValidationTruthSkipTruth] = None
    # data type: IValidationTruthAttachCategoryTruth
    oneof_schema_11_validator: Optional[IValidationTruthAttachCategoryTruth] = None
    # data type: IValidationTruthBoundingBoxTruth
    oneof_schema_12_validator: Optional[IValidationTruthBoundingBoxTruth] = None
    actual_instance: Optional[Union[IValidationTruthAttachCategoryTruth, IValidationTruthBoundingBoxTruth, IValidationTruthCompareTruth, IValidationTruthEmptyValidationTruth, IValidationTruthLineTruth, IValidationTruthLocateBoxTruth, IValidationTruthMultiCompareTruth, IValidationTruthNamedEntityTruth, IValidationTruthPolygonTruth, IValidationTruthScrubTruth, IValidationTruthSkipTruth, IValidationTruthTranscriptionTruth]] = None
    one_of_schemas: Set[str] = { "IValidationTruthAttachCategoryTruth", "IValidationTruthBoundingBoxTruth", "IValidationTruthCompareTruth", "IValidationTruthEmptyValidationTruth", "IValidationTruthLineTruth", "IValidationTruthLocateBoxTruth", "IValidationTruthMultiCompareTruth", "IValidationTruthNamedEntityTruth", "IValidationTruthPolygonTruth", "IValidationTruthScrubTruth", "IValidationTruthSkipTruth", "IValidationTruthTranscriptionTruth" }

    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 = IValidationTruth.model_construct()
        error_messages = []
        match = 0
        # validate data type: IValidationTruthTranscriptionTruth
        if not isinstance(v, IValidationTruthTranscriptionTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthTranscriptionTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthScrubTruth
        if not isinstance(v, IValidationTruthScrubTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthScrubTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthPolygonTruth
        if not isinstance(v, IValidationTruthPolygonTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthPolygonTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthNamedEntityTruth
        if not isinstance(v, IValidationTruthNamedEntityTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthNamedEntityTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthLocateBoxTruth
        if not isinstance(v, IValidationTruthLocateBoxTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthLocateBoxTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthLineTruth
        if not isinstance(v, IValidationTruthLineTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthLineTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthEmptyValidationTruth
        if not isinstance(v, IValidationTruthEmptyValidationTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthEmptyValidationTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthCompareTruth
        if not isinstance(v, IValidationTruthCompareTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthCompareTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthMultiCompareTruth
        if not isinstance(v, IValidationTruthMultiCompareTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthMultiCompareTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthSkipTruth
        if not isinstance(v, IValidationTruthSkipTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthSkipTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthAttachCategoryTruth
        if not isinstance(v, IValidationTruthAttachCategoryTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthAttachCategoryTruth`")
        else:
            match += 1
        # validate data type: IValidationTruthBoundingBoxTruth
        if not isinstance(v, IValidationTruthBoundingBoxTruth):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthBoundingBoxTruth`")
        else:
            match += 1
        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when setting `actual_instance` in IValidationTruth with oneOf schemas: IValidationTruthAttachCategoryTruth, IValidationTruthBoundingBoxTruth, IValidationTruthCompareTruth, IValidationTruthEmptyValidationTruth, IValidationTruthLineTruth, IValidationTruthLocateBoxTruth, IValidationTruthMultiCompareTruth, IValidationTruthNamedEntityTruth, IValidationTruthPolygonTruth, IValidationTruthScrubTruth, IValidationTruthSkipTruth, IValidationTruthTranscriptionTruth. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when setting `actual_instance` in IValidationTruth with oneOf schemas: IValidationTruthAttachCategoryTruth, IValidationTruthBoundingBoxTruth, IValidationTruthCompareTruth, IValidationTruthEmptyValidationTruth, IValidationTruthLineTruth, IValidationTruthLocateBoxTruth, IValidationTruthMultiCompareTruth, IValidationTruthNamedEntityTruth, IValidationTruthPolygonTruth, IValidationTruthScrubTruth, IValidationTruthSkipTruth, IValidationTruthTranscriptionTruth. 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 IValidationTruthTranscriptionTruth
        try:
            instance.actual_instance = IValidationTruthTranscriptionTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthScrubTruth
        try:
            instance.actual_instance = IValidationTruthScrubTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthPolygonTruth
        try:
            instance.actual_instance = IValidationTruthPolygonTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthNamedEntityTruth
        try:
            instance.actual_instance = IValidationTruthNamedEntityTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthLocateBoxTruth
        try:
            instance.actual_instance = IValidationTruthLocateBoxTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthLineTruth
        try:
            instance.actual_instance = IValidationTruthLineTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthEmptyValidationTruth
        try:
            instance.actual_instance = IValidationTruthEmptyValidationTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthCompareTruth
        try:
            instance.actual_instance = IValidationTruthCompareTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthMultiCompareTruth
        try:
            instance.actual_instance = IValidationTruthMultiCompareTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthSkipTruth
        try:
            instance.actual_instance = IValidationTruthSkipTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthAttachCategoryTruth
        try:
            instance.actual_instance = IValidationTruthAttachCategoryTruth.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthBoundingBoxTruth
        try:
            instance.actual_instance = IValidationTruthBoundingBoxTruth.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 IValidationTruth with oneOf schemas: IValidationTruthAttachCategoryTruth, IValidationTruthBoundingBoxTruth, IValidationTruthCompareTruth, IValidationTruthEmptyValidationTruth, IValidationTruthLineTruth, IValidationTruthLocateBoxTruth, IValidationTruthMultiCompareTruth, IValidationTruthNamedEntityTruth, IValidationTruthPolygonTruth, IValidationTruthScrubTruth, IValidationTruthSkipTruth, IValidationTruthTranscriptionTruth. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when deserializing the JSON string into IValidationTruth with oneOf schemas: IValidationTruthAttachCategoryTruth, IValidationTruthBoundingBoxTruth, IValidationTruthCompareTruth, IValidationTruthEmptyValidationTruth, IValidationTruthLineTruth, IValidationTruthLocateBoxTruth, IValidationTruthMultiCompareTruth, IValidationTruthNamedEntityTruth, IValidationTruthPolygonTruth, IValidationTruthScrubTruth, IValidationTruthSkipTruth, IValidationTruthTranscriptionTruth. 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], IValidationTruthAttachCategoryTruth, IValidationTruthBoundingBoxTruth, IValidationTruthCompareTruth, IValidationTruthEmptyValidationTruth, IValidationTruthLineTruth, IValidationTruthLocateBoxTruth, IValidationTruthMultiCompareTruth, IValidationTruthNamedEntityTruth, IValidationTruthPolygonTruth, IValidationTruthScrubTruth, IValidationTruthSkipTruth, IValidationTruthTranscriptionTruth]]:
        """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())


