Problem
Per campus API conventions, subresource paths with ID parameters should have trailing slashes (e.g., /assignments/{assignment_id}/ instead of /assignments/{assignment_id}). The campus server is being updated to match this convention, and this client library needs to be updated accordingly.
Related issue: nyjc-computing/campus#407
API Methods to Fix
The following client methods call API endpoints that need trailing slashes added. This requires updating the make_path() calls to pass end_slash=True.
campus_python/api/v1/assignments.py
Assignments.Assignment class:
get() - Line 73-76
- Current:
self.client.get(self.make_path())
- Fix:
self.client.get(self.make_path(end_slash=True))
delete() - Line 68-71
- Current:
self.client.delete(self.make_path())
- Fix:
self.client.delete(self.make_path(end_slash=True))
update() - Line 78-81
- Current:
self.client.patch(self.make_path(), json=updates)
- Fix:
self.client.patch(self.make_path(end_slash=True), json=updates)
campus_python/api/v1/submissions.py
Submissions.Submission class:
get() - Line 137-141
- Current:
self.client.get(self.make_path())
- Fix:
self.client.get(self.make_path(end_slash=True))
delete() - Line 131-135
- Current:
self.client.delete(self.make_path())
- Fix:
self.client.delete(self.make_path(end_slash=True))
update() - Line 170
- Current:
self.client.patch(self.make_path(), json=payload)
- Fix:
self.client.patch(self.make_path(end_slash=True), json=payload)
Submissions class:
by_assignment() - Line 62
- Current:
path = f"{self.make_path()}/by-assignment/{assignment_id}"
- Fix:
path = f"{self.make_path()}/by-assignment/{assignment_id}/"
by_student() - Line 79
- Current:
path = f"{self.make_path()}/by-student/{student_id}"
- Fix:
path = f"{self.make_path()}/by-student/{student_id}/"
campus_python/api/v1/circles.py
Circles.Circle class:
get() - Line 56-59
- Current:
self.client.get(self.make_path())
- Fix:
self.client.get(self.make_path(end_slash=True))
delete() - Line 51-54
- Current:
self.client.delete(self.make_path())
- Fix:
self.client.delete(self.make_path(end_slash=True))
update() - Line 61-64
- Current:
self.client.patch(self.make_path(), json=updates)
- Fix:
self.client.patch(self.make_path(end_slash=True), json=updates)
campus_python/auth/v1/credentials.py
Credentials.Provider.User class:
delete() - Line 61-68
- Current:
self.client.delete(self.make_path(), json={"client_id": client_id})
- Fix:
self.client.delete(self.make_path(end_slash=True), json={"client_id": client_id})
get() - Line 70-78
- Current:
self.client.get(self.make_path(), query={"client_id": client_id})
- Fix:
self.client.get(self.make_path(end_slash=True), query={"client_id": client_id})
update() - Line 95
- Current:
self.client.patch(self.make_path(), json=json_data)
- Fix:
self.client.patch(self.make_path(end_slash=True), json=json_data)
campus_python/auth/v1/users.py
Users.User class:
delete() - Line 48-50
- Current:
self.client.delete(self.make_path())
- Fix:
self.client.delete(self.make_path(end_slash=True))
get() - Line 52-55
- Current:
self.client.get(self.make_path())
- Fix:
self.client.get(self.make_path(end_slash=True))
campus_python/auth/v1/vaults.py
Vaults.Vault class (methods use make_path(key)):
__delitem__() - Line 33
- Current:
self.client.delete(self.make_path(key))
- Fix:
self.client.delete(self.make_path(key, end_slash=True))
__getitem__() - Line 40
- Current:
self.client.get(self.make_path(key))
- Fix:
self.client.get(self.make_path(key, end_slash=True))
__setitem__() - Line 50
- Current:
self.client.post(self.make_path(key), json={"value": value})
- Fix:
self.client.post(self.make_path(key, end_slash=True), json={"value": value})
Tasks
- Update all 19 method calls listed above to use
end_slash=True
- Update any tests that mock these API calls to expect trailing slashes
- Verify compatibility with the updated campus server routes
Notes
- Routes ending in verbs (e.g.,
/activate, /submit) do NOT need trailing slashes
- Routes ending in subresource names (e.g.,
/links, /responses, /metadata) do NOT need trailing slashes
Problem
Per campus API conventions, subresource paths with ID parameters should have trailing slashes (e.g.,
/assignments/{assignment_id}/instead of/assignments/{assignment_id}). The campus server is being updated to match this convention, and this client library needs to be updated accordingly.Related issue: nyjc-computing/campus#407
API Methods to Fix
The following client methods call API endpoints that need trailing slashes added. This requires updating the
make_path()calls to passend_slash=True.campus_python/api/v1/assignments.py
Assignments.Assignment class:
get()- Line 73-76self.client.get(self.make_path())self.client.get(self.make_path(end_slash=True))delete()- Line 68-71self.client.delete(self.make_path())self.client.delete(self.make_path(end_slash=True))update()- Line 78-81self.client.patch(self.make_path(), json=updates)self.client.patch(self.make_path(end_slash=True), json=updates)campus_python/api/v1/submissions.py
Submissions.Submission class:
get()- Line 137-141self.client.get(self.make_path())self.client.get(self.make_path(end_slash=True))delete()- Line 131-135self.client.delete(self.make_path())self.client.delete(self.make_path(end_slash=True))update()- Line 170self.client.patch(self.make_path(), json=payload)self.client.patch(self.make_path(end_slash=True), json=payload)Submissions class:
by_assignment()- Line 62path = f"{self.make_path()}/by-assignment/{assignment_id}"path = f"{self.make_path()}/by-assignment/{assignment_id}/"by_student()- Line 79path = f"{self.make_path()}/by-student/{student_id}"path = f"{self.make_path()}/by-student/{student_id}/"campus_python/api/v1/circles.py
Circles.Circle class:
get()- Line 56-59self.client.get(self.make_path())self.client.get(self.make_path(end_slash=True))delete()- Line 51-54self.client.delete(self.make_path())self.client.delete(self.make_path(end_slash=True))update()- Line 61-64self.client.patch(self.make_path(), json=updates)self.client.patch(self.make_path(end_slash=True), json=updates)campus_python/auth/v1/credentials.py
Credentials.Provider.User class:
delete()- Line 61-68self.client.delete(self.make_path(), json={"client_id": client_id})self.client.delete(self.make_path(end_slash=True), json={"client_id": client_id})get()- Line 70-78self.client.get(self.make_path(), query={"client_id": client_id})self.client.get(self.make_path(end_slash=True), query={"client_id": client_id})update()- Line 95self.client.patch(self.make_path(), json=json_data)self.client.patch(self.make_path(end_slash=True), json=json_data)campus_python/auth/v1/users.py
Users.User class:
delete()- Line 48-50self.client.delete(self.make_path())self.client.delete(self.make_path(end_slash=True))get()- Line 52-55self.client.get(self.make_path())self.client.get(self.make_path(end_slash=True))campus_python/auth/v1/vaults.py
Vaults.Vault class (methods use
make_path(key)):__delitem__()- Line 33self.client.delete(self.make_path(key))self.client.delete(self.make_path(key, end_slash=True))__getitem__()- Line 40self.client.get(self.make_path(key))self.client.get(self.make_path(key, end_slash=True))__setitem__()- Line 50self.client.post(self.make_path(key), json={"value": value})self.client.post(self.make_path(key, end_slash=True), json={"value": value})Tasks
end_slash=TrueNotes
/activate,/submit) do NOT need trailing slashes/links,/responses,/metadata) do NOT need trailing slashes