"""Admin API schemas.

⚠️ AUTO-GENERATED BY PRISM - DO NOT EDIT
"""

from __future__ import annotations

from datetime import datetime
from typing import Literal

from pydantic import BaseModel, Field


# ── User management schemas ─────────────────────────────────────


class AdminUserResponse(BaseModel):
    """User as seen by admin."""

    id: int
    {{ username_field }}: str
    username: str | None = None
    is_active: bool
    roles: list[str] = Field(default_factory=list)
{% if email_verification %}
    email_verified: bool = False
{% endif %}

    model_config = {"from_attributes": True}


class AdminUserListResponse(BaseModel):
    """Paginated user list."""

    users: list[AdminUserResponse]
    total: int
    skip: int
    limit: int


class AdminUserUpdateRequest(BaseModel):
    """Update user details (admin)."""

    is_active: bool | None = None
    roles: list[str] | None = None


# ── Whitelist schemas ────────────────────────────────────────────


class WhitelistRuleResponse(BaseModel):
    """Whitelist rule response."""

    id: int
    rule_type: str
    value: str
    created_by: str | None = None
    created_at: datetime

    model_config = {"from_attributes": True}


class WhitelistRuleCreateRequest(BaseModel):
    """Create a whitelist rule."""

    rule_type: Literal["email", "domain", "pattern"]
    value: str = Field(..., min_length=1, max_length=255)


# ── Bootstrap schemas ────────────────────────────────────────────


class BootstrapRequest(BaseModel):
    """Bootstrap first admin account."""

    token: str
    password: str = Field(..., min_length=8)


class BootstrapResponse(BaseModel):
    """Bootstrap result."""

    message: str
    user: AdminUserResponse
