"""
Pydantic Models for CMDB - wireless_controller/lw_profile

Runtime validation models for wireless_controller/lw_profile configuration.
Generated from FortiOS schema version unknown.
"""

from __future__ import annotations

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

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


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

class LwProfileModel(BaseModel):
    """
    Pydantic model for wireless_controller/lw_profile configuration.
    
    Configure LoRaWAN profile.
    
    Validation Rules:        - name: max_length=35 pattern=        - comment: max_length=63 pattern=        - lw_protocol: pattern=        - cups_server: max_length=255 pattern=        - cups_server_port: min=0 max=65535 pattern=        - cups_api_key: max_length=128 pattern=        - tc_server: max_length=255 pattern=        - tc_server_port: min=0 max=65535 pattern=        - tc_api_key: max_length=128 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=35, default=None, description="LoRaWAN profile name.")    
    comment: str | None = Field(max_length=63, default=None, description="Comment.")    
    lw_protocol: Literal["basics-station", "packet-forwarder"] | None = Field(default="basics-station", description="Configure LoRaWAN protocol (default = basics-station)")    
    cups_server: str | None = Field(max_length=255, default=None, description="CUPS (Configuration and Update Server) domain name or IP address of LoRaWAN device.")    
    cups_server_port: int | None = Field(ge=0, le=65535, default=0, description="CUPS Port value of LoRaWAN device.")    
    cups_api_key: Any = Field(max_length=128, default=None, description="CUPS API key of LoRaWAN device.")    
    tc_server: str | None = Field(max_length=255, default=None, description="TC (Traffic Controller) domain name or IP address of LoRaWAN device.")    
    tc_server_port: int | None = Field(ge=0, le=65535, default=0, description="TC Port value of LoRaWAN device.")    
    tc_api_key: Any = Field(max_length=128, default=None, description="TC API key of LoRaWAN device.")    
    # ========================================================================
    # 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]) -> "LwProfileModel":
        """
        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__ = [
    "LwProfileModel",]


# ============================================================================
# Generated by hfortix generator v0.6.0
# Schema: 1.7.2
# Generated: 2026-01-21T16:24:00.140823Z
# ============================================================================