# 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_model_attach_category_truth_model import IValidationTruthModelAttachCategoryTruthModel
from rapidata.api_client.models.i_validation_truth_model_bounding_box_truth_model import IValidationTruthModelBoundingBoxTruthModel
from rapidata.api_client.models.i_validation_truth_model_classify_truth_model import IValidationTruthModelClassifyTruthModel
from rapidata.api_client.models.i_validation_truth_model_compare_truth_model import IValidationTruthModelCompareTruthModel
from rapidata.api_client.models.i_validation_truth_model_empty_validation_truth_model import IValidationTruthModelEmptyValidationTruthModel
from rapidata.api_client.models.i_validation_truth_model_line_truth_model import IValidationTruthModelLineTruthModel
from rapidata.api_client.models.i_validation_truth_model_locate_box_truth_model import IValidationTruthModelLocateBoxTruthModel
from rapidata.api_client.models.i_validation_truth_model_multi_compare_truth_model import IValidationTruthModelMultiCompareTruthModel
from rapidata.api_client.models.i_validation_truth_model_named_entity_truth_model import IValidationTruthModelNamedEntityTruthModel
from rapidata.api_client.models.i_validation_truth_model_polygon_truth_model import IValidationTruthModelPolygonTruthModel
from rapidata.api_client.models.i_validation_truth_model_scrub_truth_model import IValidationTruthModelScrubTruthModel
from rapidata.api_client.models.i_validation_truth_model_skip_truth_model import IValidationTruthModelSkipTruthModel
from rapidata.api_client.models.i_validation_truth_model_transcription_truth_model import IValidationTruthModelTranscriptionTruthModel
from pydantic import StrictStr, Field
from typing import Union, List, Set, Optional, Dict
from typing_extensions import Literal, Self

IVALIDATIONTRUTHMODEL_ONE_OF_SCHEMAS = ["IValidationTruthModelAttachCategoryTruthModel", "IValidationTruthModelBoundingBoxTruthModel", "IValidationTruthModelClassifyTruthModel", "IValidationTruthModelCompareTruthModel", "IValidationTruthModelEmptyValidationTruthModel", "IValidationTruthModelLineTruthModel", "IValidationTruthModelLocateBoxTruthModel", "IValidationTruthModelMultiCompareTruthModel", "IValidationTruthModelNamedEntityTruthModel", "IValidationTruthModelPolygonTruthModel", "IValidationTruthModelScrubTruthModel", "IValidationTruthModelSkipTruthModel", "IValidationTruthModelTranscriptionTruthModel"]

