"""
Pydantic Models for MONITOR - fortiguard/service_communication_stats

Runtime validation models for fortiguard/service_communication_stats 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 ServiceCommunicationStatsServiceTypeEnum(str, Enum):
    """Allowed values for service_type field."""
    FORTICARE = "forticare"
    FORTIGUARD_DOWNLOAD = "fortiguard_download"
    FORTIGUARD_QUERY = "fortiguard_query"
    FORTICLOUD_LOG = "forticloud_log"
    FORTISANDBOX_CLOUD = "fortisandbox_cloud"
    FORTIGUARD_COM = "fortiguard.com"
    SDNS = "sdns"
    FORTITOKEN_REGISTRATION = "fortitoken_registration"
    SMS_SERVICE = "sms_service"


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

class ServiceCommunicationStatsModel(BaseModel):
    """
    Pydantic model for fortiguard/service_communication_stats configuration.
    
    Retrieve historical statistics for communication with FortiGuard services.
    
    Validation Rules:        - service_type: pattern=        - timeslot: 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
    # ========================================================================
    
    service_type: ServiceCommunicationStatsServiceTypeEnum | None = Field(default=None)    
    timeslot: Literal["1_hour", "24_hour", "1_week"] | 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]) -> "ServiceCommunicationStatsModel":
        """
        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__ = [
    "ServiceCommunicationStatsModel",]


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