Say my application is managing objects called workload, with the following fields. I want to expose a REST interface for user to query workloads by labels.
"Workload": {"id":"test1", "labels":["A", "B", "C"]}
"Workload": {"id":"test2", "labels":["A", "C", "D"]}
"Workload": {"id":"test3", "labels":["A", "B", "D"]}
Question: How do I design the REST endpoint so that it would supports query workload by multiple labels as filter?
Sample Query 1: I want to GET
all the workloads with both "A" and "B".
I'm thinking something like GET
as verb, workloads
as endpoint, then use a {"labels": ["A", "B"]}
as request body. But this does not seem like a RESTful way to do things
Alternatively, I can do GET /labels/{label-id}/workloads
but this would only work with one label per time.
Sample Query 2: I want to GET
all the workloads with label "A" or "B" but no "C"
No clue how to do this sort of rest api at all, other than ask user to query by A, B, C separately then do proper set operations themselves?
The second query is tracked as another question