# coding: utf-8

"""
    Pinterest REST API

    Pinterest's REST API

    The version of the OpenAPI document: 5.23.0
    Contact: blah+oapicf@cliffano.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
from inspect import getfullargspec
import json
import pprint
import re  # noqa: F401
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
from typing import Optional
from pinterestsdk.models.creative_assets_id_filter import CreativeAssetsIdFilter
from pinterestsdk.models.custom_label0_filter import CustomLabel0Filter
from pinterestsdk.models.custom_label1_filter import CustomLabel1Filter
from pinterestsdk.models.custom_label2_filter import CustomLabel2Filter
from pinterestsdk.models.custom_label3_filter import CustomLabel3Filter
from pinterestsdk.models.custom_label4_filter import CustomLabel4Filter
from pinterestsdk.models.google_product_category0_filter import GoogleProductCategory0Filter
from pinterestsdk.models.google_product_category1_filter import GoogleProductCategory1Filter
from pinterestsdk.models.google_product_category2_filter import GoogleProductCategory2Filter
from pinterestsdk.models.google_product_category3_filter import GoogleProductCategory3Filter
from pinterestsdk.models.google_product_category4_filter import GoogleProductCategory4Filter
from pinterestsdk.models.google_product_category5_filter import GoogleProductCategory5Filter
from pinterestsdk.models.google_product_category6_filter import GoogleProductCategory6Filter
from pinterestsdk.models.media_type_filter import MediaTypeFilter
from pinterestsdk.models.title_keywords_filter import TitleKeywordsFilter
from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
from typing_extensions import Literal, Self
from pydantic import Field

CATALOGSCREATIVEASSETSPRODUCTGROUPFILTERKEYS_ANY_OF_SCHEMAS = ["CreativeAssetsIdFilter", "CustomLabel0Filter", "CustomLabel1Filter", "CustomLabel2Filter", "CustomLabel3Filter", "CustomLabel4Filter", "GoogleProductCategory0Filter", "GoogleProductCategory1Filter", "GoogleProductCategory2Filter", "GoogleProductCategory3Filter", "GoogleProductCategory4Filter", "GoogleProductCategory5Filter", "GoogleProductCategory6Filter", "MediaTypeFilter", "TitleKeywordsFilter"]

class CatalogsCreativeAssetsProductGroupFilterKeys(BaseModel):
    """
    CatalogsCreativeAssetsProductGroupFilterKeys
    """

    # data type: CreativeAssetsIdFilter
    anyof_schema_1_validator: Optional[CreativeAssetsIdFilter] = None
    # data type: CustomLabel0Filter
    anyof_schema_2_validator: Optional[CustomLabel0Filter] = None
    # data type: CustomLabel1Filter
    anyof_schema_3_validator: Optional[CustomLabel1Filter] = None
    # data type: CustomLabel2Filter
    anyof_schema_4_validator: Optional[CustomLabel2Filter] = None
    # data type: CustomLabel3Filter
    anyof_schema_5_validator: Optional[CustomLabel3Filter] = None
    # data type: CustomLabel4Filter
    anyof_schema_6_validator: Optional[CustomLabel4Filter] = None
    # data type: GoogleProductCategory6Filter
    anyof_schema_7_validator: Optional[GoogleProductCategory6Filter] = None
    # data type: GoogleProductCategory5Filter
    anyof_schema_8_validator: Optional[GoogleProductCategory5Filter] = None
    # data type: GoogleProductCategory4Filter
    anyof_schema_9_validator: Optional[GoogleProductCategory4Filter] = None
    # data type: GoogleProductCategory3Filter
    anyof_schema_10_validator: Optional[GoogleProductCategory3Filter] = None
    # data type: GoogleProductCategory2Filter
    anyof_schema_11_validator: Optional[GoogleProductCategory2Filter] = None
    # data type: GoogleProductCategory1Filter
    anyof_schema_12_validator: Optional[GoogleProductCategory1Filter] = None
    # data type: GoogleProductCategory0Filter
    anyof_schema_13_validator: Optional[GoogleProductCategory0Filter] = None
    # data type: MediaTypeFilter
    anyof_schema_14_validator: Optional[MediaTypeFilter] = None
    # data type: TitleKeywordsFilter
    anyof_schema_15_validator: Optional[TitleKeywordsFilter] = None
    if TYPE_CHECKING:
        actual_instance: Optional[Union[CreativeAssetsIdFilter, CustomLabel0Filter, CustomLabel1Filter, CustomLabel2Filter, CustomLabel3Filter, CustomLabel4Filter, GoogleProductCategory0Filter, GoogleProductCategory1Filter, GoogleProductCategory2Filter, GoogleProductCategory3Filter, GoogleProductCategory4Filter, GoogleProductCategory5Filter, GoogleProductCategory6Filter, MediaTypeFilter, TitleKeywordsFilter]] = None
    else:
        actual_instance: Any = None
    any_of_schemas: Set[str] = { "CreativeAssetsIdFilter", "CustomLabel0Filter", "CustomLabel1Filter", "CustomLabel2Filter", "CustomLabel3Filter", "CustomLabel4Filter", "GoogleProductCategory0Filter", "GoogleProductCategory1Filter", "GoogleProductCategory2Filter", "GoogleProductCategory3Filter", "GoogleProductCategory4Filter", "GoogleProductCategory5Filter", "GoogleProductCategory6Filter", "MediaTypeFilter", "TitleKeywordsFilter" }

    model_config = {
        "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_anyof(cls, v):
        instance = CatalogsCreativeAssetsProductGroupFilterKeys.model_construct()
        error_messages = []
        # validate data type: CreativeAssetsIdFilter
        if not isinstance(v, CreativeAssetsIdFilter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `CreativeAssetsIdFilter`")
        else:
            return v

        # validate data type: CustomLabel0Filter
        if not isinstance(v, CustomLabel0Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `CustomLabel0Filter`")
        else:
            return v

        # validate data type: CustomLabel1Filter
        if not isinstance(v, CustomLabel1Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `CustomLabel1Filter`")
        else:
            return v

        # validate data type: CustomLabel2Filter
        if not isinstance(v, CustomLabel2Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `CustomLabel2Filter`")
        else:
            return v

        # validate data type: CustomLabel3Filter
        if not isinstance(v, CustomLabel3Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `CustomLabel3Filter`")
        else:
            return v

        # validate data type: CustomLabel4Filter
        if not isinstance(v, CustomLabel4Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `CustomLabel4Filter`")
        else:
            return v

        # validate data type: GoogleProductCategory6Filter
        if not isinstance(v, GoogleProductCategory6Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GoogleProductCategory6Filter`")
        else:
            return v

        # validate data type: GoogleProductCategory5Filter
        if not isinstance(v, GoogleProductCategory5Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GoogleProductCategory5Filter`")
        else:
            return v

        # validate data type: GoogleProductCategory4Filter
        if not isinstance(v, GoogleProductCategory4Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GoogleProductCategory4Filter`")
        else:
            return v

        # validate data type: GoogleProductCategory3Filter
        if not isinstance(v, GoogleProductCategory3Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GoogleProductCategory3Filter`")
        else:
            return v

        # validate data type: GoogleProductCategory2Filter
        if not isinstance(v, GoogleProductCategory2Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GoogleProductCategory2Filter`")
        else:
            return v

        # validate data type: GoogleProductCategory1Filter
        if not isinstance(v, GoogleProductCategory1Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GoogleProductCategory1Filter`")
        else:
            return v

        # validate data type: GoogleProductCategory0Filter
        if not isinstance(v, GoogleProductCategory0Filter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GoogleProductCategory0Filter`")
        else:
            return v

        # validate data type: MediaTypeFilter
        if not isinstance(v, MediaTypeFilter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `MediaTypeFilter`")
        else:
            return v

        # validate data type: TitleKeywordsFilter
        if not isinstance(v, TitleKeywordsFilter):
            error_messages.append(f"Error! Input type `{type(v)}` is not `TitleKeywordsFilter`")
        else:
            return v

        if error_messages:
            # no match
            raise ValueError("No match found when setting the actual_instance in CatalogsCreativeAssetsProductGroupFilterKeys with anyOf schemas: CreativeAssetsIdFilter, CustomLabel0Filter, CustomLabel1Filter, CustomLabel2Filter, CustomLabel3Filter, CustomLabel4Filter, GoogleProductCategory0Filter, GoogleProductCategory1Filter, GoogleProductCategory2Filter, GoogleProductCategory3Filter, GoogleProductCategory4Filter, GoogleProductCategory5Filter, GoogleProductCategory6Filter, MediaTypeFilter, TitleKeywordsFilter. Details: " + ", ".join(error_messages))
        else:
            return v

    @classmethod
    def from_dict(cls, obj: 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 = []
        # anyof_schema_1_validator: Optional[CreativeAssetsIdFilter] = None
        try:
            instance.actual_instance = CreativeAssetsIdFilter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_2_validator: Optional[CustomLabel0Filter] = None
        try:
            instance.actual_instance = CustomLabel0Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_3_validator: Optional[CustomLabel1Filter] = None
        try:
            instance.actual_instance = CustomLabel1Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_4_validator: Optional[CustomLabel2Filter] = None
        try:
            instance.actual_instance = CustomLabel2Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_5_validator: Optional[CustomLabel3Filter] = None
        try:
            instance.actual_instance = CustomLabel3Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_6_validator: Optional[CustomLabel4Filter] = None
        try:
            instance.actual_instance = CustomLabel4Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_7_validator: Optional[GoogleProductCategory6Filter] = None
        try:
            instance.actual_instance = GoogleProductCategory6Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_8_validator: Optional[GoogleProductCategory5Filter] = None
        try:
            instance.actual_instance = GoogleProductCategory5Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_9_validator: Optional[GoogleProductCategory4Filter] = None
        try:
            instance.actual_instance = GoogleProductCategory4Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_10_validator: Optional[GoogleProductCategory3Filter] = None
        try:
            instance.actual_instance = GoogleProductCategory3Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_11_validator: Optional[GoogleProductCategory2Filter] = None
        try:
            instance.actual_instance = GoogleProductCategory2Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_12_validator: Optional[GoogleProductCategory1Filter] = None
        try:
            instance.actual_instance = GoogleProductCategory1Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_13_validator: Optional[GoogleProductCategory0Filter] = None
        try:
            instance.actual_instance = GoogleProductCategory0Filter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_14_validator: Optional[MediaTypeFilter] = None
        try:
            instance.actual_instance = MediaTypeFilter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_15_validator: Optional[TitleKeywordsFilter] = None
        try:
            instance.actual_instance = TitleKeywordsFilter.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))

        if error_messages:
            # no match
            raise ValueError("No match found when deserializing the JSON string into CatalogsCreativeAssetsProductGroupFilterKeys with anyOf schemas: CreativeAssetsIdFilter, CustomLabel0Filter, CustomLabel1Filter, CustomLabel2Filter, CustomLabel3Filter, CustomLabel4Filter, GoogleProductCategory0Filter, GoogleProductCategory1Filter, GoogleProductCategory2Filter, GoogleProductCategory3Filter, GoogleProductCategory4Filter, GoogleProductCategory5Filter, GoogleProductCategory6Filter, MediaTypeFilter, TitleKeywordsFilter. 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], CreativeAssetsIdFilter, CustomLabel0Filter, CustomLabel1Filter, CustomLabel2Filter, CustomLabel3Filter, CustomLabel4Filter, GoogleProductCategory0Filter, GoogleProductCategory1Filter, GoogleProductCategory2Filter, GoogleProductCategory3Filter, GoogleProductCategory4Filter, GoogleProductCategory5Filter, GoogleProductCategory6Filter, MediaTypeFilter, TitleKeywordsFilter]]:
        """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:
            return self.actual_instance

    def to_str(self) -> str:
        """Returns the string representation of the actual instance"""
        return pprint.pformat(self.model_dump())


