Dear list,
We are having some discussions between teams and would like to know your thoughts on the following:
We have a collection of servers and we need to calculate the datatraffic used by these servers (either one server or multiple aggregated):
POST /servers/calculateUsage
{
"servers": [
{
"id": 1,
"startDate": "2015-01-01 00:00:00",
"endDate": "2015-02-01 01:02:00"
},
{
"id": 2,
"startDate": "2015-02-01 00:00:00",
"endDate": "2015-02-01 05:00:00"
},
]
}
This will sum all the datatraffic of the two servers in the specified timeframes and returns one value: { “usage”: 1421342134 }
At first we thought to use POST because of two reasons:
- the number of servers (1..n) the calculation needs to be performed on might exceed the maximum query string length
- make a clear distinct between ‘real’ resources being created/requested and ‘calculations’ or ‘actions’ being performed (for example, to reboot a server we would also do a POST /servers/{id}/reboot)
Now we have the discussion if this makes sense or not. What if we only need the usage for one server, would a GET request on a server resource be better? For example:
GET /servers/{id}/usage (with queryParameters “startDate” and “endDate”)
Instead of the POST method with only one serverId, start- and endDate?
Some say the GET is better and more REST and cacheable, others argue that to make our whole API look/feel uniform , stick to the POST method for all actions/calculations etc.
Regards,
Rolph
--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft.
For more options, visit https://groups.google.com/d/optout.
Some say the GET is better and more REST and cacheable, others argue that to make our whole API look/feel uniform , stick to the POST method for all actions/calculations etc.
Hi Rolph,
Hi Darrel,
Any advise on the last question:
What would you do if I only needed usage of a single resource over a certain period of time? Just implement a GET /servers/{id}/usage with queryParams as well or just stick to one implementation?
What would you do if I only needed usage of a single resource over a certain period of time? Just implement a GET /servers/{id}/usage with queryParams as well or just stick to one implementation?