[openstack-dev] [api] Usage of the PATCH verb

Amit Gandhi amit.gandhi at RACKSPACE.COM
Fri Dec 12 20:17:29 UTC 2014


We are currently using PATCH in the Poppy API to update existing resources.  However, we have recently had some discussions on how this should have been implemented.

I would like to get the advise of the Openstack Community and the API working group on how PATCH semantics should work.

The following RFC documents [1][2] (and a blog post [3]) advise the using PATCH as the following:

2.1.  A Simple PATCH Example

   PATCH /file.txt HTTP/1.1
   Host: www.example.com<http://www.example.com>
   Content-Type: application/example
   If-Match: "e0023aa4e"
   Content-Length: 100

{ "op": "test", "path": "/a/b/c", "value": "foo" },
{ "op": "remove", "path": "/a/b/c" },
{ "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },
{ "op": "replace", "path": "/a/b/c", "value": 42 },
{ "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
{ "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }

Basically, the changes consist of an operation, the path in the json object to modify, and the new value.

The way we currently have it implemented is to submit just the changes, and the server applies the change to the resource.  This means passing entire lists to change etc.

I would like to hear some feedback from others on how PATCH should be implemented.


Amit Gandhi
- Rackspace

[1] https://tools.ietf.org/html/rfc5789
[2] http://tools.ietf.org/html/rfc6902
[3] http://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20141212/1afb3737/attachment.html>

More information about the OpenStack-dev mailing list