"""
Pydantic Models for MONITOR - user/firewall/deauth

Runtime validation models for user/firewall/deauth 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 DeauthMethodEnum(str, Enum):
    """Allowed values for method field."""
    FSSO = "fsso"
    RSSO = "rsso"
    NTLM = "ntlm"
    FIREWALL = "firewall"
    WSSO = "wsso"
    FSSO_CITRIX = "fsso_citrix"
    SSO_GUEST = "sso_guest"


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

class DeauthModel(BaseModel):
    """
    Pydantic model for user/firewall/deauth configuration.
    
    Deauthenticate single, multiple, or all firewall users.
    
    Validation Rules:        - user_type: pattern=        - id_: pattern=        - ip: pattern=        - ip_version: pattern=        - method: pattern=        - all_: pattern=        - users: 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
    # ========================================================================
    
    user_type: Literal["proxy", "firewall"] | None = Field(default=None)    
    id_: Any = Field(default=None, serialization_alias="id")    
    ip: str | None = Field(default=None)    
    ip_version: Literal["ip4", "ip6"] | None = Field(default=None)    
    method: DeauthMethodEnum | None = Field(default=None)    
    all_: Any = Field(default=None, serialization_alias="all")    
    users: Any = Field(default=None)    
    # ========================================================================
    # 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]) -> "DeauthModel":
        """
        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__ = [
    "DeauthModel",]


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