T-032: User management admin panel - backend users router with CRUD, frontend UsersPage with modals T-033: Audit log viewer - backend audit router with filters/pagination, frontend AuditLogPage T-034: Global error handling - ErrorBoundary, LoadingSpinner, ErrorMessage, Toast components T-035: Backend tests - pytest setup with SQLite, tests for health/auth/techniques/tests T-036: Documentation - Updated README with testing section, created docs/API.md
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
"""Pydantic schemas for User management endpoints."""
|
|
|
|
import uuid
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, EmailStr
|
|
|
|
|
|
# ── Create ──────────────────────────────────────────────────────────
|
|
|
|
class UserCreate(BaseModel):
|
|
"""Payload for creating a new user."""
|
|
|
|
username: str
|
|
email: str | None = None
|
|
password: str
|
|
role: str = "viewer"
|
|
|
|
|
|
# ── Update ──────────────────────────────────────────────────────────
|
|
|
|
class UserUpdate(BaseModel):
|
|
"""Payload for partially updating an existing user.
|
|
Every field is optional so callers send only what changed."""
|
|
|
|
email: str | None = None
|
|
role: str | None = None
|
|
is_active: bool | None = None
|
|
password: str | None = None
|
|
|
|
|
|
# ── Read (full) ─────────────────────────────────────────────────────
|
|
|
|
class UserOut(BaseModel):
|
|
"""Complete representation returned by the API."""
|
|
|
|
id: uuid.UUID
|
|
username: str
|
|
email: str | None = None
|
|
role: str
|
|
is_active: bool
|
|
created_at: datetime | None = None
|
|
last_login: datetime | None = None
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|