# coding: utf-8

"""
    The version of the OpenAPI document: 1.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

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


from __future__ import annotations
import pprint
import re  # noqa: F401
import json
import uuid
from uuid import UUID
from pydantic import StrictStr, ValidationError
from enum import Enum
from datetime import datetime

from pydantic import BaseModel, ConfigDict, Field
from typing import Any, ClassVar, Dict, List
from typing_extensions import Annotated
from uuid import UUID
from pydantic import StrictStr  # Additional import for UUID backward compatibility
from typing import Optional, Set
from typing_extensions import Self

class DeleteMonitoredTokensRequest(BaseModel):
    """
    DeleteMonitoredTokensRequest
    """ # noqa: E501
    token_ids: Annotated[List[UUID], Field(min_length=1)] = Field(description="Token ids to be removed from the monitored tokens list. Once removed, these tokens will no longer be shown by default when fetching wallet balances.", alias="tokenIds")
    __properties: ClassVar[List[str]] = ["tokenIds"]

    def __init__(self, **kwargs):
        if "idempotencyKey" in self.__properties and not kwargs.get("idempotency_key"):
            kwargs["idempotency_key"] = "#REFILL_PLACEHOLDER"

        if "entitySecretCiphertext" in self.__properties and not kwargs.get("entity_secret_ciphertext"):
            kwargs["entity_secret_ciphertext"] = "#REFILL_PLACEHOLDER"
        super().__init__(**kwargs)

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


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        excluded_fields: Set[str] = set([
        ])
        return self.model_dump_json(
            by_alias=True, 
            exclude=excluded_fields,
            exclude_none=True  # Backwards compatible: exclude None values like Pydantic v1
        )

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of DeleteMonitoredTokensRequest from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        
        # Step 1: Get Python-native dict (datetime objects preserved)
        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
            mode='python'  # Preserves datetime objects as-is
        )
        
        # Step 2: Normalize only UUID and Enum objects to strings for v7.0.0 compatibility
        def normalize_for_legacy(obj):
            """Convert UUID and Enum objects to strings while preserving datetime objects"""
            
            if isinstance(obj, Enum):
                return obj.value
            elif isinstance(obj, UUID):
                return str(obj)
            elif isinstance(obj, list):
                return [normalize_for_legacy(item) for item in obj]  # Recursively handle arrays
            elif isinstance(obj, dict):
                return {k: normalize_for_legacy(v) for k, v in obj.items()}  # Recursively handle dicts
            else:
                return obj  # datetime objects and other types preserved as-is
        
        _dict = normalize_for_legacy(_dict)
        return _dict
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of DeleteMonitoredTokensRequest from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        
        
        # Process input data for UUID backward compatibility and Circle auto-fill
        # Use obj directly to reduce template modifications

        # Circle: Pre-validate strict string fields only (targeted approach)
        # Dynamically detect all StrictStr fields from model definition
        # Only validate Circle-specific fields for backward compatibility
        # UUID fields are now handled by conversion in __init__, so no dynamic detection needed
        strict_str_fields = ["idempotencyKey", "entitySecretCiphertext"]

        for key, value in obj.items():
            if value is not None and key in strict_str_fields and not isinstance(value, str):
                # Create a simple validation error message for Pydantic v2
                raise ValidationError.from_exception_data("ValidationError", [
                    {
                        "type": "string_type",
                        "loc": (key,),
                        "msg": f"Input should be a valid string for field '{key}', got {type(value).__name__}: {value}",
                        "input": value,
                    }
                ])
        
        
        # Circle auto-fill logic for missing/null values (matches __init__ behavior)
        # Handle idempotencyKey auto-fill
        if "idempotencyKey" in cls.__properties:
            if obj.get("idempotencyKey") is None:
                obj["idempotencyKey"] = "#REFILL_PLACEHOLDER"
        
        # Handle entitySecretCiphertext auto-fill  
        if "entitySecretCiphertext" in cls.__properties:
            if obj.get("entitySecretCiphertext") is None:
                obj["entitySecretCiphertext"] = "#REFILL_PLACEHOLDER"
        
        _obj = cls.model_validate({
            "tokenIds": obj.get("tokenIds")
        })
        return _obj


