<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1" class="" style="word-wrap:break-word">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">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:<br>
<br>
<a href="http://docs.openstack.org/api/openstack-image-service/2.0/content/update-an-image.html" target="_blank">http://docs.openstack.org/api/openstack-image-service/2.0/content/update-an-image.html</a><br>
<br>
And here's the info about the media type used for the request body:<br>
<br>
http://docs.openstack.org/api/openstack-image-service/2.0/content/appendix-b-http-patch-media-types.html<br>
<br>
Not surprisingly, we feel that this is the correct way to implement PATCH!<br>
<br>
cheers,<br>
brian<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF175941"><font color="#000000" face="Tahoma" size="2"><b>From:</b> Amit Gandhi [amit.gandhi@RACKSPACE.COM]<br>
<b>Sent:</b> Friday, December 12, 2014 3:17 PM<br>
<b>To:</b> OpenStack Development Mailing List (not for usage questions)<br>
<b>Subject:</b> [openstack-dev] [api] Usage of the PATCH verb<br>
</font><br>
</div>
<div></div>
<div>Hi<br class="">
<br class="">
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.  <br class="">
<br class="">
I would like to get the advise of the Openstack Community and the API working group on how PATCH semantics should work.<br class="">
<br class="">
The following RFC documents [1][2] (and a blog post [3]) advise the using PATCH as the following:<br class="">
<br class="">
<br class="">
2.1.  A Simple PATCH Example
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">   PATCH /file.txt HTTP/1.1</div>
<div class="">   Host: <a href="http://www.example.com" class="" target="_blank">
www.example.com</a></div>
<div class="">   Content-Type: application/example</div>
<div class="">   If-Match: "e0023aa4e"</div>
<div class="">   Content-Length: 100</div>
<div class=""><br class="">
</div>
<div class=""> </div>
[
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>{ "op": "test", "path": "/a/b/c", "value": "foo" },</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>{ "op": "remove", "path": "/a/b/c" },</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>{ "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>{ "op": "replace", "path": "/a/b/c", "value": 42 },</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>{ "op": "move", "from": "/a/b/c", "path": "/a/b/d" },</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>{ "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }</div>
]<br class="">
<br class="">
<br class="">
<br class="">
Basically, the changes consist of an operation, the path in the json object to modify, and the new value.  
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">I would like to hear some feedback from others on how PATCH should be implemented.</div>
<div class=""><br class="">
</div>
<div class="">Thanks</div>
<div class=""><br class="">
</div>
<div class="">Amit Gandhi</div>
<div class="">- Rackspace</div>
<div class=""><br class="">
<br class="">
<br class="">
[1] <a href="https://tools.ietf.org/html/rfc5789" class="" target="_blank">https://tools.ietf.org/html/rfc5789</a><br class="">
[2] <a href="http://tools.ietf.org/html/rfc6902" class="" target="_blank">http://tools.ietf.org/html/rfc6902</a><br class="">
[3] <a href="http://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/" class="" target="_blank">http://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/</a><br class="">
<br class="">
<br class="">
<br class="">
</div>
</div>
</div>
</div>
</body>
</html>