"""
Pydantic Models for CMDB - system/probe_response

Runtime validation models for system/probe_response 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 ProbeResponseModel(BaseModel):
    """
    Pydantic model for system/probe_response configuration.
    
    Configure system probe response.
    
    Validation Rules:        - port: min=1 max=65535 pattern=        - http_probe_value: max_length=1024 pattern=        - ttl_mode: pattern=        - mode: pattern=        - security_mode: pattern=        - password: max_length=128 pattern=        - timeout: min=10 max=3600 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
    # ========================================================================
    
    port: int | None = Field(ge=1, le=65535, default=8008, description="Port number to response.")    
    http_probe_value: str | None = Field(max_length=1024, default="OK", description="Value to respond to the monitoring server.")    
    ttl_mode: Literal["reinit", "decrease", "retain"] | None = Field(default="retain", description="Mode for TWAMP packet TTL modification.")    
    mode: Literal["none", "http-probe", "twamp"] | None = Field(default="none", description="SLA response mode.")    
    security_mode: Literal["none", "authentication"] | None = Field(default="none", description="TWAMP responder security mode.")    
    password: Any = Field(max_length=128, default=None, description="TWAMP responder password in authentication mode.")    
    timeout: int | None = Field(ge=10, le=3600, default=300, description="An inactivity timer for a twamp test session.")    
    # ========================================================================
    # 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]) -> "ProbeResponseModel":
        """
        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__ = [
    "ProbeResponseModel",]


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