Skip to content

feat(cli): campus user * management commands (#42) - #46

Merged
ngjunsiang merged 1 commit into
mainfrom
feat/user-commands
Oct 9, 2026
Merged

ngjunsiang merged 1 commit into
mainfrom
feat/user-commands

Conversation

@ngjunsiang

Copy link
Copy Markdown
Contributor

Implements the CLI leg of #42: the user sub-app with list / get / new / activate / edit / delete, completing the two-phase rollout.

Commands and scope mapping

Command Server action Scope floor
campus user list / get GET /users users:read
campus user activate --user-id POST activate users:mod
campus user new --email --name POST /users users:write
campus user edit --user-id --name PATCH (rename only) users:write
campus user delete --user-id DELETE users:admin

Every command's help text names its scope, so a 403 Token lacks 'users:...' maps directly to campus auth login --scope users:.... Delete routes through the shared destructive-action confirmation (TTY-safe; --confirm/-y or CAMPUS_ASSUME_YES=1). All commands support --dry-run like client/vault.

Dependencies (merge order)

  1. Server vocabulary: feat(auth): users management-scope vocabulary with per-vocabulary designation campus#873 (users:read/mod/write/admin + AUTH_USERS_ADMIN_USER_IDS) — the commands 403 without it, but nothing breaks.
  2. SDK update(): feat(auth): Users.User.update() sends the rename-only PATCH campus-api-python#105 (Users.User.update()) — campus user edit needs this; the pyproject pins branch = "main", so relock after that merge.

Tests

  • tests/unit/test_user.py: output-formatting matrix (datetime/ISO-string/None timestamps, identity fields), mirroring test_client.py.
  • Full suite: 175 passed; ruff clean.
  • Smoke: sub-app registers (campus --help), dry-runs render the equivalent campus-api-python snippets.

Closes #42 (with #873 + #105).

Adds the user sub-app: list/get/new/activate/edit/delete, backed by
api.auth_users (campus_python.auth.v1.users). Each command's help
names the users:* scope it requires — list/get: users:read, activate:
users:mod, new/edit: users:write, delete: users:admin — and delete
goes through the destructive-command confirmation (TTY-safe, --confirm
or CAMPUS_ASSUME_YES). All commands support --dry-run like client/vault.

Requires the server-side users:* vocabulary (nyjc-computing/campus#873)
and Users.User.update() (nyjc-computing/campus-api-python#105) for
edit. README documents the users scope tiers, the per-vocabulary
designation env vars (invariant A8), and dry-run/confirmation coverage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): campus user * management commands — currently nonexistent, and gated on a users:* server-side vocabulary

1 participant