class IValidationTruthModel(BaseModel):
    """
    IValidationTruthModel
    """
    # data type: IValidationTruthModelAttachCategoryTruthModel
    oneof_schema_1_validator: Optional[IValidationTruthModelAttachCategoryTruthModel] = None
    # data type: IValidationTruthModelBoundingBoxTruthModel
    oneof_schema_2_validator: Optional[IValidationTruthModelBoundingBoxTruthModel] = None
    # data type: IValidationTruthModelClassifyTruthModel
    oneof_schema_3_validator: Optional[IValidationTruthModelClassifyTruthModel] = None
    # data type: IValidationTruthModelCompareTruthModel
    oneof_schema_4_validator: Optional[IValidationTruthModelCompareTruthModel] = None
    # data type: IValidationTruthModelEmptyValidationTruthModel
    oneof_schema_5_validator: Optional[IValidationTruthModelEmptyValidationTruthModel] = None
    # data type: IValidationTruthModelLineTruthModel
    oneof_schema_6_validator: Optional[IValidationTruthModelLineTruthModel] = None
    # data type: IValidationTruthModelLocateBoxTruthModel
    oneof_schema_7_validator: Optional[IValidationTruthModelLocateBoxTruthModel] = None
    # data type: IValidationTruthModelMultiCompareTruthModel
    oneof_schema_8_validator: Optional[IValidationTruthModelMultiCompareTruthModel] = None
    # data type: IValidationTruthModelNamedEntityTruthModel
    oneof_schema_9_validator: Optional[IValidationTruthModelNamedEntityTruthModel] = None
    # data type: IValidationTruthModelPolygonTruthModel
    oneof_schema_10_validator: Optional[IValidationTruthModelPolygonTruthModel] = None
    # data type: IValidationTruthModelScrubTruthModel
    oneof_schema_11_validator: Optional[IValidationTruthModelScrubTruthModel] = None
    # data type: IValidationTruthModelSkipTruthModel
    oneof_schema_12_validator: Optional[IValidationTruthModelSkipTruthModel] = None
    # data type: IValidationTruthModelTranscriptionTruthModel
    oneof_schema_13_validator: Optional[IValidationTruthModelTranscriptionTruthModel] = None
    actual_instance: Optional[Union[IValidationTruthModelAttachCategoryTruthModel, IValidationTruthModelBoundingBoxTruthModel, IValidationTruthModelClassifyTruthModel, IValidationTruthModelCompareTruthModel, IValidationTruthModelEmptyValidationTruthModel, IValidationTruthModelLineTruthModel, IValidationTruthModelLocateBoxTruthModel, IValidationTruthModelMultiCompareTruthModel, IValidationTruthModelNamedEntityTruthModel, IValidationTruthModelPolygonTruthModel, IValidationTruthModelScrubTruthModel, IValidationTruthModelSkipTruthModel, IValidationTruthModelTranscriptionTruthModel]] = None
    one_of_schemas: Set[str] = { "IValidationTruthModelAttachCategoryTruthModel", "IValidationTruthModelBoundingBoxTruthModel", "IValidationTruthModelClassifyTruthModel", "IValidationTruthModelCompareTruthModel", "IValidationTruthModelEmptyValidationTruthModel", "IValidationTruthModelLineTruthModel", "IValidationTruthModelLocateBoxTruthModel", "IValidationTruthModelMultiCompareTruthModel", "IValidationTruthModelNamedEntityTruthModel", "IValidationTruthModelPolygonTruthModel", "IValidationTruthModelScrubTruthModel", "IValidationTruthModelSkipTruthModel", "IValidationTruthModelTranscriptionTruthModel" }

    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 = IValidationTruthModel.model_construct()
        error_messages = []
        match = 0
        # validate data type: IValidationTruthModelAttachCategoryTruthModel
        if not isinstance(v, IValidationTruthModelAttachCategoryTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelAttachCategoryTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelBoundingBoxTruthModel
        if not isinstance(v, IValidationTruthModelBoundingBoxTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelBoundingBoxTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelClassifyTruthModel
        if not isinstance(v, IValidationTruthModelClassifyTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelClassifyTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelCompareTruthModel
        if not isinstance(v, IValidationTruthModelCompareTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelCompareTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelEmptyValidationTruthModel
        if not isinstance(v, IValidationTruthModelEmptyValidationTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelEmptyValidationTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelLineTruthModel
        if not isinstance(v, IValidationTruthModelLineTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelLineTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelLocateBoxTruthModel
        if not isinstance(v, IValidationTruthModelLocateBoxTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelLocateBoxTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelMultiCompareTruthModel
        if not isinstance(v, IValidationTruthModelMultiCompareTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelMultiCompareTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelNamedEntityTruthModel
        if not isinstance(v, IValidationTruthModelNamedEntityTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelNamedEntityTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelPolygonTruthModel
        if not isinstance(v, IValidationTruthModelPolygonTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelPolygonTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelScrubTruthModel
        if not isinstance(v, IValidationTruthModelScrubTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelScrubTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelSkipTruthModel
        if not isinstance(v, IValidationTruthModelSkipTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelSkipTruthModel`")
        else:
            match += 1
        # validate data type: IValidationTruthModelTranscriptionTruthModel
        if not isinstance(v, IValidationTruthModelTranscriptionTruthModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `IValidationTruthModelTranscriptionTruthModel`")
        else:
            match += 1
        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when setting `actual_instance` in IValidationTruthModel with oneOf schemas: IValidationTruthModelAttachCategoryTruthModel, IValidationTruthModelBoundingBoxTruthModel, IValidationTruthModelClassifyTruthModel, IValidationTruthModelCompareTruthModel, IValidationTruthModelEmptyValidationTruthModel, IValidationTruthModelLineTruthModel, IValidationTruthModelLocateBoxTruthModel, IValidationTruthModelMultiCompareTruthModel, IValidationTruthModelNamedEntityTruthModel, IValidationTruthModelPolygonTruthModel, IValidationTruthModelScrubTruthModel, IValidationTruthModelSkipTruthModel, IValidationTruthModelTranscriptionTruthModel. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when setting `actual_instance` in IValidationTruthModel with oneOf schemas: IValidationTruthModelAttachCategoryTruthModel, IValidationTruthModelBoundingBoxTruthModel, IValidationTruthModelClassifyTruthModel, IValidationTruthModelCompareTruthModel, IValidationTruthModelEmptyValidationTruthModel, IValidationTruthModelLineTruthModel, IValidationTruthModelLocateBoxTruthModel, IValidationTruthModelMultiCompareTruthModel, IValidationTruthModelNamedEntityTruthModel, IValidationTruthModelPolygonTruthModel, IValidationTruthModelScrubTruthModel, IValidationTruthModelSkipTruthModel, IValidationTruthModelTranscriptionTruthModel. 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 IValidationTruthModelAttachCategoryTruthModel
        try:
            instance.actual_instance = IValidationTruthModelAttachCategoryTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelBoundingBoxTruthModel
        try:
            instance.actual_instance = IValidationTruthModelBoundingBoxTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelClassifyTruthModel
        try:
            instance.actual_instance = IValidationTruthModelClassifyTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelCompareTruthModel
        try:
            instance.actual_instance = IValidationTruthModelCompareTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelEmptyValidationTruthModel
        try:
            instance.actual_instance = IValidationTruthModelEmptyValidationTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelLineTruthModel
        try:
            instance.actual_instance = IValidationTruthModelLineTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelLocateBoxTruthModel
        try:
            instance.actual_instance = IValidationTruthModelLocateBoxTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelMultiCompareTruthModel
        try:
            instance.actual_instance = IValidationTruthModelMultiCompareTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelNamedEntityTruthModel
        try:
            instance.actual_instance = IValidationTruthModelNamedEntityTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelPolygonTruthModel
        try:
            instance.actual_instance = IValidationTruthModelPolygonTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelScrubTruthModel
        try:
            instance.actual_instance = IValidationTruthModelScrubTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelSkipTruthModel
        try:
            instance.actual_instance = IValidationTruthModelSkipTruthModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into IValidationTruthModelTranscriptionTruthModel
        try:
            instance.actual_instance = IValidationTruthModelTranscriptionTruthModel.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 IValidationTruthModel with oneOf schemas: IValidationTruthModelAttachCategoryTruthModel, IValidationTruthModelBoundingBoxTruthModel, IValidationTruthModelClassifyTruthModel, IValidationTruthModelCompareTruthModel, IValidationTruthModelEmptyValidationTruthModel, IValidationTruthModelLineTruthModel, IValidationTruthModelLocateBoxTruthModel, IValidationTruthModelMultiCompareTruthModel, IValidationTruthModelNamedEntityTruthModel, IValidationTruthModelPolygonTruthModel, IValidationTruthModelScrubTruthModel, IValidationTruthModelSkipTruthModel, IValidationTruthModelTranscriptionTruthModel. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when deserializing the JSON string into IValidationTruthModel with oneOf schemas: IValidationTruthModelAttachCategoryTruthModel, IValidationTruthModelBoundingBoxTruthModel, IValidationTruthModelClassifyTruthModel, IValidationTruthModelCompareTruthModel, IValidationTruthModelEmptyValidationTruthModel, IValidationTruthModelLineTruthModel, IValidationTruthModelLocateBoxTruthModel, IValidationTruthModelMultiCompareTruthModel, IValidationTruthModelNamedEntityTruthModel, IValidationTruthModelPolygonTruthModel, IValidationTruthModelScrubTruthModel, IValidationTruthModelSkipTruthModel, IValidationTruthModelTranscriptionTruthModel. 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], IValidationTruthModelAttachCategoryTruthModel, IValidationTruthModelBoundingBoxTruthModel, IValidationTruthModelClassifyTruthModel, IValidationTruthModelCompareTruthModel, IValidationTruthModelEmptyValidationTruthModel, IValidationTruthModelLineTruthModel, IValidationTruthModelLocateBoxTruthModel, IValidationTruthModelMultiCompareTruthModel, IValidationTruthModelNamedEntityTruthModel, IValidationTruthModelPolygonTruthModel, IValidationTruthModelScrubTruthModel, IValidationTruthModelSkipTruthModel, IValidationTruthModelTranscriptionTruthModel]]:
        """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())


