"""
Pydantic Models for CMDB - system/session_helper

Runtime validation models for system/session_helper configuration.
Generated from FortiOS schema version unknown.
"""

from __future__ import annotations

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

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

class SessionHelperNameEnum(str, Enum):
    """Allowed values for name field."""
    FTP = "ftp"
    TFTP = "tftp"
    RAS = "ras"
    H323 = "h323"
    TNS = "tns"
    MMS = "mms"
    SIP = "sip"
    PPTP = "pptp"
    RTSP = "rtsp"
    DNS_UDP = "dns-udp"
    DNS_TCP = "dns-tcp"
    PMAP = "pmap"
    RSH = "rsh"
    DCERPC = "dcerpc"
    MGCP = "mgcp"


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

class SessionHelperModel(BaseModel):
    """
    Pydantic model for system/session_helper configuration.
    
    Configure session helper.
    
    Validation Rules:        - id_: min=0 max=4294967295 pattern=        - name: pattern=        - protocol: min=0 max=255 pattern=        - port: min=1 max=65535 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
    # ========================================================================
    
    id_: int | None = Field(ge=0, le=4294967295, default=0, serialization_alias="id", description="Session helper ID.")    
    name: SessionHelperNameEnum = Field(description="Helper name.")    
    protocol: int = Field(ge=0, le=255, default=0, description="Protocol number.")    
    port: int = Field(ge=1, le=65535, default=0, description="Protocol port.")    
    # ========================================================================
    # 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]) -> "SessionHelperModel":
        """
        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__ = [
    "SessionHelperModel",]


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