"""
Pydantic Models for CMDB - user/pop3

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

from __future__ import annotations

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

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

class Pop3SslMinProtoVersionEnum(str, Enum):
    """Allowed values for ssl_min_proto_version field."""
    DEFAULT = "default"
    SSLV3 = "SSLv3"
    TLSV1 = "TLSv1"
    TLSV1_1 = "TLSv1-1"
    TLSV1_2 = "TLSv1-2"
    TLSV1_3 = "TLSv1-3"


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

class Pop3Model(BaseModel):
    """
    Pydantic model for user/pop3 configuration.
    
    POP3 server entry configuration.
    
    Validation Rules:        - name: max_length=35 pattern=        - server: max_length=63 pattern=        - port: min=0 max=65535 pattern=        - secure: pattern=        - ssl_min_proto_version: 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="POP3 server entry name.")    
    server: str = Field(max_length=63, description="Server domain name or IP address.")    
    port: int | None = Field(ge=0, le=65535, default=0, description="POP3 service port number.")    
    secure: Literal["none", "starttls", "pop3s"] | None = Field(default="starttls", description="SSL connection.")    
    ssl_min_proto_version: Pop3SslMinProtoVersionEnum | None = Field(default=Pop3SslMinProtoVersionEnum.DEFAULT, description="Minimum supported protocol version for SSL/TLS connections (default is to follow system global setting).")    
    # ========================================================================
    # 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]) -> "Pop3Model":
        """
        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__ = [
    "Pop3Model",]


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