The Images API v2 has been using PATCH to update an image record for quite a 
long time now.  We pretty much follow the IETF docs.  Here's how it's 
documented:

http://docs.openstack.org/api/openstack-image-service/2.0/content/update-an-image.html

And here's the info about the media type used for the request body:

http://docs.openstack.org/api/openstack-image-service/2.0/content/appendix-b-http-patch-media-types.html

Not surprisingly, we feel that this is the correct way to implement PATCH!

cheers,
brian

________________________________
From: Amit Gandhi [amit.gan...@rackspace.com]
Sent: Friday, December 12, 2014 3:17 PM
To: OpenStack Development Mailing List (not for usage questions)
Subject: [openstack-dev] [api] Usage of the PATCH verb

Hi

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.

Thanks

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/



_______________________________________________
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to