"""
Pydantic Models for MONITOR - system/resource/usage

Runtime validation models for system/resource/usage configuration.
Generated from FortiOS schema version unknown.
"""

from __future__ import annotations

from pydantic import BaseModel, Field
from typing import Any, Literal, Optional
from enum import Enum

# ============================================================================
# Enum Definitions (for fields with 4+ allowed values)
# ============================================================================

class UsageResourceEnum(str, Enum):
    """Allowed values for resource field."""
    CPU = "cpu"
    MEM = "mem"
    DISK = "disk"
    SESSION = "session"
    SESSION6 = "session6"
    SETUPRATE = "setuprate"
    SETUPRATE6 = "setuprate6"
    DISK_LOGRATE = "disk_lograte"
    FAZ_LOGRATE = "faz_lograte"
    FORTICLOUD_LOGRATE = "forticloud_lograte"
    GTP_TUNNEL = "gtp_tunnel"
    GTP_TUNNEL_SETUP_RATE = "gtp_tunnel_setup_rate"

class UsageIntervalEnum(str, Enum):
    """Allowed values for interval field."""
    V_1_MIN = "1-min"
    V_10_MIN = "10-min"
    V_30_MIN = "30-min"
    V_1_HOUR = "1-hour"
    V_12_HOUR = "12-hour"
    V_24_HOUR = "24-hour"


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

class UsageModel(BaseModel):
    """
    Pydantic model for system/resource/usage configuration.
    
    Retreive current and historical usage data for a provided resource.
    
    Validation Rules:        - scope: pattern=        - resource: pattern=        - interval: 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
    # ========================================================================
    
    scope: Literal["vdom", "global"] | None = Field(default=None)    
    resource: UsageResourceEnum | None = Field(default=None)    
    interval: UsageIntervalEnum | None = Field(default=None)    
    # ========================================================================
    # 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]) -> "UsageModel":
        """
        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__ = [
    "UsageModel",]


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