# coding: utf-8

"""
    Rapidata.Dataset

    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 rapidata.api_client.models.classification_metadata_model import ClassificationMetadataModel
from rapidata.api_client.models.count_metadata_model import CountMetadataModel
from rapidata.api_client.models.demographic_metadata_model import DemographicMetadataModel
from rapidata.api_client.models.image_dimension_metadata_model import ImageDimensionMetadataModel
from rapidata.api_client.models.location_metadata_model import LocationMetadataModel
from rapidata.api_client.models.original_filename_metadata_model import OriginalFilenameMetadataModel
from rapidata.api_client.models.prompt_metadata_model import PromptMetadataModel
from rapidata.api_client.models.text_metadata_model import TextMetadataModel
from rapidata.api_client.models.transcription_metadata_model import TranscriptionMetadataModel
from rapidata.api_client.models.translated_prompt_metadata_model import TranslatedPromptMetadataModel
from pydantic import StrictStr, Field
from typing import Union, List, Set, Optional, Dict
from typing_extensions import Literal, Self

FILEASSETMODEL1METADATAINNER_ONE_OF_SCHEMAS = ["ClassificationMetadataModel", "CountMetadataModel", "DemographicMetadataModel", "ImageDimensionMetadataModel", "LocationMetadataModel", "OriginalFilenameMetadataModel", "PromptMetadataModel", "TextMetadataModel", "TranscriptionMetadataModel", "TranslatedPromptMetadataModel"]

class FileAssetModel1MetadataInner(BaseModel):
    """
    FileAssetModel1MetadataInner
    """
    # data type: TranslatedPromptMetadataModel
    oneof_schema_1_validator: Optional[TranslatedPromptMetadataModel] = None
    # data type: ClassificationMetadataModel
    oneof_schema_2_validator: Optional[ClassificationMetadataModel] = None
    # data type: CountMetadataModel
    oneof_schema_3_validator: Optional[CountMetadataModel] = None
    # data type: DemographicMetadataModel
    oneof_schema_4_validator: Optional[DemographicMetadataModel] = None
    # data type: ImageDimensionMetadataModel
    oneof_schema_5_validator: Optional[ImageDimensionMetadataModel] = None
    # data type: LocationMetadataModel
    oneof_schema_6_validator: Optional[LocationMetadataModel] = None
    # data type: OriginalFilenameMetadataModel
    oneof_schema_7_validator: Optional[OriginalFilenameMetadataModel] = None
    # data type: PromptMetadataModel
    oneof_schema_8_validator: Optional[PromptMetadataModel] = None
    # data type: TextMetadataModel
    oneof_schema_9_validator: Optional[TextMetadataModel] = None
    # data type: TranscriptionMetadataModel
    oneof_schema_10_validator: Optional[TranscriptionMetadataModel] = None
    actual_instance: Optional[Union[ClassificationMetadataModel, CountMetadataModel, DemographicMetadataModel, ImageDimensionMetadataModel, LocationMetadataModel, OriginalFilenameMetadataModel, PromptMetadataModel, TextMetadataModel, TranscriptionMetadataModel, TranslatedPromptMetadataModel]] = None
    one_of_schemas: Set[str] = { "ClassificationMetadataModel", "CountMetadataModel", "DemographicMetadataModel", "ImageDimensionMetadataModel", "LocationMetadataModel", "OriginalFilenameMetadataModel", "PromptMetadataModel", "TextMetadataModel", "TranscriptionMetadataModel", "TranslatedPromptMetadataModel" }

    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 = FileAssetModel1MetadataInner.model_construct()
        error_messages = []
        match = 0
        # validate data type: TranslatedPromptMetadataModel
        if not isinstance(v, TranslatedPromptMetadataModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `TranslatedPromptMetadataModel`")
        else:
            match += 1
        # validate data type: ClassificationMetadataModel
        if not isinstance(v, ClassificationMetadataModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ClassificationMetadataModel`")
        else:
            match += 1
        # validate data type: CountMetadataModel
        if not isinstance(v, CountMetadataModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `CountMetadataModel`")
        else:
            match += 1
        # validate data type: DemographicMetadataModel
        if not isinstance(v, DemographicMetadataModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `DemographicMetadataModel`")
        else:
            match += 1
        # validate data type: ImageDimensionMetadataModel
        if not isinstance(v, ImageDimensionMetadataModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ImageDimensionMetadataModel`")
        else:
            match += 1
        # validate data type: LocationMetadataModel
        if not isinstance(v, LocationMetadataModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `LocationMetadataModel`")
        else:
            match += 1
        # validate data type: OriginalFilenameMetadataModel
        if not isinstance(v, OriginalFilenameMetadataModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `OriginalFilenameMetadataModel`")
        else:
            match += 1
        # validate data type: PromptMetadataModel
        if not isinstance(v, PromptMetadataModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `PromptMetadataModel`")
        else:
            match += 1
        # validate data type: TextMetadataModel
        if not isinstance(v, TextMetadataModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `TextMetadataModel`")
        else:
            match += 1
        # validate data type: TranscriptionMetadataModel
        if not isinstance(v, TranscriptionMetadataModel):
            error_messages.append(f"Error! Input type `{type(v)}` is not `TranscriptionMetadataModel`")
        else:
            match += 1
        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when setting `actual_instance` in FileAssetModel1MetadataInner with oneOf schemas: ClassificationMetadataModel, CountMetadataModel, DemographicMetadataModel, ImageDimensionMetadataModel, LocationMetadataModel, OriginalFilenameMetadataModel, PromptMetadataModel, TextMetadataModel, TranscriptionMetadataModel, TranslatedPromptMetadataModel. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when setting `actual_instance` in FileAssetModel1MetadataInner with oneOf schemas: ClassificationMetadataModel, CountMetadataModel, DemographicMetadataModel, ImageDimensionMetadataModel, LocationMetadataModel, OriginalFilenameMetadataModel, PromptMetadataModel, TextMetadataModel, TranscriptionMetadataModel, TranslatedPromptMetadataModel. 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 TranslatedPromptMetadataModel
        try:
            instance.actual_instance = TranslatedPromptMetadataModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ClassificationMetadataModel
        try:
            instance.actual_instance = ClassificationMetadataModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into CountMetadataModel
        try:
            instance.actual_instance = CountMetadataModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into DemographicMetadataModel
        try:
            instance.actual_instance = DemographicMetadataModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ImageDimensionMetadataModel
        try:
            instance.actual_instance = ImageDimensionMetadataModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into LocationMetadataModel
        try:
            instance.actual_instance = LocationMetadataModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into OriginalFilenameMetadataModel
        try:
            instance.actual_instance = OriginalFilenameMetadataModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into PromptMetadataModel
        try:
            instance.actual_instance = PromptMetadataModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into TextMetadataModel
        try:
            instance.actual_instance = TextMetadataModel.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into TranscriptionMetadataModel
        try:
            instance.actual_instance = TranscriptionMetadataModel.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 FileAssetModel1MetadataInner with oneOf schemas: ClassificationMetadataModel, CountMetadataModel, DemographicMetadataModel, ImageDimensionMetadataModel, LocationMetadataModel, OriginalFilenameMetadataModel, PromptMetadataModel, TextMetadataModel, TranscriptionMetadataModel, TranslatedPromptMetadataModel. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when deserializing the JSON string into FileAssetModel1MetadataInner with oneOf schemas: ClassificationMetadataModel, CountMetadataModel, DemographicMetadataModel, ImageDimensionMetadataModel, LocationMetadataModel, OriginalFilenameMetadataModel, PromptMetadataModel, TextMetadataModel, TranscriptionMetadataModel, TranslatedPromptMetadataModel. 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], ClassificationMetadataModel, CountMetadataModel, DemographicMetadataModel, ImageDimensionMetadataModel, LocationMetadataModel, OriginalFilenameMetadataModel, PromptMetadataModel, TextMetadataModel, TranscriptionMetadataModel, TranslatedPromptMetadataModel]]:
        """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())


