"""
Pydantic Models for CMDB - firewall/schedule/onetime

Runtime validation models for firewall/schedule/onetime configuration.
Generated from FortiOS schema version unknown.
"""

from __future__ import annotations

from pydantic import BaseModel, Field
from typing import Any, Literal, Optional
from uuid import UUID

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


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

class OnetimeModel(BaseModel):
    """
    Pydantic model for firewall/schedule/onetime configuration.
    
    Onetime schedule configuration.
    
    Validation Rules:        - name: max_length=31 pattern=        - uuid: pattern=        - start: pattern=        - start_utc: pattern=        - end: pattern=        - end_utc: pattern=        - color: min=0 max=32 pattern=        - expiration_days: min=0 max=100 pattern=        - fabric_object: 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
    # ========================================================================
    
    name: str = Field(max_length=31, description="Onetime schedule name.")    
    uuid: str | None = Field(default="00000000-0000-0000-0000-000000000000", description="Universally Unique Identifier (UUID; automatically assigned but can be manually reset).")    
    start: str = Field(description="Schedule start date and time, format hh:mm yyyy/mm/dd.")    
    start_utc: str | None = Field(default=None, description="Schedule start date and time, in epoch format.")    
    end: str = Field(description="Schedule end date and time, format hh:mm yyyy/mm/dd.")    
    end_utc: str | None = Field(default=None, description="Schedule end date and time, in epoch format.")    
    color: int | None = Field(ge=0, le=32, default=0, description="Color of icon on the GUI.")    
    expiration_days: int | None = Field(ge=0, le=100, default=3, description="Write an event log message this many days before the schedule expires.")    
    fabric_object: Literal["enable", "disable"] | None = Field(default="disable", description="Security Fabric global object setting.")    
    # ========================================================================
    # 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]) -> "OnetimeModel":
        """
        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__ = [
    "OnetimeModel",]


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