# 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.bold_mark import BoldMark
from src.client.generated.models.code_mark import CodeMark
from src.client.generated.models.italic_mark import ItalicMark
from src.client.generated.models.link_mark import LinkMark
from src.client.generated.models.strike_mark import StrikeMark
from src.client.generated.models.text_color_mark import TextColorMark
from src.client.generated.models.text_fill_mark import TextFillMark
from src.client.generated.models.underline_mark import UnderlineMark
from pydantic import StrictStr, Field
from typing import Union, List, Set, Optional, Dict
from typing_extensions import Literal, Self

TEXTPARAGRAPHNODEMARKSINNER_ONE_OF_SCHEMAS = ["BoldMark", "CodeMark", "ItalicMark", "LinkMark", "StrikeMark", "TextColorMark", "TextFillMark", "UnderlineMark"]

class TextParagraphNodeMarksInner(BaseModel):
    """
    TextParagraphNodeMarksInner
    """
    # data type: BoldMark
    oneof_schema_1_validator: Optional[BoldMark] = None
    # data type: CodeMark
    oneof_schema_2_validator: Optional[CodeMark] = None
    # data type: ItalicMark
    oneof_schema_3_validator: Optional[ItalicMark] = None
    # data type: LinkMark
    oneof_schema_4_validator: Optional[LinkMark] = None
    # data type: StrikeMark
    oneof_schema_5_validator: Optional[StrikeMark] = None
    # data type: TextColorMark
    oneof_schema_6_validator: Optional[TextColorMark] = None
    # data type: TextFillMark
    oneof_schema_7_validator: Optional[TextFillMark] = None
    # data type: UnderlineMark
    oneof_schema_8_validator: Optional[UnderlineMark] = None
    actual_instance: Optional[Union[BoldMark, CodeMark, ItalicMark, LinkMark, StrikeMark, TextColorMark, TextFillMark, UnderlineMark]] = None
    one_of_schemas: Set[str] = { "BoldMark", "CodeMark", "ItalicMark", "LinkMark", "StrikeMark", "TextColorMark", "TextFillMark", "UnderlineMark" }

    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 = TextParagraphNodeMarksInner.model_construct()
        error_messages = []
        match = 0
        # validate data type: BoldMark
        if not isinstance(v, BoldMark):
            error_messages.append(f"Error! Input type `{type(v)}` is not `BoldMark`")
        else:
            match += 1
        # validate data type: CodeMark
        if not isinstance(v, CodeMark):
            error_messages.append(f"Error! Input type `{type(v)}` is not `CodeMark`")
        else:
            match += 1
        # validate data type: ItalicMark
        if not isinstance(v, ItalicMark):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ItalicMark`")
        else:
            match += 1
        # validate data type: LinkMark
        if not isinstance(v, LinkMark):
            error_messages.append(f"Error! Input type `{type(v)}` is not `LinkMark`")
        else:
            match += 1
        # validate data type: StrikeMark
        if not isinstance(v, StrikeMark):
            error_messages.append(f"Error! Input type `{type(v)}` is not `StrikeMark`")
        else:
            match += 1
        # validate data type: TextColorMark
        if not isinstance(v, TextColorMark):
            error_messages.append(f"Error! Input type `{type(v)}` is not `TextColorMark`")
        else:
            match += 1
        # validate data type: TextFillMark
        if not isinstance(v, TextFillMark):
            error_messages.append(f"Error! Input type `{type(v)}` is not `TextFillMark`")
        else:
            match += 1
        # validate data type: UnderlineMark
        if not isinstance(v, UnderlineMark):
            error_messages.append(f"Error! Input type `{type(v)}` is not `UnderlineMark`")
        else:
            match += 1
        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when setting `actual_instance` in TextParagraphNodeMarksInner with oneOf schemas: BoldMark, CodeMark, ItalicMark, LinkMark, StrikeMark, TextColorMark, TextFillMark, UnderlineMark. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when setting `actual_instance` in TextParagraphNodeMarksInner with oneOf schemas: BoldMark, CodeMark, ItalicMark, LinkMark, StrikeMark, TextColorMark, TextFillMark, UnderlineMark. 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 BoldMark
        try:
            instance.actual_instance = BoldMark.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into CodeMark
        try:
            instance.actual_instance = CodeMark.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ItalicMark
        try:
            instance.actual_instance = ItalicMark.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into LinkMark
        try:
            instance.actual_instance = LinkMark.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into StrikeMark
        try:
            instance.actual_instance = StrikeMark.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into TextColorMark
        try:
            instance.actual_instance = TextColorMark.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into TextFillMark
        try:
            instance.actual_instance = TextFillMark.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into UnderlineMark
        try:
            instance.actual_instance = UnderlineMark.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 TextParagraphNodeMarksInner with oneOf schemas: BoldMark, CodeMark, ItalicMark, LinkMark, StrikeMark, TextColorMark, TextFillMark, UnderlineMark. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when deserializing the JSON string into TextParagraphNodeMarksInner with oneOf schemas: BoldMark, CodeMark, ItalicMark, LinkMark, StrikeMark, TextColorMark, TextFillMark, UnderlineMark. 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], BoldMark, CodeMark, ItalicMark, LinkMark, StrikeMark, TextColorMark, TextFillMark, UnderlineMark]]:
        """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())


