Consider the following relationship between two resources
- The college has many faculties.
- Faculty refers to College
Obviously, faculty is not a first class resource here.
Now I need endpoints for the following operations.
- Create a new faculty in this college of this farm. One possible way to do this in two operations.
POST /faculties/PUT /college/1/faculties
- Remove faculty from this college. Again two operations
GET /college/1/faculties : list of related faculties. Each of them will contain its own URL, for example /faculties/1 .DELETE /college/1/faculties/1 : The URL looks better, but how do I open this URL?
- Add one or more faculties to this college.
PUT /college/1/faculties , which accepts the full list of faculties of this college.
- Delete this specific sector as a whole.
DELETE /sectors/1 : It looks good, but you need to take care of the cache /faculties/1/sectors .
What would be better in this case? I read about exposing membership resources, but with this approach, if the college has 10 faculties, it will take 10 separate HTTP calls to get all members from membership.
In addition, this is just one small part of a complete relationship tree. To extend this further, let's say the system has
- The faculties have many departments.
- There are many laboratories in the department, etc.
In addition, in a RESTful architecture, a client should never fill in URLs.
Any suggestion?
rest restful-architecture apiblueprint
Samiron
source share