-
Notifications
You must be signed in to change notification settings - Fork 0
0.7 List Semantics
The UDJ-Server has common semantics for interacting with lists.
- Getting the list
- Adding an element to the list
- Removing an element from the list
- Modify the list (multiple operations)
Returns the entire list as a JSON array.
Example for a list of IDs:
GET /endpoint
[id1, id2, id3, ... idN]
Example for a list of User objects:
GET /endpoint
[{
"id" : "12345",
"username" : "testuser",
"first_name" : "Test ",
"last_name" : "User"
},
{
"id" : "54321",
"username" : "anotheruser",
"first_name" : "Another ",
"last_name" : "User"
}]
If the element you're adding is already in the list, an error will be returned.
For objects that have an id
, just send the id
to /endpoint/id
instead of sending the whole object (see PUT /endpoint/id
below).
For structures that will have an id
after this call, but don't yet, send the whole object to /endpoint and the id
field will be ignored.
Example: Creating a new user:
PUT to /endpoint
{
// No id field, since non-existant users don't have an id yet.
// If an id field was included, it would be ignore.
"username" : "testuser",
"first_name" : "Test ",
"last_name" : "User"
}
Adds and element to a list by it's id
.
Example: Adding a user (id 1756) to a list:
PUT /endpoint/1756
Removes the specified element from the list.
Takes two parameters, add
and delete
. Each contains a list of elements to add or delete.
At least one of the parameters must be specified, or an error is returned.