# 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.ext_form_field_checkbox import ExtFormFieldCheckbox
from src.client.generated.models.ext_form_field_composite import ExtFormFieldComposite
from src.client.generated.models.ext_form_field_external_select import ExtFormFieldExternalSelect
from src.client.generated.models.ext_form_field_form_choice import ExtFormFieldFormChoice
from src.client.generated.models.ext_form_field_list import ExtFormFieldList
from src.client.generated.models.ext_form_field_number import ExtFormFieldNumber
from src.client.generated.models.ext_form_field_password import ExtFormFieldPassword
from src.client.generated.models.ext_form_field_select import ExtFormFieldSelect
from src.client.generated.models.ext_form_field_slider import ExtFormFieldSlider
from src.client.generated.models.ext_form_field_text import ExtFormFieldText
from src.client.generated.models.ext_form_field_textarea import ExtFormFieldTextarea
from src.client.generated.models.ext_form_field_unknown import ExtFormFieldUnknown
from pydantic import StrictStr, Field
from typing import Union, List, Set, Optional, Dict
from typing_extensions import Literal, Self

INTEGRATIONFIELDSFORMDTODEFAULTPROJECTFIELDSINNER_ONE_OF_SCHEMAS = ["ExtFormFieldCheckbox", "ExtFormFieldComposite", "ExtFormFieldExternalSelect", "ExtFormFieldFormChoice", "ExtFormFieldList", "ExtFormFieldNumber", "ExtFormFieldPassword", "ExtFormFieldSelect", "ExtFormFieldSlider", "ExtFormFieldText", "ExtFormFieldTextarea", "ExtFormFieldUnknown"]

