On 03/03/11 17:39 -0800, David Lutterkort wrote:
On Wed, 2011-03-02 at 12:05 +0100, [email protected] wrote:
Hi,
I decide to send out another patch, which fixes all issues mentioned by David.
Also when I tried to figure out how I'll report the link in instance actions for
creating images, I got into a problem how I'll report params needed to complete
this action (like instance_id).
So I came up with this solution and want to know if I'm wrong or not ;-)
So I wrote a simple helper for Sinatra called 'generate_action_params' which
will generate this block for <link> element:
<link href="http://localhost:3001/api/images" method="post" rel="create_image">
<param name="description" type="string"/>
<param name="name" type="string"/>
<param name="instance_id" required="required" type="string"
value="i-e90ead85"/>
</link>
I am not convinced that that will make clients' life easier - they still
need to know what the name and description parameters mean. Of course,
we'd want the mandatory instance_id to show up in the URL. We could use
a query param:
<link href="http://localhost:3001/api/images?instance_id=i-e90ead85" method="post"
rel="create_image"/>
but you shouldn't really use query params on a URL you'll post to. This
might be a good use for a matrix param then:
<link href="http://localhost:3001/api/images;instance_id=i-e90ead85" method="post"
rel="create_image"/>
Haven't tried yet though how Rack/Sinatra handle them.
Good idea! I created a simple Rack middleware to do this. What about 'optional'
parameters? So we will advertise them somewhere (except docs) ? Should
I keep the generate_action_params and remove 'required' param from there?
-- Michal
David
--
--------------------------------------------------------
Michal Fojtik, [email protected]
Deltacloud API: http://deltacloud.org
--------------------------------------------------------