Hi David/Martin/all,
David,
I went through the link you provided- and I am thankful that you pointed
that out(that the way I suggested for version negotiation)-- its simply
outdated :( Sorry for that...
With ref to auth, if we are working on a library then should it not have
some authentication of its own? I dont know, just a thought... This way,
(with auth) an end user can straight away use the library as it is(one
potential user is myself as I could straightaway deploy the library and use
the in-built auth to make use of the deployed library from my end-user apps)
Also, as Martin has said, RABL can be used with Sinatra too- so we need not
add Rails to the project....
Martin,
I dont have experience using RABL myself-- its just that one of my friends
has used it and recommends it.
With ref to parsing of JSON/XML objects the only Ruby libraries I am aware
of are Representable(https://github.com/apotonick/representable) and
Crack(http://www.railstips.org/blog/archives/2009/04/01/crack-the-easiest-way-to-parse-xml-and-json/)
-- Crack looks very suitable for this use case- although again I have never
used it myself-- plus its very new -- so it may well have some bugs in it:(
With ref to my projects-- well a couple of them are for deploying a custom
CMS to cloud, a cloud platform (what you would call a cloud PaaS) and a
distributed computing platform. In all of these, I would require DeltaCloud
to provision/restart/perform other ops on virtual machines in different
clouds. I initially zeroed in on jclouds but feel Delta Cloud is a better
fit, simply because of the much larger community that is working on it, and
also I can deploy Delta Cloud as a standalone app(accessible via API from
each of my end user apps separately)-- which is not possible with jclouds
(would require a lot of work).
Yours sincerely,
Arvind.
-----Original Message-----
From: Martin Povolny
Sent: Wednesday, April 10, 2013 11:42 PM
To: [email protected]
Subject: Re: deltacloud as a lib and broker
On Tue, Apr 09, 2013 at 09:11:46PM +0530, Arvind Creatrix IT Soft wrote:
Hi
Hallo Arvind.
With ref to the discussion- I was already planning to work on creating an
API over the core Delta Cloud code as I need it in a number of my
projects.
I suggest the following means to do this, in as painless a manner as
possible--
(1) Use Rails and RABL--> https://github.com/nesquena/rabl to generate the
API
(2) Use the VersionCake gem for versioning(
https://github.com/bwillis/versioncake)
(3) Controllers are set up in an hierarchy where you have one
BaseController which contains this authentication logic (as a
before_filter) and then the other controllers inherit from that. If you
have any other helpers, they would go in this controller too.
(4) For authorization, use CanCan.(https://github.com/ryanb/cancan) It's
README and Wiki are great sources of information on how to use it.
I am experimenting with a cloud broker concept and actually I am trying
out Rabl on top of Sinatra w/o Padrino as this gives me most of what I
need and stays sort-of lightweight especially when comparing with Rails.
So you can provide a recommendation for Rabl? Do you have personal good
experience with it?
Then what do you use for parsing of POST data? Is there some counterpart
of Rabl that would parse XML and JSON based on similar rules and give me
a nice Ruby hash and a decent list of errors in case of any?
I also wonder what type of project you have that use DeltaCloud. Can you
share such information? What parts of DeltaCloud do you use most?
Finally, here is some helpful text from the RABL docs-->
Once you have installed RABL (explained above), you can construct a RABL
view template and then render the template from your Sinatra, Padrino or
Rails applications from the controller (or route) very easily. Using
Padrino as an example, assuming you have aPost model filled with blog
posts, you can render an API representation (both JSON and XML) by
creating a route:
# app/app.rb
get "/posts", :provides => [:json, :xml] do
@user = current_user
@posts = Post.order("id DESC")
render "posts/index"
end
Then we can create the following RABL template to express the API output
of @posts:
# app/views/posts/index.rabl
collection @posts
attributes :id, :title, :subject
child(:user) { attributes :full_name }
node(:read) { |post| post.read_by?(@user) }
Which would output the following JSON or XML when visiting
http://localhost:3000/posts.json
[{ "post" :
{
"id" : 5, title: "...", subject: "...",
"user" : { full_name : "..." },
"read" : true
}
}]
This is an easy way to create a API library that has its own versioning-
and at the same time it basically just uses the core code in the Delta
Cloud library itself.
--
Martin Povolny <[email protected]>
tel. +420777714458