"""
Pydantic Models for MONITOR - firewall/policy_lookup

Runtime validation models for firewall/policy_lookup 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 PolicyLookupModel(BaseModel):
    """
    Pydantic model for firewall/policy_lookup configuration.
    
    Performs a policy lookup by creating a dummy packet and asking the kernel which policy would be hit.
    
    Validation Rules:        - ipv6: pattern=        - srcintf: pattern=        - sourceport: pattern=        - sourceip: pattern=        - protocol: pattern=        - dest: pattern=        - destport: pattern=        - icmptype: pattern=        - icmpcode: pattern=        - policy_type: pattern=        - auth_type: pattern=        - user_group: pattern=        - server_name: pattern=        - user_db: pattern=        - group_attr_type: 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
    # ========================================================================
    
    ipv6: Any = Field(default=None)    
    srcintf: str = Field()    
    sourceport: Any = Field(default=None)    
    sourceip: str = Field()    
    protocol: str = Field()    
    dest: str = Field()    
    destport: Any = Field(default=None)    
    icmptype: Any = Field(default=None)    
    icmpcode: Any = Field(default=None)    
    policy_type: str | None = Field(default=None)    
    auth_type: str | None = Field(default=None)    
    user_group: Any = Field(default=None)    
    server_name: str | None = Field(default=None)    
    user_db: str | None = Field(default=None)    
    group_attr_type: str | None = 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]) -> "PolicyLookupModel":
        """
        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__ = [
    "PolicyLookupModel",]


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