"""
Pydantic Models for CMDB - switch_controller/lldp_settings

Runtime validation models for switch_controller/lldp_settings 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 LldpSettingsModel(BaseModel):
    """
    Pydantic model for switch_controller/lldp_settings configuration.
    
    Configure FortiSwitch LLDP settings.
    
    Validation Rules:        - tx_hold: min=1 max=16 pattern=        - tx_interval: min=5 max=4095 pattern=        - fast_start_interval: min=0 max=255 pattern=        - management_interface: pattern=        - device_detection: 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
    # ========================================================================
    
    tx_hold: int | None = Field(ge=1, le=16, default=4, description="Number of tx-intervals before local LLDP data expires (1 - 16, default = 4). Packet TTL is tx-hold * tx-interval.")    
    tx_interval: int | None = Field(ge=5, le=4095, default=30, description="Frequency of LLDP PDU transmission from FortiSwitch (5 - 4095 sec, default = 30). Packet TTL is tx-hold * tx-interval.")    
    fast_start_interval: int | None = Field(ge=0, le=255, default=2, description="Frequency of LLDP PDU transmission from FortiSwitch for the first 4 packets when the link is up (2 - 5 sec, default = 2, 0 = disable fast start).")    
    management_interface: Literal["internal", "mgmt"] | None = Field(default="internal", description="Primary management interface to be advertised in LLDP and CDP PDUs.")    
    device_detection: Literal["disable", "enable"] | None = Field(default="enable", description="Enable/disable dynamic detection of LLDP neighbor devices for VLAN assignment.")    
    # ========================================================================
    # 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]) -> "LldpSettingsModel":
        """
        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__ = [
    "LldpSettingsModel",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.0
# Generated: 2026-01-17T17:56:12.290784Z
# ============================================================================