"""
Pydantic Models for CMDB - ips/settings

Runtime validation models for ips/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 SettingsModel(BaseModel):
    """
    Pydantic model for ips/settings configuration.
    
    Configure IPS VDOM parameter.
    
    Validation Rules:        - packet_log_history: min=1 max=255 pattern=        - packet_log_post_attack: min=0 max=255 pattern=        - packet_log_memory: min=64 max=8192 pattern=        - ips_packet_quota: min=0 max=4294967295 pattern=        - proxy_inline_ips: pattern=        - ha_session_pickup: 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
    # ========================================================================
    
    packet_log_history: int | None = Field(ge=1, le=255, default=1, description="Number of packets to capture before and including the one in which the IPS signature is detected (1 - 255).")    
    packet_log_post_attack: int | None = Field(ge=0, le=255, default=0, description="Number of packets to log after the IPS signature is detected (0 - 255).")    
    packet_log_memory: int | None = Field(ge=64, le=8192, default=256, description="Maximum memory can be used by packet log (64 - 8192 kB).")    
    ips_packet_quota: int | None = Field(ge=0, le=4294967295, default=0, description="Maximum amount of disk space in MB for logged packets when logging to disk. Range depends on disk size.")    
    proxy_inline_ips: Literal["disable", "enable"] | None = Field(default="enable", description="Enable/disable proxy-mode policy inline IPS support.")    
    ha_session_pickup: Literal["connectivity", "security"] | None = Field(default="connectivity", description="IPS HA failover session pickup preference.")    
    # ========================================================================
    # 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]) -> "SettingsModel":
        """
        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__ = [
    "SettingsModel",]


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