"""
Pydantic Models for CMDB - wireless_controller/hotspot20/h2qp_wan_metric

Runtime validation models for wireless_controller/hotspot20/h2qp_wan_metric 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 H2qpWanMetricModel(BaseModel):
    """
    Pydantic model for wireless_controller/hotspot20/h2qp_wan_metric configuration.
    
    Configure WAN metrics.
    
    Validation Rules:        - name: max_length=35 pattern=        - link_status: pattern=        - symmetric_wan_link: pattern=        - link_at_capacity: pattern=        - uplink_speed: min=0 max=4294967295 pattern=        - downlink_speed: min=0 max=4294967295 pattern=        - uplink_load: min=0 max=255 pattern=        - downlink_load: min=0 max=255 pattern=        - load_measurement_duration: min=0 max=65535 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=None, description="WAN metric name.")    
    link_status: Literal["up", "down", "in-test"] | None = Field(default="up", description="Link status.")    
    symmetric_wan_link: Literal["symmetric", "asymmetric"] | None = Field(default="asymmetric", description="WAN link symmetry.")    
    link_at_capacity: Literal["enable", "disable"] | None = Field(default="disable", description="Link at capacity.")    
    uplink_speed: int | None = Field(ge=0, le=4294967295, default=2400, description="Uplink speed (in kilobits/s).")    
    downlink_speed: int | None = Field(ge=0, le=4294967295, default=2400, description="Downlink speed (in kilobits/s).")    
    uplink_load: int | None = Field(ge=0, le=255, default=0, description="Uplink load.")    
    downlink_load: int | None = Field(ge=0, le=255, default=0, description="Downlink load.")    
    load_measurement_duration: int | None = Field(ge=0, le=65535, default=0, description="Load measurement duration (in tenths of a second).")    
    # ========================================================================
    # 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]) -> "H2qpWanMetricModel":
        """
        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__ = [
    "H2qpWanMetricModel",]


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