I have this list of Notes:
public static List<Note> _notes = new List<Note> { new Note { Id = new Guid("00000000-0000-0000-0000-000000000001"), CategoryId = "1", OwnerId = new Guid("00000000-0000-0000-0000-000000000001"), Title = "First Note", Description = "First Note Description" },
new Note { Id = new Guid("00000000-0000-0000-0000-000000000002"), CategoryId = "1", OwnerId = new Guid("00000000-0000-0000-0000-000000000001"), Title = "Second Note", Description = "Second Note Description" },
new Note { Id = new Guid("00000000-0000-0000-0000-000000000003"), CategoryId = "1", OwnerId = new Guid("00000000-0000-0000-0000-000000000001"), Title = "Third Note", Description = "Third Note Description" },
new Note { Id = new Guid("00000000-0000-0000-0000-000000000004"), CategoryId = "1", OwnerId = new Guid("00000000-0000-0000-0000-000000000001"), Title = "Fourth Note", Description = "Fourth Note Description" },
new Note { Id = new Guid("00000000-0000-0000-0000-000000000005"), CategoryId = "1", OwnerId = new Guid("00000000-0000-0000-0000-000000000001"), Title = "Fifth Note", Description = "Fifth Note Description" }
};
I have these endpoints:
/api/notes GET
/api/notes POST
/api/notes/{id} GET
/api/notes/{id} PUT
/api/notes/{id} DELETE
I want to be able to DELETE/PUT/GET a resource based on OwnerID too. Right now, I can DELETE/PUT/GET a resource based on ID only. I have multiple solutions:
1) Do it from the OwnerController - /api/owner/{ownerId}/{noteId}
2) Do it from the NotesController - /api/notes/{noteId}/{ownerId}
3) Do it from the NotesController, on the GET/PUT/DELETE check if {id} matches either Id or OwnerId - I think that's not a solution, there might be collisions between those IDs.
From all of those I think that the second one might be what I need, but I'm not sure either.
In the REST api arhitecture, how would this case be treated?
Thanks.