[openstack-dev] [API] Standardizing status codes in the native API

Eoghan Glynn eglynn at redhat.com
Fri Jul 20 15:58:19 UTC 2012


Folks,

In an IRC discussion on the patch for a bug[1] reported against the
volumes API, it wasn't clear whether:

 (a) the API spec actually calls out a specific status code (i.e.
     if the 200 was deliberate or just an over-sight)

or:

 (b) a change of this nature should go ahead without wider discussion.

So my feeling, as reflected in this patch[2] is that we should as
far as possible follow generally-accepted RESTful idioms. In this
case, we're creating a new resource, so the response to the POST
request should specify a status code of either 201 or 202 and
include a Location header.

Note that there is some inconsistency on this point in the native API,
for example we return 202 and provide a location header when a new
server is booted or a snapshot image is created, but 200 and no
location when for example a volume or security group is created.

My preference would be to use 201/202 across the board for new resources,
but I would love to know if there are any contrary opinions.

Cheers,
Eoghan


[1]  https://bugs.launchpad.net/nova/+bug/1026600
[2]  https://review.openstack.org/10058



More information about the OpenStack-dev mailing list