"""
User Pydantic model for Nginx Proxy Manager.

This module defines the User model representing user accounts
and permissions in Nginx Proxy Manager.
"""

from datetime import datetime

from pydantic import BaseModel, Field


class User(BaseModel):
    """
    Pydantic model for Nginx Proxy Manager User.

    A user represents an account with access to the NPM admin interface
    and API, with role-based permissions.

    Attributes:
        id: Unique identifier (auto-generated by NPM)
        created_on: Timestamp when the user was created
        modified_on: Timestamp when the user was last modified
        email: User email address (unique identifier)
        name: User's full name
        nickname: User's nickname (optional)
        avatar: URL to user's avatar image (optional)
        is_disabled: Whether the user account is disabled
        roles: List of roles assigned to the user
    """

    # Identifiers
    id: int | None = None
    created_on: datetime | None = None
    modified_on: datetime | None = None

    # User details
    email: str
    name: str
    nickname: str | None = None
    avatar: str | None = None

    # Status and permissions
    is_disabled: bool = False
    roles: list[str] = Field(default_factory=list)

    model_config = {
        "json_schema_extra": {
            "examples": [
                {
                    "email": "admin@example.com",
                    "name": "Admin User",
                    "roles": ["admin"],
                },
            ]
        }
    }
