"""
Pydantic Models for CMDB - wireless_controller/wag_profile

Runtime validation models for wireless_controller/wag_profile 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 WagProfileModel(BaseModel):
    """
    Pydantic model for wireless_controller/wag_profile configuration.
    
    Configure wireless access gateway (WAG) profiles used for tunnels on AP.
    
    Validation Rules:        - name: max_length=35 pattern=        - comment: max_length=255 pattern=        - tunnel_type: pattern=        - wag_ip: pattern=        - wag_port: min=0 max=65535 pattern=        - ping_interval: min=1 max=65535 pattern=        - ping_number: min=1 max=65535 pattern=        - return_packet_timeout: min=1 max=65535 pattern=        - dhcp_ip_addr: 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
    # ========================================================================
    
    name: str | None = Field(max_length=35, default=None, description="Tunnel profile name.")    
    comment: str | None = Field(max_length=255, default=None, description="Comment.")    
    tunnel_type: Literal["l2tpv3", "gre"] | None = Field(default="l2tpv3", description="Tunnel type.")    
    wag_ip: str | None = Field(default="0.0.0.0", description="IP Address of the wireless access gateway.")    
    wag_port: int | None = Field(ge=0, le=65535, default=1701, description="UDP port of the wireless access gateway.")    
    ping_interval: int | None = Field(ge=1, le=65535, default=1, description="Interval between two tunnel monitoring echo packets (1 - 65535 sec, default = 1).")    
    ping_number: int | None = Field(ge=1, le=65535, default=5, description="Number of the tunnel monitoring echo packets (1 - 65535, default = 5).")    
    return_packet_timeout: int | None = Field(ge=1, le=65535, default=160, description="Window of time for the return packets from the tunnel's remote end (1 - 65535 sec, default = 160).")    
    dhcp_ip_addr: str | None = Field(default="0.0.0.0", description="IP address of the monitoring DHCP request packet sent through the tunnel.")    
    # ========================================================================
    # 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]) -> "WagProfileModel":
        """
        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__ = [
    "WagProfileModel",]


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