feat(api): add POST /v1/users/{username}/reset-octets endpoint

Add endpoints to reset per-user octet counters without restarting the
proxy, enabling external tools to implement periodic (monthly/daily)
quota resets.

New endpoints:
- POST /v1/users/{username}/reset-octets — reset single user
- POST /v1/users/reset-octets — reset all users

Changes:
- stats/mod.rs: add reset_user_octets() and reset_all_user_octets()
- api/mod.rs: add route handlers for both endpoints
- api/model.rs: add ResetOctetsResponse and ResetAllOctetsResponse
- docs/API.md: document new endpoints

Closes #510
This commit is contained in:
SamNet-dev
2026-03-20 09:20:38 -05:00
parent 2798039ab8
commit b9eb1406bb
5 changed files with 81 additions and 1 deletions

View File

@@ -1058,6 +1058,8 @@ Link generation uses active config and enabled modes:
| `PATCH /v1/users/{username}` | Partial update of provided fields only. Missing fields remain unchanged. Current implementation persists full config document on success. |
| `POST /v1/users/{username}/rotate-secret` | Currently returns `404` in runtime route matcher; request schema is reserved for intended behavior. |
| `DELETE /v1/users/{username}` | Deletes only specified user, removes this user from related optional `access.user_*` maps, blocks last-user deletion, and atomically updates only related `access.*` TOML tables. |
| `POST /v1/users/{username}/reset-octets` | Resets the per-user octet counters (`octets_from_client` and `octets_to_client`) to zero. Returns `{ "username": "...", "octets_reset": true }`. Useful for implementing periodic (monthly/daily) quota resets without restarting the proxy. |
| `POST /v1/users/reset-octets` | Resets octet counters for **all** tracked users. Returns `{ "users_reset": N }`. |
All mutating endpoints:
- Respect `read_only` mode.