"""
Pydantic Models for CMDB - system/health_check_fortiguard

Runtime validation models for system/health_check_fortiguard 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 HealthCheckFortiguardProtocolEnum(str, Enum):
    """Allowed values for protocol field."""
    PING = "ping"
    TCP_ECHO = "tcp-echo"
    UDP_ECHO = "udp-echo"
    HTTP = "http"
    HTTPS = "https"
    TWAMP = "twamp"
    DNS = "dns"
    TCP_CONNECT = "tcp-connect"
    FTP = "ftp"


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

class HealthCheckFortiguardModel(BaseModel):
    """
    Pydantic model for system/health_check_fortiguard configuration.
    
    SD-WAN status checking or health checking. Identify a server predefine by FortiGuard and determine how SD-WAN verifies that FGT can communicate with it.
    
    Validation Rules:        - name: max_length=35 pattern=        - server: max_length=127 pattern=        - obsolete: min=0 max=255 pattern=        - protocol: 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="Status check or predefined health-check targets name.")    
    server: str = Field(max_length=127, description="Status check or predefined health-check domain name.")    
    obsolete: int | None = Field(ge=0, le=255, default=0, description="Indicates whether Health Check service can be used.")    
    protocol: HealthCheckFortiguardProtocolEnum = Field(default=HealthCheckFortiguardProtocolEnum.PING, description="Protocol name.")    
    # ========================================================================
    # 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]) -> "HealthCheckFortiguardModel":
        """
        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__ = [
    "HealthCheckFortiguardModel",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.1
# Generated: 2026-01-18T20:31:29.489829Z
# ============================================================================