"""
Pydantic Models for CMDB - router/access_list6

Runtime validation models for router/access_list6 configuration.
Generated from FortiOS schema version unknown.
"""

from __future__ import annotations

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

# ============================================================================
# Child Table Models
# ============================================================================

class AccessList6Rule(BaseModel):
    """
    Child table model for rule.
    
    Rule.
    """
    
    class Config:
        """Pydantic model configuration."""
        extra = "allow"  # Allow additional fields from API
        str_strip_whitespace = True
    
    id: int = Field(ge=0, le=4294967295, default=0, description="Rule ID.")    
    action: Literal["permit", "deny"] | None = Field(default="permit", description="Permit or deny this IP address and netmask prefix.")    
    prefix6: str = Field(default="", description="IPv6 prefix to define regular filter criteria, such as \"any\" or subnets.")    
    exact_match: Literal["enable", "disable"] | None = Field(default="disable", description="Enable/disable exact prefix match.")    
    flags: int | None = Field(ge=0, le=4294967295, default=0, description="Flags.")
# ============================================================================
# Enum Definitions (for fields with 4+ allowed values)
# ============================================================================


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

class AccessList6Model(BaseModel):
    """
    Pydantic model for router/access_list6 configuration.
    
    Configure IPv6 access lists.
    
    Validation Rules:        - name: max_length=35 pattern=        - comments: max_length=127 pattern=        - rule: 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, default="", description="Name.")    
    comments: str | None = Field(max_length=127, default="", description="Comment.")    
    rule: list[Rule] = Field(default=None, description="Rule.")    
    # ========================================================================
    # 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]) -> "AccessList6Model":
        """
        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__ = [
    "AccessList6Model",    "AccessList6Rule",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.0
# Generated: 2026-01-17T02:10:48.544743Z
# ============================================================================