Consider the following relationship between two resources
- College has many Faculties
- Faculty belong to a College
Obviously a Faculty is not a first class resource here.
Now I need endpoints for following operations.
- Create a new faculty in this college this farm. One possible way to do this in two operations.
POST /faculties/
PUT /college/1/faculties
- Remove a faculty from this college. Again two operations
GET /college/1/faculties
: List of associated faculties. Each will contain a self url like/faculties/1
.DELETE /college/1/faculties/1
: The url looks better but how to expose this url?
- Add one or more faculties under that college.
PUT /college/1/faculties
that accepts a complete list of faculties of this college.
- Delete that particular sector entirely.
DELETE /sectors/1
: Looks good but needs to take care of the cache of/faculties/1/sectors
.
What would be a better approach in this case? I have read about exposing membership resources, but with that approach, if a college has 10 faculties, it will take 10 seperate http call to get all of those from the memberships.
Moreover, this is just one small part of the full relationship tree. To extend this further, say the system has
- Faculties has many Departments
- Department has many labs so on.
And besides, In RESTful architecture, the client should never populate the URLs.
Any suggestion?