# coding: utf-8

"""
    Agent Service

    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 asteroid_odyssey.models.agents_execution_agent_query_context_started_details import AgentsExecutionAgentQueryContextStartedDetails
from asteroid_odyssey.models.agents_execution_llm_call_started_details import AgentsExecutionLLMCallStartedDetails
from asteroid_odyssey.models.agents_execution_nav_to_started_details import AgentsExecutionNavToStartedDetails
from asteroid_odyssey.models.agents_execution_scratchpad_read_started_details import AgentsExecutionScratchpadReadStartedDetails
from asteroid_odyssey.models.agents_execution_scratchpad_write_started_details import AgentsExecutionScratchpadWriteStartedDetails
from asteroid_odyssey.models.agents_execution_script_eval_started_details import AgentsExecutionScriptEvalStartedDetails
from asteroid_odyssey.models.agents_execution_script_hybrid_playwright_started_details import AgentsExecutionScriptHybridPlaywrightStartedDetails
from asteroid_odyssey.models.agents_execution_script_playwright_started_details import AgentsExecutionScriptPlaywrightStartedDetails
from asteroid_odyssey.models.agents_execution_scriptpad_read_started_details import AgentsExecutionScriptpadReadStartedDetails
from asteroid_odyssey.models.agents_execution_scriptpad_run_function_started_details import AgentsExecutionScriptpadRunFunctionStartedDetails
from asteroid_odyssey.models.agents_execution_scriptpad_search_replace_started_details import AgentsExecutionScriptpadSearchReplaceStartedDetails
from asteroid_odyssey.models.agents_execution_util_get_datetime_started_details import AgentsExecutionUtilGetDatetimeStartedDetails
from pydantic import StrictStr, Field
from typing import Union, List, Set, Optional, Dict
from typing_extensions import Literal, Self

AGENTSEXECUTIONACTIVITYACTIONSTARTEDINFO_ONE_OF_SCHEMAS = ["AgentsExecutionAgentQueryContextStartedDetails", "AgentsExecutionLLMCallStartedDetails", "AgentsExecutionNavToStartedDetails", "AgentsExecutionScratchpadReadStartedDetails", "AgentsExecutionScratchpadWriteStartedDetails", "AgentsExecutionScriptEvalStartedDetails", "AgentsExecutionScriptHybridPlaywrightStartedDetails", "AgentsExecutionScriptPlaywrightStartedDetails", "AgentsExecutionScriptpadReadStartedDetails", "AgentsExecutionScriptpadRunFunctionStartedDetails", "AgentsExecutionScriptpadSearchReplaceStartedDetails", "AgentsExecutionUtilGetDatetimeStartedDetails"]

class AgentsExecutionActivityActionStartedInfo(BaseModel):
    """
    AgentsExecutionActivityActionStartedInfo
    """
    # data type: AgentsExecutionNavToStartedDetails
    oneof_schema_1_validator: Optional[AgentsExecutionNavToStartedDetails] = None
    # data type: AgentsExecutionScratchpadReadStartedDetails
    oneof_schema_2_validator: Optional[AgentsExecutionScratchpadReadStartedDetails] = None
    # data type: AgentsExecutionScratchpadWriteStartedDetails
    oneof_schema_3_validator: Optional[AgentsExecutionScratchpadWriteStartedDetails] = None
    # data type: AgentsExecutionScriptpadRunFunctionStartedDetails
    oneof_schema_4_validator: Optional[AgentsExecutionScriptpadRunFunctionStartedDetails] = None
    # data type: AgentsExecutionScriptPlaywrightStartedDetails
    oneof_schema_5_validator: Optional[AgentsExecutionScriptPlaywrightStartedDetails] = None
    # data type: AgentsExecutionScriptHybridPlaywrightStartedDetails
    oneof_schema_6_validator: Optional[AgentsExecutionScriptHybridPlaywrightStartedDetails] = None
    # data type: AgentsExecutionScriptEvalStartedDetails
    oneof_schema_7_validator: Optional[AgentsExecutionScriptEvalStartedDetails] = None
    # data type: AgentsExecutionScriptpadSearchReplaceStartedDetails
    oneof_schema_8_validator: Optional[AgentsExecutionScriptpadSearchReplaceStartedDetails] = None
    # data type: AgentsExecutionUtilGetDatetimeStartedDetails
    oneof_schema_9_validator: Optional[AgentsExecutionUtilGetDatetimeStartedDetails] = None
    # data type: AgentsExecutionScriptpadReadStartedDetails
    oneof_schema_10_validator: Optional[AgentsExecutionScriptpadReadStartedDetails] = None
    # data type: AgentsExecutionLLMCallStartedDetails
    oneof_schema_11_validator: Optional[AgentsExecutionLLMCallStartedDetails] = None
    # data type: AgentsExecutionAgentQueryContextStartedDetails
    oneof_schema_12_validator: Optional[AgentsExecutionAgentQueryContextStartedDetails] = None
    actual_instance: Optional[Union[AgentsExecutionAgentQueryContextStartedDetails, AgentsExecutionLLMCallStartedDetails, AgentsExecutionNavToStartedDetails, AgentsExecutionScratchpadReadStartedDetails, AgentsExecutionScratchpadWriteStartedDetails, AgentsExecutionScriptEvalStartedDetails, AgentsExecutionScriptHybridPlaywrightStartedDetails, AgentsExecutionScriptPlaywrightStartedDetails, AgentsExecutionScriptpadReadStartedDetails, AgentsExecutionScriptpadRunFunctionStartedDetails, AgentsExecutionScriptpadSearchReplaceStartedDetails, AgentsExecutionUtilGetDatetimeStartedDetails]] = None
    one_of_schemas: Set[str] = { "AgentsExecutionAgentQueryContextStartedDetails", "AgentsExecutionLLMCallStartedDetails", "AgentsExecutionNavToStartedDetails", "AgentsExecutionScratchpadReadStartedDetails", "AgentsExecutionScratchpadWriteStartedDetails", "AgentsExecutionScriptEvalStartedDetails", "AgentsExecutionScriptHybridPlaywrightStartedDetails", "AgentsExecutionScriptPlaywrightStartedDetails", "AgentsExecutionScriptpadReadStartedDetails", "AgentsExecutionScriptpadRunFunctionStartedDetails", "AgentsExecutionScriptpadSearchReplaceStartedDetails", "AgentsExecutionUtilGetDatetimeStartedDetails" }

    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 = AgentsExecutionActivityActionStartedInfo.model_construct()
        error_messages = []
        match = 0
        # validate data type: AgentsExecutionNavToStartedDetails
        if not isinstance(v, AgentsExecutionNavToStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionNavToStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionScratchpadReadStartedDetails
        if not isinstance(v, AgentsExecutionScratchpadReadStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionScratchpadReadStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionScratchpadWriteStartedDetails
        if not isinstance(v, AgentsExecutionScratchpadWriteStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionScratchpadWriteStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionScriptpadRunFunctionStartedDetails
        if not isinstance(v, AgentsExecutionScriptpadRunFunctionStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionScriptpadRunFunctionStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionScriptPlaywrightStartedDetails
        if not isinstance(v, AgentsExecutionScriptPlaywrightStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionScriptPlaywrightStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionScriptHybridPlaywrightStartedDetails
        if not isinstance(v, AgentsExecutionScriptHybridPlaywrightStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionScriptHybridPlaywrightStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionScriptEvalStartedDetails
        if not isinstance(v, AgentsExecutionScriptEvalStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionScriptEvalStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionScriptpadSearchReplaceStartedDetails
        if not isinstance(v, AgentsExecutionScriptpadSearchReplaceStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionScriptpadSearchReplaceStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionUtilGetDatetimeStartedDetails
        if not isinstance(v, AgentsExecutionUtilGetDatetimeStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionUtilGetDatetimeStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionScriptpadReadStartedDetails
        if not isinstance(v, AgentsExecutionScriptpadReadStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionScriptpadReadStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionLLMCallStartedDetails
        if not isinstance(v, AgentsExecutionLLMCallStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionLLMCallStartedDetails`")
        else:
            match += 1
        # validate data type: AgentsExecutionAgentQueryContextStartedDetails
        if not isinstance(v, AgentsExecutionAgentQueryContextStartedDetails):
            error_messages.append(f"Error! Input type `{type(v)}` is not `AgentsExecutionAgentQueryContextStartedDetails`")
        else:
            match += 1
        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when setting `actual_instance` in AgentsExecutionActivityActionStartedInfo with oneOf schemas: AgentsExecutionAgentQueryContextStartedDetails, AgentsExecutionLLMCallStartedDetails, AgentsExecutionNavToStartedDetails, AgentsExecutionScratchpadReadStartedDetails, AgentsExecutionScratchpadWriteStartedDetails, AgentsExecutionScriptEvalStartedDetails, AgentsExecutionScriptHybridPlaywrightStartedDetails, AgentsExecutionScriptPlaywrightStartedDetails, AgentsExecutionScriptpadReadStartedDetails, AgentsExecutionScriptpadRunFunctionStartedDetails, AgentsExecutionScriptpadSearchReplaceStartedDetails, AgentsExecutionUtilGetDatetimeStartedDetails. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when setting `actual_instance` in AgentsExecutionActivityActionStartedInfo with oneOf schemas: AgentsExecutionAgentQueryContextStartedDetails, AgentsExecutionLLMCallStartedDetails, AgentsExecutionNavToStartedDetails, AgentsExecutionScratchpadReadStartedDetails, AgentsExecutionScratchpadWriteStartedDetails, AgentsExecutionScriptEvalStartedDetails, AgentsExecutionScriptHybridPlaywrightStartedDetails, AgentsExecutionScriptPlaywrightStartedDetails, AgentsExecutionScriptpadReadStartedDetails, AgentsExecutionScriptpadRunFunctionStartedDetails, AgentsExecutionScriptpadSearchReplaceStartedDetails, AgentsExecutionUtilGetDatetimeStartedDetails. 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 AgentsExecutionNavToStartedDetails
        try:
            instance.actual_instance = AgentsExecutionNavToStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionScratchpadReadStartedDetails
        try:
            instance.actual_instance = AgentsExecutionScratchpadReadStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionScratchpadWriteStartedDetails
        try:
            instance.actual_instance = AgentsExecutionScratchpadWriteStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionScriptpadRunFunctionStartedDetails
        try:
            instance.actual_instance = AgentsExecutionScriptpadRunFunctionStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionScriptPlaywrightStartedDetails
        try:
            instance.actual_instance = AgentsExecutionScriptPlaywrightStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionScriptHybridPlaywrightStartedDetails
        try:
            instance.actual_instance = AgentsExecutionScriptHybridPlaywrightStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionScriptEvalStartedDetails
        try:
            instance.actual_instance = AgentsExecutionScriptEvalStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionScriptpadSearchReplaceStartedDetails
        try:
            instance.actual_instance = AgentsExecutionScriptpadSearchReplaceStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionUtilGetDatetimeStartedDetails
        try:
            instance.actual_instance = AgentsExecutionUtilGetDatetimeStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionScriptpadReadStartedDetails
        try:
            instance.actual_instance = AgentsExecutionScriptpadReadStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionLLMCallStartedDetails
        try:
            instance.actual_instance = AgentsExecutionLLMCallStartedDetails.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into AgentsExecutionAgentQueryContextStartedDetails
        try:
            instance.actual_instance = AgentsExecutionAgentQueryContextStartedDetails.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 AgentsExecutionActivityActionStartedInfo with oneOf schemas: AgentsExecutionAgentQueryContextStartedDetails, AgentsExecutionLLMCallStartedDetails, AgentsExecutionNavToStartedDetails, AgentsExecutionScratchpadReadStartedDetails, AgentsExecutionScratchpadWriteStartedDetails, AgentsExecutionScriptEvalStartedDetails, AgentsExecutionScriptHybridPlaywrightStartedDetails, AgentsExecutionScriptPlaywrightStartedDetails, AgentsExecutionScriptpadReadStartedDetails, AgentsExecutionScriptpadRunFunctionStartedDetails, AgentsExecutionScriptpadSearchReplaceStartedDetails, AgentsExecutionUtilGetDatetimeStartedDetails. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when deserializing the JSON string into AgentsExecutionActivityActionStartedInfo with oneOf schemas: AgentsExecutionAgentQueryContextStartedDetails, AgentsExecutionLLMCallStartedDetails, AgentsExecutionNavToStartedDetails, AgentsExecutionScratchpadReadStartedDetails, AgentsExecutionScratchpadWriteStartedDetails, AgentsExecutionScriptEvalStartedDetails, AgentsExecutionScriptHybridPlaywrightStartedDetails, AgentsExecutionScriptPlaywrightStartedDetails, AgentsExecutionScriptpadReadStartedDetails, AgentsExecutionScriptpadRunFunctionStartedDetails, AgentsExecutionScriptpadSearchReplaceStartedDetails, AgentsExecutionUtilGetDatetimeStartedDetails. 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], AgentsExecutionAgentQueryContextStartedDetails, AgentsExecutionLLMCallStartedDetails, AgentsExecutionNavToStartedDetails, AgentsExecutionScratchpadReadStartedDetails, AgentsExecutionScratchpadWriteStartedDetails, AgentsExecutionScriptEvalStartedDetails, AgentsExecutionScriptHybridPlaywrightStartedDetails, AgentsExecutionScriptPlaywrightStartedDetails, AgentsExecutionScriptpadReadStartedDetails, AgentsExecutionScriptpadRunFunctionStartedDetails, AgentsExecutionScriptpadSearchReplaceStartedDetails, AgentsExecutionUtilGetDatetimeStartedDetails]]:
        """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())


