"""
Pydantic Models for CMDB - switch_controller/igmp_snooping

Runtime validation models for switch_controller/igmp_snooping configuration.
Generated from FortiOS schema version unknown.
"""

from __future__ import annotations

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

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


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

class IgmpSnoopingModel(BaseModel):
    """
    Pydantic model for switch_controller/igmp_snooping configuration.
    
    Configure FortiSwitch IGMP snooping global settings.
    
    Validation Rules:        - aging_time: min=15 max=3600 pattern=        - flood_unknown_multicast: pattern=        - query_interval: min=10 max=1200 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
    # ========================================================================
    
    aging_time: int | None = Field(ge=15, le=3600, default=300, description="Maximum number of seconds to retain a multicast snooping entry for which no packets have been seen (15 - 3600 sec, default = 300).")    
    flood_unknown_multicast: Literal["enable", "disable"] | None = Field(default="disable", description="Enable/disable unknown multicast flooding.")    
    query_interval: int | None = Field(ge=10, le=1200, default=125, description="Maximum time after which IGMP query will be sent (10 - 1200 sec, default = 125).")    
    # ========================================================================
    # 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]) -> "IgmpSnoopingModel":
        """
        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__ = [
    "IgmpSnoopingModel",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.1
# Generated: 2026-01-18T20:31:28.173346Z
# ============================================================================