"""
Pydantic Models for CMDB - system/speed_test_server

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

Example Usage:
    >>> from hfortix_fortios.models.cmdb.system.speed_test_server import 
    >>>
    >>> # Create with validation
    >>> obj = (
    ...     name=1,
    ...     name="example",
    ... )
    >>>
    >>> # Validation happens automatically
    >>> # ValidationError raised if constraints violated
"""

from __future__ import annotations

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

# ============================================================================
# Child Table Models
# ============================================================================

class SpeedTestServerHost(BaseModel):
    """
    Child table model for host.
    
    Hosts of the server.
    """
    
    class Config:
        """Pydantic model configuration."""
        extra = "allow"  # Allow additional fields from API
        str_strip_whitespace = True
    
    id: int | None = Field(ge=0, le=4294967295, default=0, description="Server host ID.")    
    ip: str | None = Field(default="0.0.0.0", description="Server host IPv4 address.")    
    port: int | None = Field(ge=1, le=65535, default=5204, description="Server host port number to communicate with client.")    
    user: str | None = Field(max_length=64, default="", description="Speed test host user name.")    
    password: Any = Field(max_length=128, default=None, description="Speed test host password.")    
    longitude: str | None = Field(max_length=7, default="", description="Speed test host longitude.")    
    latitude: str | None = Field(max_length=7, default="", description="Speed test host latitude.")    
    distance: int | None = Field(ge=0, le=4294967295, default=0, description="Speed test host distance.")
# ============================================================================
# Enum Definitions (for fields with 4+ allowed values)
# ============================================================================


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

class SpeedTestServerModel(BaseModel):
    """
    Pydantic model for system/speed_test_server configuration.
    
    Configure speed test server list.
    
    Validation Rules:        - name: max_length=35 pattern=        - timestamp: min=0 max=4294967295 pattern=        - host: 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 | None = Field(max_length=35, default="", description="Speed test server name.")    
    timestamp: int | None = Field(ge=0, le=4294967295, default=0, description="Speed test server timestamp.")    
    host: list[Host] = Field(default=None, description="Hosts of the server.")    
    # ========================================================================
    # 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]) -> "":
        """
        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__ = [
    "SpeedTestServerModel",    "SpeedTestServerHost",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.0
# Generated: 2026-01-09T09:47:39.113698Z
# ============================================================================