"""
Pydantic Models for CMDB - firewall/ippool6

Runtime validation models for firewall/ippool6 configuration.
Generated from FortiOS schema version unknown.

Example Usage:
    >>> from hfortix_fortios.models.cmdb.firewall.ippool6 import 
    >>>
    >>> # Create with validation
    >>> obj = (
    ...     name=1,
    ...     name="example",
    ... )
    >>>
    >>> # Validation happens automatically
    >>> # ValidationError raised if constraints violated
"""

from __future__ import annotations

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

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


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

class Ippool6Model(BaseModel):
    """
    Pydantic model for firewall/ippool6 configuration.
    
    Configure IPv6 IP pools.
    
    Validation Rules:        - name: max_length=79 pattern=        - type: pattern=        - startip: pattern=        - endip: pattern=        - internal_prefix: pattern=        - external_prefix: pattern=        - comments: max_length=255 pattern=        - nat46: pattern=        - add_nat46_route: 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 | None = Field(max_length=79, default="", description="IPv6 IP pool name.")    
    type: Literal["overload", "nptv6"] | None = Field(default="overload", description="Configure IPv6 pool type (overload or NPTv6).")    
    startip: str = Field(default="::", description="First IPv6 address (inclusive) in the range for the address pool (format = xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx, default = ::).")    
    endip: str = Field(default="::", description="Final IPv6 address (inclusive) in the range for the address pool (format = xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx, default = ::).")    
    internal_prefix: str = Field(default="::/0", description="Internal NPTv6 prefix length (32 - 64).")    
    external_prefix: str = Field(default="::/0", description="External NPTv6 prefix length (32 - 64).")    
    comments: str | None = Field(max_length=255, default=None, description="Comment.")    
    nat46: Literal["disable", "enable"] | None = Field(default="disable", description="Enable/disable NAT46.")    
    add_nat46_route: Literal["disable", "enable"] | None = Field(default="enable", description="Enable/disable adding NAT46 route.")    
    # ========================================================================
    # 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]) -> "":
        """
        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__ = [
    "Ippool6Model",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.0
# Generated: 2026-01-07T01:42:15.959160Z
# ============================================================================