"""
Pydantic Models for CMDB - webfilter/ips_urlfilter_cache_setting

Runtime validation models for webfilter/ips_urlfilter_cache_setting configuration.
Generated from FortiOS schema version unknown.
"""

from __future__ import annotations

from pydantic import BaseModel, Field
from typing import Any, Optional

# ============================================================================
# Enum Definitions (for fields with 4+ allowed values)
# ============================================================================


# ============================================================================
# Main Model
# ============================================================================

class IpsUrlfilterCacheSettingModel(BaseModel):
    """
    Pydantic model for webfilter/ips_urlfilter_cache_setting configuration.
    
    Configure IPS URL filter cache settings.
    
    Validation Rules:        - dns_retry_interval: min=0 max=2147483 pattern=        - extended_ttl: min=0 max=2147483 pattern=    """
    
    class Config:
        """Pydantic model configuration."""
        extra = "allow"  # Allow additional fields from API
        str_strip_whitespace = True
        validate_assignment = True  # Validate on attribute assignment
        use_enum_values = True  # Use enum values instead of names
    
    # ========================================================================
    # Model Fields
    # ========================================================================
    
    dns_retry_interval: int | None = Field(ge=0, le=2147483, default=0, description="Retry interval. Refresh DNS faster than TTL to capture multiple IPs for hosts. 0 means use DNS server's TTL only.")    
    extended_ttl: int | None = Field(ge=0, le=2147483, default=0, description="Extend time to live beyond reported by DNS. Use of 0 means use DNS server's TTL.")    
    # ========================================================================
    # Custom Validators
    # ========================================================================
    
    # ========================================================================
    # Helper Methods
    # ========================================================================
    
    def to_fortios_dict(self) -> dict[str, Any]:
        """
        Convert model to FortiOS API payload format.
        
        Returns:
            Dict suitable for POST/PUT operations
        """
        # Export with exclude_none to avoid sending null values
        return self.model_dump(exclude_none=True, by_alias=True)
    
    @classmethod
    def from_fortios_response(cls, data: dict[str, Any]) -> "IpsUrlfilterCacheSettingModel":
        """
        Create model instance from FortiOS API response.
        
        Args:
            data: Response data from API
            
        Returns:
            Validated model instance
        """
        return cls(**data)

# ============================================================================
# Type Aliases for Convenience
# ============================================================================

Dict = dict[str, Any]  # For backward compatibility

# ============================================================================
# Module Exports
# ============================================================================

__all__ = [
    "IpsUrlfilterCacheSettingModel",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.2
# Generated: 2026-01-21T16:23:59.661100Z
# ============================================================================