[Engine-devel] REST API calls from the GUI
Vojtech Szocs
vszocs at redhat.com
Fri Feb 15 18:11:20 UTC 2013
Hi Libor,
> I would like to ask, if there have been discussions about an option to
> call REST API services directly from the Frontend (GWT layer)? GWT
> compiles Java frontend-side to Javascript, calls to backend services
> are performed "transparently" by the framework using AJAX support.
> But, there is still a need to have a special set of data objects and
> the server-side logic can duplicate.
Indeed, for both WebAdmin and UserPortal, we're planning to move away from GWT RPC (a.k.a Generic API) and use Engine REST API and promote loose coupling between client and server.
As Chris mentioned, for WebAdmin UI plugins, there's already support for calling Engine REST API - session ID is obtained upon WebAdmin UI login and passed to all UI plugins. It's up to plugin authors to decide if the plugin itself (JavaScript) will communicate via REST API, or if the plugin passes the session ID to some other server so that the other server does REST API communication.
> Java REST API SDK enables to build "thick" client. The calls are
> realized using e.g. Apache HttClient and supported libraries. I think
> the requirements of GWT can be a little bit different, but something
> overlaps.
Well, we can't really use Java REST API SDK directly due to restrictions imposed by GWT on client-side code, e.g. HttClient uses sockets which are (obviously) not supported in JavaScript and therefore related classes are rejected by GWT compiler.
What we're planning to do is to map REST API XML responses to generated "REST API Types" (based on api.xsd schema) and vice versa. This could be a bit of challenge, as most frameworks for GWT REST API support use JSON representation in favor of XML.
Vojtech
----- Original Message -----
From: "Christopher Morrissey" <Christopher.Morrissey at netapp.com>
To: "Keith Robertson" <kroberts at redhat.com>, "Libor Spevak" <lspevak at redhat.com>
Cc: engine-devel at ovirt.org
Sent: Tuesday, February 12, 2013 11:53:52 PM
Subject: Re: [Engine-devel] REST API calls from the GUI
The UI plugin framework already makes a session ID available for REST API calls. Oved's blog gives a good description with some example code.
http://ovedou.blogspot.co.il/2012/12/ovirt-foreman-ui-plugin.html
-Chris
> -----Original Message-----
> From: engine-devel-bounces at ovirt.org [mailto:engine-devel-
> bounces at ovirt.org] On Behalf Of Keith Robertson
> Sent: Tuesday, February 12, 2013 11:30 AM
> To: Libor Spevak
> Cc: engine-devel at ovirt.org
> Subject: Re: [Engine-devel] REST API calls from the GUI
>
> Not sure if this is possible now but, I would like the front-end to expose an
> authenticated hook to the API so that plug-ins can call RESTful methods. It
> would enable plug-in writers to do all sorts of interesting things in their plug-
> ins with the RESTful API.
>
> Cheers,
> Keith
>
> On 02/12/2013 11:13 AM, Libor Spevak wrote:
> > Hi,
> >
> > I would like to ask, if there have been discussions about an option to
> > call REST API services directly from the Frontend (GWT layer)? GWT
> > compiles Java frontend-side to Javascript, calls to backend services
> > are performed "transparently" by the framework using AJAX support.
> > But, there is still a need to have a special set of data objects and
> > the server-side logic can duplicate.
> >
> > Java REST API SDK enables to build "thick" client. The calls are
> > realized using e.g. Apache HttClient and supported libraries. I think
> > the requirements of GWT can be a little bit different, but something
> > overlaps.
> >
> > I found several links about REST API support from GWT, so there is
> > something for inspiration...
> >
> > - http://www.spiffyui.org/
> > - http://www.zackgrossbart.com/hackito/gwt-rest/
> > - http://code.google.com/p/gwt-rest/
> > - http://restygwt.fusesource.org/
> >
> > But, do you think it would be useful and what drawbacks can occur
> > (authentication, authorization, response times, need to support larger
> > set of services, painful refactoring, ...)?
> >
> > Regards,
> > Libor
> >
> > _______________________________________________
> > Engine-devel mailing list
> > Engine-devel at ovirt.org
> > http://lists.ovirt.org/mailman/listinfo/engine-devel
>
> _______________________________________________
> Engine-devel mailing list
> Engine-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/engine-devel
_______________________________________________
Engine-devel mailing list
Engine-devel at ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-devel
More information about the Engine-devel
mailing list