# coding: utf-8

"""
    Kanidm

    API for interacting with the Kanidm system. This is a work in progress.

    The version of the OpenAPI document: 1.9.0-dev
    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 kanidm_openapi_client.models.consistency_error_one_of import ConsistencyErrorOneOf
from kanidm_openapi_client.models.consistency_error_one_of1 import ConsistencyErrorOneOf1
from kanidm_openapi_client.models.consistency_error_one_of10 import ConsistencyErrorOneOf10
from kanidm_openapi_client.models.consistency_error_one_of11 import ConsistencyErrorOneOf11
from kanidm_openapi_client.models.consistency_error_one_of12 import ConsistencyErrorOneOf12
from kanidm_openapi_client.models.consistency_error_one_of13 import ConsistencyErrorOneOf13
from kanidm_openapi_client.models.consistency_error_one_of14 import ConsistencyErrorOneOf14
from kanidm_openapi_client.models.consistency_error_one_of15 import ConsistencyErrorOneOf15
from kanidm_openapi_client.models.consistency_error_one_of16 import ConsistencyErrorOneOf16
from kanidm_openapi_client.models.consistency_error_one_of2 import ConsistencyErrorOneOf2
from kanidm_openapi_client.models.consistency_error_one_of3 import ConsistencyErrorOneOf3
from kanidm_openapi_client.models.consistency_error_one_of4 import ConsistencyErrorOneOf4
from kanidm_openapi_client.models.consistency_error_one_of5 import ConsistencyErrorOneOf5
from kanidm_openapi_client.models.consistency_error_one_of6 import ConsistencyErrorOneOf6
from kanidm_openapi_client.models.consistency_error_one_of7 import ConsistencyErrorOneOf7
from kanidm_openapi_client.models.consistency_error_one_of8 import ConsistencyErrorOneOf8
from kanidm_openapi_client.models.consistency_error_one_of9 import ConsistencyErrorOneOf9
from pydantic import StrictStr, Field
from typing import Union, List, Set, Optional, Dict
from typing_extensions import Literal, Self

CONSISTENCYERROR_ONE_OF_SCHEMAS = ["ConsistencyErrorOneOf", "ConsistencyErrorOneOf1", "ConsistencyErrorOneOf10", "ConsistencyErrorOneOf11", "ConsistencyErrorOneOf12", "ConsistencyErrorOneOf13", "ConsistencyErrorOneOf14", "ConsistencyErrorOneOf15", "ConsistencyErrorOneOf16", "ConsistencyErrorOneOf2", "ConsistencyErrorOneOf3", "ConsistencyErrorOneOf4", "ConsistencyErrorOneOf5", "ConsistencyErrorOneOf6", "ConsistencyErrorOneOf7", "ConsistencyErrorOneOf8", "ConsistencyErrorOneOf9", "str"]

class ConsistencyError(BaseModel):
    """
    ConsistencyError
    """
    # data type: str
    oneof_schema_1_validator: Optional[StrictStr] = None
    # data type: ConsistencyErrorOneOf
    oneof_schema_2_validator: Optional[ConsistencyErrorOneOf] = None
    # data type: ConsistencyErrorOneOf1
    oneof_schema_3_validator: Optional[ConsistencyErrorOneOf1] = None
    # data type: ConsistencyErrorOneOf2
    oneof_schema_4_validator: Optional[ConsistencyErrorOneOf2] = None
    # data type: str
    oneof_schema_5_validator: Optional[StrictStr] = None
    # data type: ConsistencyErrorOneOf3
    oneof_schema_6_validator: Optional[ConsistencyErrorOneOf3] = None
    # data type: ConsistencyErrorOneOf4
    oneof_schema_7_validator: Optional[ConsistencyErrorOneOf4] = None
    # data type: ConsistencyErrorOneOf5
    oneof_schema_8_validator: Optional[ConsistencyErrorOneOf5] = None
    # data type: ConsistencyErrorOneOf6
    oneof_schema_9_validator: Optional[ConsistencyErrorOneOf6] = None
    # data type: ConsistencyErrorOneOf7
    oneof_schema_10_validator: Optional[ConsistencyErrorOneOf7] = None
    # data type: ConsistencyErrorOneOf8
    oneof_schema_11_validator: Optional[ConsistencyErrorOneOf8] = None
    # data type: str
    oneof_schema_12_validator: Optional[StrictStr] = None
    # data type: ConsistencyErrorOneOf9
    oneof_schema_13_validator: Optional[ConsistencyErrorOneOf9] = None
    # data type: str
    oneof_schema_14_validator: Optional[StrictStr] = None
    # data type: str
    oneof_schema_15_validator: Optional[StrictStr] = None
    # data type: str
    oneof_schema_16_validator: Optional[StrictStr] = None
    # data type: ConsistencyErrorOneOf10
    oneof_schema_17_validator: Optional[ConsistencyErrorOneOf10] = None
    # data type: ConsistencyErrorOneOf11
    oneof_schema_18_validator: Optional[ConsistencyErrorOneOf11] = None
    # data type: ConsistencyErrorOneOf12
    oneof_schema_19_validator: Optional[ConsistencyErrorOneOf12] = None
    # data type: ConsistencyErrorOneOf13
    oneof_schema_20_validator: Optional[ConsistencyErrorOneOf13] = None
    # data type: ConsistencyErrorOneOf14
    oneof_schema_21_validator: Optional[ConsistencyErrorOneOf14] = None
    # data type: ConsistencyErrorOneOf15
    oneof_schema_22_validator: Optional[ConsistencyErrorOneOf15] = None
    # data type: ConsistencyErrorOneOf16
    oneof_schema_23_validator: Optional[ConsistencyErrorOneOf16] = None
    actual_instance: Optional[Union[ConsistencyErrorOneOf, ConsistencyErrorOneOf1, ConsistencyErrorOneOf10, ConsistencyErrorOneOf11, ConsistencyErrorOneOf12, ConsistencyErrorOneOf13, ConsistencyErrorOneOf14, ConsistencyErrorOneOf15, ConsistencyErrorOneOf16, ConsistencyErrorOneOf2, ConsistencyErrorOneOf3, ConsistencyErrorOneOf4, ConsistencyErrorOneOf5, ConsistencyErrorOneOf6, ConsistencyErrorOneOf7, ConsistencyErrorOneOf8, ConsistencyErrorOneOf9, str]] = None
    one_of_schemas: Set[str] = { "ConsistencyErrorOneOf", "ConsistencyErrorOneOf1", "ConsistencyErrorOneOf10", "ConsistencyErrorOneOf11", "ConsistencyErrorOneOf12", "ConsistencyErrorOneOf13", "ConsistencyErrorOneOf14", "ConsistencyErrorOneOf15", "ConsistencyErrorOneOf16", "ConsistencyErrorOneOf2", "ConsistencyErrorOneOf3", "ConsistencyErrorOneOf4", "ConsistencyErrorOneOf5", "ConsistencyErrorOneOf6", "ConsistencyErrorOneOf7", "ConsistencyErrorOneOf8", "ConsistencyErrorOneOf9", "str" }

    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 = ConsistencyError.model_construct()
        error_messages = []
        match = 0
        # validate data type: str
        try:
            instance.oneof_schema_1_validator = v
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # validate data type: ConsistencyErrorOneOf
        if not isinstance(v, ConsistencyErrorOneOf):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf1
        if not isinstance(v, ConsistencyErrorOneOf1):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf1`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf2
        if not isinstance(v, ConsistencyErrorOneOf2):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf2`")
        else:
            match += 1
        # validate data type: str
        try:
            instance.oneof_schema_5_validator = v
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # validate data type: ConsistencyErrorOneOf3
        if not isinstance(v, ConsistencyErrorOneOf3):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf3`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf4
        if not isinstance(v, ConsistencyErrorOneOf4):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf4`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf5
        if not isinstance(v, ConsistencyErrorOneOf5):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf5`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf6
        if not isinstance(v, ConsistencyErrorOneOf6):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf6`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf7
        if not isinstance(v, ConsistencyErrorOneOf7):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf7`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf8
        if not isinstance(v, ConsistencyErrorOneOf8):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf8`")
        else:
            match += 1
        # validate data type: str
        try:
            instance.oneof_schema_12_validator = v
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # validate data type: ConsistencyErrorOneOf9
        if not isinstance(v, ConsistencyErrorOneOf9):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf9`")
        else:
            match += 1
        # validate data type: str
        try:
            instance.oneof_schema_14_validator = v
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # validate data type: str
        try:
            instance.oneof_schema_15_validator = v
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # validate data type: str
        try:
            instance.oneof_schema_16_validator = v
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # validate data type: ConsistencyErrorOneOf10
        if not isinstance(v, ConsistencyErrorOneOf10):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf10`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf11
        if not isinstance(v, ConsistencyErrorOneOf11):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf11`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf12
        if not isinstance(v, ConsistencyErrorOneOf12):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf12`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf13
        if not isinstance(v, ConsistencyErrorOneOf13):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf13`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf14
        if not isinstance(v, ConsistencyErrorOneOf14):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf14`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf15
        if not isinstance(v, ConsistencyErrorOneOf15):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf15`")
        else:
            match += 1
        # validate data type: ConsistencyErrorOneOf16
        if not isinstance(v, ConsistencyErrorOneOf16):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ConsistencyErrorOneOf16`")
        else:
            match += 1
        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when setting `actual_instance` in ConsistencyError with oneOf schemas: ConsistencyErrorOneOf, ConsistencyErrorOneOf1, ConsistencyErrorOneOf10, ConsistencyErrorOneOf11, ConsistencyErrorOneOf12, ConsistencyErrorOneOf13, ConsistencyErrorOneOf14, ConsistencyErrorOneOf15, ConsistencyErrorOneOf16, ConsistencyErrorOneOf2, ConsistencyErrorOneOf3, ConsistencyErrorOneOf4, ConsistencyErrorOneOf5, ConsistencyErrorOneOf6, ConsistencyErrorOneOf7, ConsistencyErrorOneOf8, ConsistencyErrorOneOf9, str. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when setting `actual_instance` in ConsistencyError with oneOf schemas: ConsistencyErrorOneOf, ConsistencyErrorOneOf1, ConsistencyErrorOneOf10, ConsistencyErrorOneOf11, ConsistencyErrorOneOf12, ConsistencyErrorOneOf13, ConsistencyErrorOneOf14, ConsistencyErrorOneOf15, ConsistencyErrorOneOf16, ConsistencyErrorOneOf2, ConsistencyErrorOneOf3, ConsistencyErrorOneOf4, ConsistencyErrorOneOf5, ConsistencyErrorOneOf6, ConsistencyErrorOneOf7, ConsistencyErrorOneOf8, ConsistencyErrorOneOf9, str. 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 str
        try:
            # validation
            instance.oneof_schema_1_validator = json.loads(json_str)
            # assign value to actual_instance
            instance.actual_instance = instance.oneof_schema_1_validator
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf
        try:
            instance.actual_instance = ConsistencyErrorOneOf.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf1
        try:
            instance.actual_instance = ConsistencyErrorOneOf1.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf2
        try:
            instance.actual_instance = ConsistencyErrorOneOf2.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into str
        try:
            # validation
            instance.oneof_schema_5_validator = json.loads(json_str)
            # assign value to actual_instance
            instance.actual_instance = instance.oneof_schema_5_validator
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf3
        try:
            instance.actual_instance = ConsistencyErrorOneOf3.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf4
        try:
            instance.actual_instance = ConsistencyErrorOneOf4.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf5
        try:
            instance.actual_instance = ConsistencyErrorOneOf5.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf6
        try:
            instance.actual_instance = ConsistencyErrorOneOf6.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf7
        try:
            instance.actual_instance = ConsistencyErrorOneOf7.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf8
        try:
            instance.actual_instance = ConsistencyErrorOneOf8.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into str
        try:
            # validation
            instance.oneof_schema_12_validator = json.loads(json_str)
            # assign value to actual_instance
            instance.actual_instance = instance.oneof_schema_12_validator
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf9
        try:
            instance.actual_instance = ConsistencyErrorOneOf9.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into str
        try:
            # validation
            instance.oneof_schema_14_validator = json.loads(json_str)
            # assign value to actual_instance
            instance.actual_instance = instance.oneof_schema_14_validator
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into str
        try:
            # validation
            instance.oneof_schema_15_validator = json.loads(json_str)
            # assign value to actual_instance
            instance.actual_instance = instance.oneof_schema_15_validator
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into str
        try:
            # validation
            instance.oneof_schema_16_validator = json.loads(json_str)
            # assign value to actual_instance
            instance.actual_instance = instance.oneof_schema_16_validator
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf10
        try:
            instance.actual_instance = ConsistencyErrorOneOf10.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf11
        try:
            instance.actual_instance = ConsistencyErrorOneOf11.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf12
        try:
            instance.actual_instance = ConsistencyErrorOneOf12.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf13
        try:
            instance.actual_instance = ConsistencyErrorOneOf13.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf14
        try:
            instance.actual_instance = ConsistencyErrorOneOf14.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf15
        try:
            instance.actual_instance = ConsistencyErrorOneOf15.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into ConsistencyErrorOneOf16
        try:
            instance.actual_instance = ConsistencyErrorOneOf16.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 ConsistencyError with oneOf schemas: ConsistencyErrorOneOf, ConsistencyErrorOneOf1, ConsistencyErrorOneOf10, ConsistencyErrorOneOf11, ConsistencyErrorOneOf12, ConsistencyErrorOneOf13, ConsistencyErrorOneOf14, ConsistencyErrorOneOf15, ConsistencyErrorOneOf16, ConsistencyErrorOneOf2, ConsistencyErrorOneOf3, ConsistencyErrorOneOf4, ConsistencyErrorOneOf5, ConsistencyErrorOneOf6, ConsistencyErrorOneOf7, ConsistencyErrorOneOf8, ConsistencyErrorOneOf9, str. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when deserializing the JSON string into ConsistencyError with oneOf schemas: ConsistencyErrorOneOf, ConsistencyErrorOneOf1, ConsistencyErrorOneOf10, ConsistencyErrorOneOf11, ConsistencyErrorOneOf12, ConsistencyErrorOneOf13, ConsistencyErrorOneOf14, ConsistencyErrorOneOf15, ConsistencyErrorOneOf16, ConsistencyErrorOneOf2, ConsistencyErrorOneOf3, ConsistencyErrorOneOf4, ConsistencyErrorOneOf5, ConsistencyErrorOneOf6, ConsistencyErrorOneOf7, ConsistencyErrorOneOf8, ConsistencyErrorOneOf9, str. 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], ConsistencyErrorOneOf, ConsistencyErrorOneOf1, ConsistencyErrorOneOf10, ConsistencyErrorOneOf11, ConsistencyErrorOneOf12, ConsistencyErrorOneOf13, ConsistencyErrorOneOf14, ConsistencyErrorOneOf15, ConsistencyErrorOneOf16, ConsistencyErrorOneOf2, ConsistencyErrorOneOf3, ConsistencyErrorOneOf4, ConsistencyErrorOneOf5, ConsistencyErrorOneOf6, ConsistencyErrorOneOf7, ConsistencyErrorOneOf8, ConsistencyErrorOneOf9, str]]:
        """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())


