"""
Pydantic Models for CMDB - web_proxy/wisp

Runtime validation models for web_proxy/wisp 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 WispModel(BaseModel):
    """
    Pydantic model for web_proxy/wisp configuration.
    
    Configure Websense Integrated Services Protocol (WISP) servers.
    
    Validation Rules:        - name: max_length=35 pattern=        - comment: max_length=255 pattern=        - outgoing_ip: pattern=        - server_ip: pattern=        - server_port: min=1 max=65535 pattern=        - max_connections: min=4 max=4096 pattern=        - timeout: min=1 max=15 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 = Field(max_length=35, description="Server name.")    
    comment: str | None = Field(max_length=255, default=None, description="Comment.")    
    outgoing_ip: str | None = Field(default="0.0.0.0", description="WISP outgoing IP address.")    
    server_ip: str = Field(default="0.0.0.0", description="WISP server IP address.")    
    server_port: int = Field(ge=1, le=65535, default=15868, description="WISP server port (1 - 65535, default = 15868).")    
    max_connections: int | None = Field(ge=4, le=4096, default=64, description="Maximum number of web proxy WISP connections (4 - 4096, default = 64).")    
    timeout: int | None = Field(ge=1, le=15, default=5, description="Period of time before WISP requests time out (1 - 15 sec, default = 5).")    
    # ========================================================================
    # 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]) -> "WispModel":
        """
        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__ = [
    "WispModel",]


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