Mailinglist Archive: yast-devel (163 mails)

< Previous Next >
[yast-devel] rest-service ResourcesController should be more RESTful
  • From: Martin Kudlvasr <mkudlvasr@xxxxxxx>
  • Date: Thu, 17 Sep 2009 15:35:53 +0200
  • Message-id: <200909171535.53748.mkudlvasr@xxxxxxx>
Hi,

see http://bugzilla.novell.com/show_bug.cgi?id=539290 for introduction.

Basically, we currently discover resources from interface using path like:
/resources.xml?interface=org.opensuse.yast.modules.yapi.network

this is not restful, so service_resource.rb circumvents this by always using
"proxy.find :all" and then searching for the resource in the list
(/resources.xml works well). Simply because "proxy.find
'org.opensuse.yast.modules.yapi.network'" does not work ("proxy" is a proxy
for /resources).

Goal: Make it work!
Currently finding a single resource is not used, so we have a bit of freedom,
when figuring that out. There are 2 problems:

1)

/resources/org.opensuse.yast.modules.yapi.network is a problematic path,
because "." is a format separator (for .xml, .json, ...).

proposed solution:

use dashes instead of dots in the URI.
/resources/org-opensuse-yast-modules-yapi-network.xml
We can say, that dashes cannot be part of interface name (thanks to mvidner
for http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-
names). The interface name has to be transliterated, but this happens only
once on server and once on client.

2)

there can be more resources found for a single interface name. In current
implementation, ResourcesController returns this for /resources.xml:
<resources>
<resource>
<interface>
...
</resource>
...
</resources>

and the same format for
/resources.xml?interface=org.opensuse.yast.modules.yapi.network . Returning a
list of items, where (according to ActiveResource) a single item is expected.
ActiveResource has a problem with that.

**imho optimal solution:**

remake the xml format, so that single resource can contain several
implementations (the same way it is in internal structures of rest-
service/webservice/lib/resource_registration.rb). The format for
/resources.xml can then look like this:

<resources>
<resource>
<implementations>
<implementation>
<interface>
...
</implementation>
</implementations>
</resource>
...
</resources>

with the same (but only single <resource>) for /resources/$interface_name.xml
. By remaking the xml, service_resource.rb would have to be changed. I tried
that and did not succeed.

**proposed solution:**

Make server return only single implementation/resource, when asked for a
single interface.
This would preserve current format of /resources.xml and work with
ActiveResource mechanisms at the same time. The only thing that changes is,
that server decides which implementation of resource is used by the client.
Until now, this was decided in web-client by the rule "take first"
(service_resource.rb:315).

Both proposed solutions are implemented in resource-restful branch and pushed
to git.opensuse.org. Please comment, if this can be merged, and say why, if
not.

Martin Kudlvasr
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages