forge
Explore
Log in

Don't you dare go Hollow

User search in endpoint table, users tag, curl tour

Browse files at this commit

f89c4f8d1cbcb6aac2bcb53d422045469fea414aAhmet Kaan GümüşParent: e0b0b73
  • docs
    • user search in endpoint table, users tag, curl tour
Show full message
📝 docs: user search in endpoint table, users tag, curl tour
README.mdmodified+6 -1
@@ -217,6 +217,7 @@ logged-in user.
217 | POST | `/auth/logout` | no | Clear session (no-op if none) |217 | POST | `/auth/logout` | no | Clear session (no-op if none) |
218 | GET | `/auth/me` | student | Current user (incl. `role` and personal info) |218 | GET | `/auth/me` | student | Current user (incl. `role` and personal info) |
219 | PATCH | `/users/me` | student | Update own personal info (see below) |219 | PATCH | `/users/me` | student | Update own personal info (see below) |
220+| GET | `/users/search` | teacher | `?q=<fragment>&role=<role?>` — find users by username/name fragment (pickers); ≤10 refs, no contact info |
220 | GET | `/users` | admin | List all users |221 | GET | `/users` | admin | List all users |
221 | GET | `/users/{id}` | admin | Get one user |222 | GET | `/users/{id}` | admin | Get one user |
222 | PATCH | `/users/{id}/role` | admin | `{role}` — set a user's role |223 | PATCH | `/users/{id}/role` | admin | `{role}` — set a user's role |
@@ -537,7 +538,11 @@ curl -s -b $JAR $BASE/events/$EV/attendance -H 'content-type: application/json'
537 -d '{"status":"present"}'538 -d '{"status":"present"}'
538 curl -s -b $JAR $BASE/events/$EV/attendance539 curl -s -b $JAR $BASE/events/$EV/attendance
539 540
540-# courses + weighted marks (as a teacher; $SID is a student's user id)541+# courses + weighted marks (as a teacher)
542+# find the student to enroll (here: a registered user "veli"): fragment
543+# search over username/name, role-narrowed (teacher+)
544+SID=$(curl -s -b $JAR "$BASE/users/search?q=vel&role=student" \
545+ | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
541 CO=$(curl -s -b $JAR $BASE/courses -H 'content-type: application/json' \546 CO=$(curl -s -b $JAR $BASE/courses -H 'content-type: application/json' \
542 -d '{"title":"algebra"}' | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)547 -d '{"title":"algebra"}' | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
543 curl -s -b $JAR $BASE/courses/$CO/enrollments -H 'content-type: application/json' \548 curl -s -b $JAR $BASE/courses/$CO/enrollments -H 'content-type: application/json' \
src/lib.rsmodified+1 -1
@@ -38,7 +38,7 @@ use crate::state::AppState;
38 tags(38 tags(
39 (name = "meta", description = "Liveness and service metadata"),39 (name = "meta", description = "Liveness and service metadata"),
40 (name = "auth", description = "Registration, login, session lifecycle"),40 (name = "auth", description = "Registration, login, session lifecycle"),
41- (name = "users", description = "User info: self-service profile, plus listing, lookup, and role/profile administration (admin only)"),41+ (name = "users", description = "User info: self-service profile, name search for the pickers (teacher+, optionally role-filtered), plus listing, lookup, and role/profile administration (admin only)"),
42 (name = "notes", description = "Per-user notes CRUD"),42 (name = "notes", description = "Per-user notes CRUD"),
43 (name = "events", description = "Events and attendance"),43 (name = "events", description = "Events and attendance"),
44 (name = "courses", description = "Courses, enrollment, course exams, and course sessions"),44 (name = "courses", description = "Courses, enrollment, course exams, and course sessions"),