"""
Pydantic Models for CMDB - log/memory/global_setting

Runtime validation models for log/memory/global_setting configuration.
Generated from FortiOS schema version unknown.
"""

from __future__ import annotations

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

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


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

class GlobalSettingModel(BaseModel):
    """
    Pydantic model for log/memory/global_setting configuration.
    
    Global settings for memory logging.
    
    Validation Rules:        - max_size: min=0 max=4294967295 pattern=        - full_first_warning_threshold: min=1 max=98 pattern=        - full_second_warning_threshold: min=2 max=99 pattern=        - full_final_warning_threshold: min=3 max=100 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
    # ========================================================================
    
    max_size: int | None = Field(ge=0, le=4294967295, default=62524334, description="Maximum amount of memory that can be used for memory logging in bytes.")    
    full_first_warning_threshold: int | None = Field(ge=1, le=98, default=75, description="Log full first warning threshold as a percent (1 - 98, default = 75).")    
    full_second_warning_threshold: int | None = Field(ge=2, le=99, default=90, description="Log full second warning threshold as a percent (2 - 99, default = 90).")    
    full_final_warning_threshold: int | None = Field(ge=3, le=100, default=95, description="Log full final warning threshold as a percent (3 - 100, default = 95).")    
    # ========================================================================
    # 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]) -> "GlobalSettingModel":
        """
        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__ = [
    "GlobalSettingModel",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.0
# Generated: 2026-01-17T17:56:13.995506Z
# ============================================================================