"""
Pydantic Models for CMDB - report/setting

Runtime validation models for report/setting configuration.
Generated from FortiOS schema version unknown.

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

from __future__ import annotations

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

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


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

class SettingModel(BaseModel):
    """
    Pydantic model for report/setting configuration.
    
    Report setting configuration.
    
    Validation Rules:        - pdf_report: pattern=        - fortiview: pattern=        - report_source: pattern=        - web_browsing_threshold: min=3 max=15 pattern=        - top_n: min=1000 max=20000 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
    # ========================================================================
    
    pdf_report: Literal["enable", "disable"] | None = Field(default="enable", description="Enable/disable PDF report.")    
    fortiview: Literal["enable", "disable"] | None = Field(default="enable", description="Enable/disable historical FortiView.")    
    report_source: list[ReportSource] = Field(default="forward-traffic", description="Report log source.")    
    web_browsing_threshold: int | None = Field(ge=3, le=15, default=3, description="Web browsing time calculation threshold (3 - 15 min).")    
    top_n: int | None = Field(ge=1000, le=20000, default=1000, description="Number of items to populate (1000 - 20000).")    
    # ========================================================================
    # 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__ = [
    "SettingModel",]


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