[REST API] Depth on call response info

Hi,

We have started using the rest api for some developments that demand quite a lot of information from the database to the client application.

In the current standard, one needs to ask for the device name (/devices), then the attribute list (/devices/sys/tg_test/1/attributes), then the specific attribute (/devices/sys/tg_test/1/attributes/ampli) and then info (…/ampli/info) and value (…/ampli/value).

Unless you know the device and attribute name and you go straight to the value endpoint, there are quite a few calls to the get to the value, or juts to get all the relevant info for a given attribute. And multiply by the number of devices or attributes you want to access.

Would it be possible to add an optional depth argument that allows the addition of extra information in the response instead of only the url? Aggregating the info if the additional calls. For example:


GET /devices/sys/tg_test/1 would return:

"commands":
{
"url": "http://w-v-kitslab-cc-0:8909/tango/rest/rc3/hosts/w-v-kitslab-csdb-0.maxiv.lu.se/10000/devices/sys/tg_test/1/commands",
"command_list": [
{"name": "DevBoolean"},
{"name": "DevDouble"}
….
],
}
"attributes":
{ "url":"url": "http://w-v-kitslab-cc-0:8909/tango/rest/rc3/hosts/w-v-kitslab-csdb-0.maxiv.lu.se/10000/devices/sys/tg_test/1/attributes",
"attibute_list":[
{"name": "ampli"},
{"name": "DevDouble"}
….
],
}
"properties": { xxxxxx }
etc.
}

A depth of 0 would give the same response as todays standard, depth=1 would include command, attributes and property names only, depth 2 would include additional /info and /value data. A depth of 2 maybe has no sense when accessing attribute endpoint.

Similar consideration can be made at /devices level.

What do you think? Is this something worth considering for adding to the standard?

best regards,

mikel
Hi Mikel,

In Tango REST API rc5 it is planned to make commands, attributes and pipes first class citizens: link

This means you will be able to access commands, attributes and pipes via simple url: <host>/attributes

So this should solve your issue :)

rc5 will be released this year (2018), hopefully…


Cheers,
Thanks for the reply. Looking forward for the RC5!

cheers,

mikel
I replied too quickly…

How do you specify to which device the attribute belongs? And you still cannot get all attributes of a given device.

Perhaps I am missing something, could you provide a brief example of what you propose?

thanks,

mikel
I am thinking about something like this:

1. Get attributes

GET …/tango_host/attributes


[
{
   name: 'attr1',
   device: 'sys/tg_test/1',
   info: {…}
},
…
]

This may be paged


2. Get attribute

GET …/tango_host/attributes/attr1


{
   name: 'attr1',
   device: 'sys/tg_test/1',
   info: {…}
}

3. Get attribute values

GET …/tango_host/attributes/value?attr=attr1


{
   name: 'attr1',
   value: 'Hello World!'
}

etc

Hope this clarifies!
But one would need to give a device name(s) in all those calls:


GET …/tango_host/attributes?dev=dev1&dev=dev2

You would receive all the attributes of those devices.

Also, in this case, would the info field in the response be the info url or the whole info dict (unit, alarm, format, etc)? I would rather have the extended info dict but then this response would be different to the one from:


GET …/tango_host/devices/<dev1>/attributes

thanks,

mikel
 
Register or login to create to post a reply.