"""
Pydantic Models for CMDB - system/autoupdate/schedule

Runtime validation models for system/autoupdate/schedule configuration.
Generated from FortiOS schema version unknown.
"""

from __future__ import annotations

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

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

class ScheduleFrequencyEnum(str, Enum):
    """Allowed values for frequency field."""
    EVERY = "every"    DAILY = "daily"    WEEKLY = "weekly"    AUTOMATIC = "automatic"
class ScheduleDayEnum(str, Enum):
    """Allowed values for day field."""
    SUNDAY = "Sunday"    MONDAY = "Monday"    TUESDAY = "Tuesday"    WEDNESDAY = "Wednesday"    THURSDAY = "Thursday"    FRIDAY = "Friday"    SATURDAY = "Saturday"

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

class ScheduleModel(BaseModel):
    """
    Pydantic model for system/autoupdate/schedule configuration.
    
    Configure update schedule.
    
    Validation Rules:        - status: pattern=        - frequency: pattern=        - time: pattern=        - day: 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
    # ========================================================================
    
    status: Literal["enable", "disable"] = Field(default="enable", description="Enable/disable scheduled updates.")    
    frequency: FrequencyEnum = Field(default="daily", description="Update frequency.")    
    time: str = Field(default="", description="Update time.")    
    day: DayEnum = Field(default="Monday", description="Update day.")    
    # ========================================================================
    # 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]) -> "ScheduleModel":
        """
        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__ = [
    "ScheduleModel",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.0
# Generated: 2026-01-17T02:10:48.720519Z
# ============================================================================