"""
Pydantic Models for CMDB - switch_controller/remote_log

Runtime validation models for switch_controller/remote_log 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 RemoteLogSeverityEnum(str, Enum):
    """Allowed values for severity field."""
    EMERGENCY = "emergency"
    ALERT = "alert"
    CRITICAL = "critical"
    ERROR = "error"
    WARNING = "warning"
    NOTIFICATION = "notification"
    INFORMATION = "information"
    DEBUG = "debug"

class RemoteLogFacilityEnum(str, Enum):
    """Allowed values for facility field."""
    KERNEL = "kernel"
    USER = "user"
    MAIL = "mail"
    DAEMON = "daemon"
    AUTH = "auth"
    SYSLOG = "syslog"
    LPR = "lpr"
    NEWS = "news"
    UUCP = "uucp"
    CRON = "cron"
    AUTHPRIV = "authpriv"
    FTP = "ftp"
    NTP = "ntp"
    AUDIT = "audit"
    ALERT = "alert"
    CLOCK = "clock"
    LOCAL0 = "local0"
    LOCAL1 = "local1"
    LOCAL2 = "local2"
    LOCAL3 = "local3"
    LOCAL4 = "local4"
    LOCAL5 = "local5"
    LOCAL6 = "local6"
    LOCAL7 = "local7"


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

class RemoteLogModel(BaseModel):
    """
    Pydantic model for switch_controller/remote_log configuration.
    
    Configure logging by FortiSwitch device to a remote syslog server.
    
    Validation Rules:        - name: max_length=35 pattern=        - status: pattern=        - server: max_length=63 pattern=        - port: min=0 max=65535 pattern=        - severity: pattern=        - csv: pattern=        - facility: 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=35, description="Remote log name.")    
    status: Literal["enable", "disable"] | None = Field(default="disable", description="Enable/disable logging by FortiSwitch device to a remote syslog server.")    
    server: str = Field(max_length=63, description="IPv4 address of the remote syslog server.")    
    port: int | None = Field(ge=0, le=65535, default=514, description="Remote syslog server listening port.")    
    severity: RemoteLogSeverityEnum | None = Field(default=RemoteLogSeverityEnum.INFORMATION, description="Severity of logs to be transferred to remote log server.")    
    csv: Literal["enable", "disable"] | None = Field(default="disable", description="Enable/disable comma-separated value (CSV) strings.")    
    facility: RemoteLogFacilityEnum | None = Field(default=RemoteLogFacilityEnum.LOCAL7, description="Facility to log to remote syslog server.")    
    # ========================================================================
    # 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]) -> "RemoteLogModel":
        """
        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__ = [
    "RemoteLogModel",]


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