Let's say I want to design a REST store used to manage a list. A list entry would look something like this:
<listentry>
<position>0</position> <!-- position in the list -->
<data>interesting information</data> <!-- entry data -->
</listentry>
I would design the resource like this:
GET /list/ // returns all list entries
GET /list/{position} // returns the list entry at {position}
DELETE /list/{position} // delete list entry at {position}
PUT /list/first // update first list entry
PUT /list/last // update last list entry
PUT /list/{position} // update entry at {position}
POST /list/last // inserts a new list entry at last position
POST /list/first // inserts a new list entry at first position
POST /list/{position} // inserts a new list entry at {position} and moves all
// entries down the list starting from the entry that
// was at {position} before the insertion.
is this a legal REST resource? If not is there a way to design a rest resource so that it can manage a list?
EDIT
Thank you for the input it definetly helped. I agree with nategood and darrel that the use of first and last as special identifiers is perfectly legal (see also my question on this). Of course I could do without those magic identifiers as suggested by Saintedlama, but this would rob me of the possibillity to use them in the post requests I want to present you now.
While thinking again about the design, I would like to add two additional functionalities to my resource design suggestion.
POST /list/{position1}/swap/{position2} // swap the position of two elements
POST /list/{position1}/move/{position2} // move the element at {position1} to
// {position2} and move all entries
// down the list starting from the
// entry that was at {position2}
//possible uses
POST /list/first/swap/last // swap first with last element
POST /list/42/swap/2 // swap element 42 with element 2
POST /list/first/move/42 // move first element to position 42
// you get the idea ...
What do you think?