"""
Pydantic Models for CMDB - user/fortitoken

Runtime validation models for user/fortitoken configuration.
Generated from FortiOS schema version unknown.

Example Usage:
    >>> from hfortix_fortios.models.cmdb.user.fortitoken import 
    >>>
    >>> # Create with validation
    >>> obj = (
    ...     serial-number=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 FortitokenModel(BaseModel):
    """
    Pydantic model for user/fortitoken configuration.
    
    Configure FortiToken.
    
    Validation Rules:        - serial_number: max_length=16 pattern=        - status: pattern=        - comments: max_length=255 pattern=        - license: max_length=31 pattern=        - activation_code: max_length=32 pattern=        - activation_expire: min=0 max=4294967295 pattern=        - reg_id: max_length=256 pattern=        - os_ver: max_length=15 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
    # ========================================================================
    
    serial_number: str | None = Field(max_length=16, default="", description="Serial number.")    
    status: Literal["active", "lock"] | None = Field(default="active", description="Status.")    
    comments: str | None = Field(max_length=255, default=None, description="Comment.")    
    license: str | None = Field(max_length=31, default="", description="Mobile token license.")    
    activation_code: str | None = Field(max_length=32, default="", description="Mobile token user activation-code.")    
    activation_expire: int | None = Field(ge=0, le=4294967295, default=0, description="Mobile token user activation-code expire time.")    
    reg_id: str | None = Field(max_length=256, default="", description="Device Reg ID.")    
    os_ver: str | None = Field(max_length=15, default="", description="Device Mobile Version.")    
    # ========================================================================
    # 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__ = [
    "FortitokenModel",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.0
# Generated: 2026-01-09T09:47:42.911842Z
# ============================================================================