"""
Pydantic Models for CMDB - ips/view_map

Runtime validation models for ips/view_map configuration.
Generated from FortiOS schema version unknown.
"""

from __future__ import annotations

from pydantic import BaseModel, Field
from typing import Any, Optional
from enum import Enum

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

class ViewMapWhichEnum(str, Enum):
    """Allowed values for which field."""
    FIREWALL = "firewall"
    INTERFACE = "interface"
    INTERFACE6 = "interface6"
    SNIFFER = "sniffer"
    SNIFFER6 = "sniffer6"
    EXPLICIT = "explicit"


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

class ViewMapModel(BaseModel):
    """
    Pydantic model for ips/view_map configuration.
    
    Configure IPS view-map.
    
    Validation Rules:        - id_: min=0 max=4294967295 pattern=        - vdom_id: min=0 max=4294967295 pattern=        - policy_id: min=0 max=4294967295 pattern=        - id_policy_id: min=0 max=4294967295 pattern=        - which: 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
    # ========================================================================
    
    id_: int | None = Field(ge=0, le=4294967295, default=0, serialization_alias="id", description="View ID.")    
    vdom_id: int | None = Field(ge=0, le=4294967295, default=0, description="VDOM ID.")    
    policy_id: int | None = Field(ge=0, le=4294967295, default=0, description="Policy ID.")    
    id_policy_id: int | None = Field(ge=0, le=4294967295, default=0, description="ID-based policy ID.")    
    which: ViewMapWhichEnum | None = Field(default=ViewMapWhichEnum.FIREWALL, description="Policy.")    
    # ========================================================================
    # 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]) -> "ViewMapModel":
        """
        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__ = [
    "ViewMapModel",]


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