# coding: utf-8

"""
    allure-testops-service

    Branch **HEAD**  Commit **623f6ed302ba4b651cf9040faca4635af2d93b7c**

    The version of the OpenAPI document: 25.4.1
    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 src.client.generated.models.widget_options_analytic_graph import WidgetOptionsAnalyticGraph
from src.client.generated.models.widget_options_last_launch_pie_chart import WidgetOptionsLastLaunchPieChart
from src.client.generated.models.widget_options_launch_list import WidgetOptionsLaunchList
from src.client.generated.models.widget_options_launch_trend import WidgetOptionsLaunchTrend
from src.client.generated.models.widget_options_markdown import WidgetOptionsMarkdown
from src.client.generated.models.widget_options_statistic_trend import WidgetOptionsStatisticTrend
from src.client.generated.models.widget_options_tc_pie_chart import WidgetOptionsTcPieChart
from src.client.generated.models.widget_options_tc_tree_map import WidgetOptionsTcTreeMap
from src.client.generated.models.widget_options_top_tc import WidgetOptionsTopTc
from src.client.generated.models.widget_options_trend import WidgetOptionsTrend
from src.client.generated.models.widget_options_trend_v2 import WidgetOptionsTrendV2
from pydantic import StrictStr, Field
from typing import Union, List, Set, Optional, Dict
from typing_extensions import Literal, Self

WIDGETCREATEDTOOPTIONS_ONE_OF_SCHEMAS = ["WidgetOptionsAnalyticGraph", "WidgetOptionsLastLaunchPieChart", "WidgetOptionsLaunchList", "WidgetOptionsLaunchTrend", "WidgetOptionsMarkdown", "WidgetOptionsStatisticTrend", "WidgetOptionsTcPieChart", "WidgetOptionsTcTreeMap", "WidgetOptionsTopTc", "WidgetOptionsTrend", "WidgetOptionsTrendV2"]

class WidgetCreateDtoOptions(BaseModel):
    """
    WidgetCreateDtoOptions
    """
    # data type: WidgetOptionsAnalyticGraph
    oneof_schema_1_validator: Optional[WidgetOptionsAnalyticGraph] = None
    # data type: WidgetOptionsLastLaunchPieChart
    oneof_schema_2_validator: Optional[WidgetOptionsLastLaunchPieChart] = None
    # data type: WidgetOptionsLaunchList
    oneof_schema_3_validator: Optional[WidgetOptionsLaunchList] = None
    # data type: WidgetOptionsLaunchTrend
    oneof_schema_4_validator: Optional[WidgetOptionsLaunchTrend] = None
    # data type: WidgetOptionsMarkdown
    oneof_schema_5_validator: Optional[WidgetOptionsMarkdown] = None
    # data type: WidgetOptionsStatisticTrend
    oneof_schema_6_validator: Optional[WidgetOptionsStatisticTrend] = None
    # data type: WidgetOptionsTcPieChart
    oneof_schema_7_validator: Optional[WidgetOptionsTcPieChart] = None
    # data type: WidgetOptionsTcTreeMap
    oneof_schema_8_validator: Optional[WidgetOptionsTcTreeMap] = None
    # data type: WidgetOptionsTopTc
    oneof_schema_9_validator: Optional[WidgetOptionsTopTc] = None
    # data type: WidgetOptionsTrend
    oneof_schema_10_validator: Optional[WidgetOptionsTrend] = None
    # data type: WidgetOptionsTrendV2
    oneof_schema_11_validator: Optional[WidgetOptionsTrendV2] = None
    actual_instance: Optional[Union[WidgetOptionsAnalyticGraph, WidgetOptionsLastLaunchPieChart, WidgetOptionsLaunchList, WidgetOptionsLaunchTrend, WidgetOptionsMarkdown, WidgetOptionsStatisticTrend, WidgetOptionsTcPieChart, WidgetOptionsTcTreeMap, WidgetOptionsTopTc, WidgetOptionsTrend, WidgetOptionsTrendV2]] = None
    one_of_schemas: Set[str] = { "WidgetOptionsAnalyticGraph", "WidgetOptionsLastLaunchPieChart", "WidgetOptionsLaunchList", "WidgetOptionsLaunchTrend", "WidgetOptionsMarkdown", "WidgetOptionsStatisticTrend", "WidgetOptionsTcPieChart", "WidgetOptionsTcTreeMap", "WidgetOptionsTopTc", "WidgetOptionsTrend", "WidgetOptionsTrendV2" }

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


    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 = WidgetCreateDtoOptions.model_construct()
        error_messages = []
        match = 0
        # validate data type: WidgetOptionsAnalyticGraph
        if not isinstance(v, WidgetOptionsAnalyticGraph):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsAnalyticGraph`")
        else:
            match += 1
        # validate data type: WidgetOptionsLastLaunchPieChart
        if not isinstance(v, WidgetOptionsLastLaunchPieChart):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsLastLaunchPieChart`")
        else:
            match += 1
        # validate data type: WidgetOptionsLaunchList
        if not isinstance(v, WidgetOptionsLaunchList):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsLaunchList`")
        else:
            match += 1
        # validate data type: WidgetOptionsLaunchTrend
        if not isinstance(v, WidgetOptionsLaunchTrend):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsLaunchTrend`")
        else:
            match += 1
        # validate data type: WidgetOptionsMarkdown
        if not isinstance(v, WidgetOptionsMarkdown):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsMarkdown`")
        else:
            match += 1
        # validate data type: WidgetOptionsStatisticTrend
        if not isinstance(v, WidgetOptionsStatisticTrend):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsStatisticTrend`")
        else:
            match += 1
        # validate data type: WidgetOptionsTcPieChart
        if not isinstance(v, WidgetOptionsTcPieChart):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsTcPieChart`")
        else:
            match += 1
        # validate data type: WidgetOptionsTcTreeMap
        if not isinstance(v, WidgetOptionsTcTreeMap):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsTcTreeMap`")
        else:
            match += 1
        # validate data type: WidgetOptionsTopTc
        if not isinstance(v, WidgetOptionsTopTc):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsTopTc`")
        else:
            match += 1
        # validate data type: WidgetOptionsTrend
        if not isinstance(v, WidgetOptionsTrend):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsTrend`")
        else:
            match += 1
        # validate data type: WidgetOptionsTrendV2
        if not isinstance(v, WidgetOptionsTrendV2):
            error_messages.append(f"Error! Input type `{type(v)}` is not `WidgetOptionsTrendV2`")
        else:
            match += 1
        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when setting `actual_instance` in WidgetCreateDtoOptions with oneOf schemas: WidgetOptionsAnalyticGraph, WidgetOptionsLastLaunchPieChart, WidgetOptionsLaunchList, WidgetOptionsLaunchTrend, WidgetOptionsMarkdown, WidgetOptionsStatisticTrend, WidgetOptionsTcPieChart, WidgetOptionsTcTreeMap, WidgetOptionsTopTc, WidgetOptionsTrend, WidgetOptionsTrendV2. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when setting `actual_instance` in WidgetCreateDtoOptions with oneOf schemas: WidgetOptionsAnalyticGraph, WidgetOptionsLastLaunchPieChart, WidgetOptionsLaunchList, WidgetOptionsLaunchTrend, WidgetOptionsMarkdown, WidgetOptionsStatisticTrend, WidgetOptionsTcPieChart, WidgetOptionsTcTreeMap, WidgetOptionsTopTc, WidgetOptionsTrend, WidgetOptionsTrendV2. 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 WidgetOptionsAnalyticGraph
        try:
            instance.actual_instance = WidgetOptionsAnalyticGraph.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WidgetOptionsLastLaunchPieChart
        try:
            instance.actual_instance = WidgetOptionsLastLaunchPieChart.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WidgetOptionsLaunchList
        try:
            instance.actual_instance = WidgetOptionsLaunchList.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WidgetOptionsLaunchTrend
        try:
            instance.actual_instance = WidgetOptionsLaunchTrend.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WidgetOptionsMarkdown
        try:
            instance.actual_instance = WidgetOptionsMarkdown.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WidgetOptionsStatisticTrend
        try:
            instance.actual_instance = WidgetOptionsStatisticTrend.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WidgetOptionsTcPieChart
        try:
            instance.actual_instance = WidgetOptionsTcPieChart.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WidgetOptionsTcTreeMap
        try:
            instance.actual_instance = WidgetOptionsTcTreeMap.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WidgetOptionsTopTc
        try:
            instance.actual_instance = WidgetOptionsTopTc.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WidgetOptionsTrend
        try:
            instance.actual_instance = WidgetOptionsTrend.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into WidgetOptionsTrendV2
        try:
            instance.actual_instance = WidgetOptionsTrendV2.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 WidgetCreateDtoOptions with oneOf schemas: WidgetOptionsAnalyticGraph, WidgetOptionsLastLaunchPieChart, WidgetOptionsLaunchList, WidgetOptionsLaunchTrend, WidgetOptionsMarkdown, WidgetOptionsStatisticTrend, WidgetOptionsTcPieChart, WidgetOptionsTcTreeMap, WidgetOptionsTopTc, WidgetOptionsTrend, WidgetOptionsTrendV2. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when deserializing the JSON string into WidgetCreateDtoOptions with oneOf schemas: WidgetOptionsAnalyticGraph, WidgetOptionsLastLaunchPieChart, WidgetOptionsLaunchList, WidgetOptionsLaunchTrend, WidgetOptionsMarkdown, WidgetOptionsStatisticTrend, WidgetOptionsTcPieChart, WidgetOptionsTcTreeMap, WidgetOptionsTopTc, WidgetOptionsTrend, WidgetOptionsTrendV2. 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], WidgetOptionsAnalyticGraph, WidgetOptionsLastLaunchPieChart, WidgetOptionsLaunchList, WidgetOptionsLaunchTrend, WidgetOptionsMarkdown, WidgetOptionsStatisticTrend, WidgetOptionsTcPieChart, WidgetOptionsTcTreeMap, WidgetOptionsTopTc, WidgetOptionsTrend, WidgetOptionsTrendV2]]:
        """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())


