feat: cover all admin-only backend endpoints
Problem
Currently, corpus-client-cli only supports user-level operations (login, profile, upload).
Administrative tasks such as managing roles, approving categories, and handling history restores require manual API calls.
Objective
Implement a comprehensive admin command group in the CLI that maps to all admin-restricted backend endpoints.
This will allow authorized users to perform maintenance and moderation tasks directly from their terminal.
Scope & Requirements
1. Role Management
-
Requirement: Capability to list, retrieve details, and create system roles (admin, user, reviewer).
-
Proposed Commands:
admin roles list admin roles get admin roles create
2. User Administration
-
Requirement: Admin-level user discovery with pagination support.
-
Proposed Commands:
admin users list --skip X --limit Y
3. Authentication Utilities
-
Requirement: Ability for admins to force-reset user passwords (e.g., for recovery or security resets).
-
Proposed Commands:
admin auth reset-password
4. Category Moderation
-
Requirement: Manage the category lifecycle, specifically handling user-suggested categories.
-
Proposed Commands:
admin categories list-pending admin categories approve admin categories reject admin categories create admin categories delete
5. History Restores
-
Requirement: Handle restore operations for deleted or corrupted records.
-
Proposed Commands:
admin history pending-restores admin history approve-restore
Technical Implementation Details
-
Create a modular
admin.pyto house sub-apps for each domain (roles, users, etc.). -
Implement a centralized request helper to handle:
- Authorization headers
- Consistent error reporting for
403 Forbiddenresponses
-
Integrate the admin group into the main
corpus-cliententry point.
Acceptance Criteria
- All commands must verify authentication before execution.
- JSON responses from the backend should be rendered clearly (using
richif possible). - Comprehensive unit tests must be implemented for each command group.