class IntegrationFieldsFormDtoDefaultProjectFieldsInner(BaseModel):
    """
    IntegrationFieldsFormDtoDefaultProjectFieldsInner
    """
    # data type: ExtFormFieldCheckbox
    oneof_schema_1_validator: Optional[ExtFormFieldCheckbox] = None
    # data type: ExtFormFieldComposite
    oneof_schema_2_validator: Optional[ExtFormFieldComposite] = None
    # data type: ExtFormFieldExternalSelect
    oneof_schema_3_validator: Optional[ExtFormFieldExternalSelect] = None
    # data type: ExtFormFieldFormChoice
    oneof_schema_4_validator: Optional[ExtFormFieldFormChoice] = None
    # data type: ExtFormFieldList
    oneof_schema_5_validator: Optional[ExtFormFieldList] = None
    # data type: ExtFormFieldNumber
    oneof_schema_6_validator: Optional[ExtFormFieldNumber] = None
    # data type: ExtFormFieldPassword
    oneof_schema_7_validator: Optional[ExtFormFieldPassword] = None
    # data type: ExtFormFieldSelect
    oneof_schema_8_validator: Optional[ExtFormFieldSelect] = None
    # data type: ExtFormFieldSlider
    oneof_schema_9_validator: Optional[ExtFormFieldSlider] = None
    # data type: ExtFormFieldText
    oneof_schema_10_validator: Optional[ExtFormFieldText] = None
    # data type: ExtFormFieldTextarea
    oneof_schema_11_validator: Optional[ExtFormFieldTextarea] = None
    # data type: ExtFormFieldUnknown
    oneof_schema_12_validator: Optional[ExtFormFieldUnknown] = None
    actual_instance: Optional[Union[ExtFormFieldCheckbox, ExtFormFieldComposite, ExtFormFieldExternalSelect, ExtFormFieldFormChoice, ExtFormFieldList, ExtFormFieldNumber, ExtFormFieldPassword, ExtFormFieldSelect, ExtFormFieldSlider, ExtFormFieldText, ExtFormFieldTextarea, ExtFormFieldUnknown]] = None
    one_of_schemas: Set[str] = { "ExtFormFieldCheckbox", "ExtFormFieldComposite", "ExtFormFieldExternalSelect", "ExtFormFieldFormChoice", "ExtFormFieldList", "ExtFormFieldNumber", "ExtFormFieldPassword", "ExtFormFieldSelect", "ExtFormFieldSlider", "ExtFormFieldText", "ExtFormFieldTextarea", "ExtFormFieldUnknown" }

    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 = IntegrationFieldsFormDtoDefaultProjectFieldsInner.model_construct()
        error_messages = []
        match = 0
        # validate data type: ExtFormFieldCheckbox
        if not isinstance(v, ExtFormFieldCheckbox):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldCheckbox`")
        else:
            match += 1
        # validate data type: ExtFormFieldComposite
        if not isinstance(v, ExtFormFieldComposite):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldComposite`")
        else:
            match += 1
        # validate data type: ExtFormFieldExternalSelect
        if not isinstance(v, ExtFormFieldExternalSelect):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldExternalSelect`")
        else:
            match += 1
        # validate data type: ExtFormFieldFormChoice
        if not isinstance(v, ExtFormFieldFormChoice):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldFormChoice`")
        else:
            match += 1
        # validate data type: ExtFormFieldList
        if not isinstance(v, ExtFormFieldList):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldList`")
        else:
            match += 1
        # validate data type: ExtFormFieldNumber
        if not isinstance(v, ExtFormFieldNumber):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldNumber`")
        else:
            match += 1
        # validate data type: ExtFormFieldPassword
        if not isinstance(v, ExtFormFieldPassword):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldPassword`")
        else:
            match += 1
        # validate data type: ExtFormFieldSelect
        if not isinstance(v, ExtFormFieldSelect):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldSelect`")
        else:
            match += 1
        # validate data type: ExtFormFieldSlider
        if not isinstance(v, ExtFormFieldSlider):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldSlider`")
        else:
            match += 1
        # validate data type: ExtFormFieldText
        if not isinstance(v, ExtFormFieldText):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldText`")
        else:
            match += 1
        # validate data type: ExtFormFieldTextarea
        if not isinstance(v, ExtFormFieldTextarea):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldTextarea`")
        else:
            match += 1
        # validate data type: ExtFormFieldUnknown
        if not isinstance(v, ExtFormFieldUnknown):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ExtFormFieldUnknown`")
        else:
            match += 1
        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when setting `actual_instance` in IntegrationFieldsFormDtoDefaultProjectFieldsInner with oneOf schemas: ExtFormFieldCheckbox, ExtFormFieldComposite, ExtFormFieldExternalSelect, ExtFormFieldFormChoice, ExtFormFieldList, ExtFormFieldNumber, ExtFormFieldPassword, ExtFormFieldSelect, ExtFormFieldSlider, ExtFormFieldText, ExtFormFieldTextarea, ExtFormFieldUnknown. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when setting `actual_instance` in IntegrationFieldsFormDtoDefaultProjectFieldsInner with oneOf schemas: ExtFormFieldCheckbox, ExtFormFieldComposite, ExtFormFieldExternalSelect, ExtFormFieldFormChoice, ExtFormFieldList, ExtFormFieldNumber, ExtFormFieldPassword, ExtFormFieldSelect, ExtFormFieldSlider, ExtFormFieldText, ExtFormFieldTextarea, ExtFormFieldUnknown. 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 ExtFormFieldCheckbox
        try:
            instance.actual_instance = ExtFormFieldCheckbox.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldComposite
        try:
            instance.actual_instance = ExtFormFieldComposite.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldExternalSelect
        try:
            instance.actual_instance = ExtFormFieldExternalSelect.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldFormChoice
        try:
            instance.actual_instance = ExtFormFieldFormChoice.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldList
        try:
            instance.actual_instance = ExtFormFieldList.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldNumber
        try:
            instance.actual_instance = ExtFormFieldNumber.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldPassword
        try:
            instance.actual_instance = ExtFormFieldPassword.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldSelect
        try:
            instance.actual_instance = ExtFormFieldSelect.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldSlider
        try:
            instance.actual_instance = ExtFormFieldSlider.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldText
        try:
            instance.actual_instance = ExtFormFieldText.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldTextarea
        try:
            instance.actual_instance = ExtFormFieldTextarea.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ExtFormFieldUnknown
        try:
            instance.actual_instance = ExtFormFieldUnknown.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 IntegrationFieldsFormDtoDefaultProjectFieldsInner with oneOf schemas: ExtFormFieldCheckbox, ExtFormFieldComposite, ExtFormFieldExternalSelect, ExtFormFieldFormChoice, ExtFormFieldList, ExtFormFieldNumber, ExtFormFieldPassword, ExtFormFieldSelect, ExtFormFieldSlider, ExtFormFieldText, ExtFormFieldTextarea, ExtFormFieldUnknown. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when deserializing the JSON string into IntegrationFieldsFormDtoDefaultProjectFieldsInner with oneOf schemas: ExtFormFieldCheckbox, ExtFormFieldComposite, ExtFormFieldExternalSelect, ExtFormFieldFormChoice, ExtFormFieldList, ExtFormFieldNumber, ExtFormFieldPassword, ExtFormFieldSelect, ExtFormFieldSlider, ExtFormFieldText, ExtFormFieldTextarea, ExtFormFieldUnknown. 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], ExtFormFieldCheckbox, ExtFormFieldComposite, ExtFormFieldExternalSelect, ExtFormFieldFormChoice, ExtFormFieldList, ExtFormFieldNumber, ExtFormFieldPassword, ExtFormFieldSelect, ExtFormFieldSlider, ExtFormFieldText, ExtFormFieldTextarea, ExtFormFieldUnknown]]:
        """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())


