<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>Thanks for your comment, Miguel.  Your suggestion is indeed very close to the RESTful ideal.</div>
<div><br>
</div>
<div>However, I have a question for the entire API-WG.  Our (proposed) mission is "To improve the developer experience of API users by converging the OpenStack API to a consistent and pragmatic RESTful design." [1]  My question is: what is the sense of "pragmatic"
 in this sentence?  I thought it meant that we advise the designers of OpenStack APIs to adhere to RESTful design as much as possible, but allow them to diverge where appropriate.  The proposed functional call to deactivate an image seems to be an appropriate
 place to deviate from the ideal.  Creating a task or action object so that the POST request will create a new resource does not seem very pragmatic.  I believe that a necessary component of encouraging OpenStack APIs to be consistent is to allow some pragmatism.</div>
<div><br>
</div>
<div>thanks,</div>
<div>brian </div>
<div><br>
</div>
<div>[1] https://review.openstack.org/#/c/155911/</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div>
<div>On 2/18/15, 4:49 PM, "Miguel Grinberg" <<a href="mailto:miguel.s.grinberg@gmail.com">miguel.s.grinberg@gmail.com</a>> wrote:</div>
</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>
<div>
<div dir="ltr">Out of all the proposals mentioned in this thread, I think Jay's (d) option is what is closer to the REST ideal:
<div><br>
</div>
<div><span style="font-size:12.8000001907349px">d) POST /images/{image_id}/tasks with payload:</span><br style="font-size:12.8000001907349px">
<span style="font-size:12.8000001907349px">   { "action": "deactivate|activate" }</span><br style="font-size:12.8000001907349px">
</div>
<div><span style="font-size:12.8000001907349px"><br>
</span></div>
<div><span style="font-size:12.8000001907349px">Even though I don't think this is the perfect solution, I can recognize that at least it tries to be RESTful, unlike the other three options suggested in the first message.</span></div>
<div><span style="font-size:12.8000001907349px"><br>
</span></div>
<div><span style="font-size:12.8000001907349px">That said, I'm going to keep insisting that in a REST API state changes are the most important thing, and actions are implicitly derived by the server from these state changes requested by the client. What you
 are trying to do is to reverse this flow, you want the client to invoke an action, which in turn will cause an implicit state change on the server. This isn't wrong in itself, it's just not the way you do REST.</span></div>
<div><span style="font-size:12.8000001907349px"><br>
</span></div>
<div><span style="font-size:12.8000001907349px">Jay's (d) proposal above could be improved by making the task a real resource. Sending a POST request to the /tasks address creates a new task resource, which gets a URI of its own, returned in the Location header.
 You can then send a GET request to this URI to obtain status info, such as whether the task completed or not. And since tasks are now real resources, they should have a documented representation as well.</span></div>
<div><span style="font-size:12.8000001907349px"><br>
</span></div>
<div><span style="font-size:12.8000001907349px">Miguel</span></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Feb 18, 2015 at 1:19 PM, Brian Rosmaita <span dir="ltr">
<<a href="mailto:brian.rosmaita@rackspace.com" target="_blank">brian.rosmaita@rackspace.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb">
<div class="h5">On 2/15/15, 2:35 PM, "Jay Pipes" <<a href="mailto:jaypipes@gmail.com">jaypipes@gmail.com</a>> wrote:<br>
>On 02/15/2015 01:13 PM, Brian Rosmaita wrote:<br>
>> On 2/15/15, 10:10 AM, "Jay Pipes" <<a href="mailto:jaypipes@gmail.com">jaypipes@gmail.com</a>> wrote:<br>
>><br>
>>> On 02/15/2015 01:31 AM, Brian Rosmaita wrote:<br>
>>>> This is a follow-up to the discussion at the 12 February API-WG<br>
>>>> meeting [1] concerning "functional" API in Glance [2].  We made<br>
>>>> some progress, but need to close this off so the spec can be<br>
>>>> implemented in Kilo.<br>
>>>><br>
>>>> I believe this is where we left off: 1. The general consensus was<br>
>>>> that POST is the correct verb.<br>
>>><br>
>>> Yes, POST is correct (though the resource is wrong).<br>
>>><br>
>>>> 2. Did not agree on what to POST.  Three options are in play: (A)<br>
>>>> POST /images/{image_id}?action=deactivate POST<br>
>>>> /images/{image_id}?action=reactivate<br>
>>>><br>
>>>> (B) POST /images/{image_id}/actions with payload describing the<br>
>>>> action, e.g., { "action": "deactivate" } { "action": "reactivate"<br>
>>>> }<br>
>>>><br>
>>>> (C) POST /images/{image_id}/actions/deactivate POST<br>
>>>> /images/{image_id}/actions/reactivate<br>
>>><br>
>>> d) POST /images/{image_id}/tasks with payload: { "action":<br>
>>> "deactivate|activate" }<br>
>>><br>
>>> An action isn't created. An action is taken. A task is created. A<br>
>>> task contains instructions on what action to take.<br>
>><br>
>> The Images API v2 already has tasks (schema available at<br>
>> /v2/schemas/tasks ), which are used for long-running asynchronous<br>
>> operations (right now, image import and image export).  I think we<br>
>> want to keep those distinct from what we're talking about here.<br>
>><br>
>> Does something really need to be created for this call?  The idea<br>
>> behind the "functional" API was to have a place for things that don't<br>
>> fit neatly into the CRUD-centric paradigm.  Option (C) seems like a<br>
>> good fit for this.<br>
><br>
>Why not just use the existing tasks/ interface, then? :) Seems like a<br>
>perfect fit to me.<br>
<br>
</div>
</div>
The existing tasks/ interface is kind of heavyweight.  It provides a<br>
framework for asynchronous operations.  It's really not appropriate for<br>
this purpose.<br>
<br>
cheers,<br>
brian<br>
<div class="HOEnZb">
<div class="h5"><br>
<br>
__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" target="_blank">
OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</span>
</body>
</html>