tango-controls / rest-api Goto Github PK
View Code? Open in Web Editor NEWTango REST API specification
Home Page: http://tango-rest-api.readthedocs.io
Tango REST API specification
Home Page: http://tango-rest-api.readthedocs.io
It is intended that the response must be the same as when reading attribute directly. As this is not very clear we must add an example.
As discussed on the community forum here images must be handled the same way as spectrum.
Specifically, attributes/image-attribute/value
returns standard response with raw matrix; attributes/image-attribute/image
may return an embedded image for supported types, i.e. ushort; attributes/image-attribute/plain
returns raw matrix.
as well as Subscriptions
Db commands e.g. alias:
PUT hosts/tango/db/set_alias?device=sys/tg_test/1&alias=my_test_device
Starter commands:
PUT hosts/tango/starter/start?device=sys/tg_test/1
Others?!
subj.
Originally reported by: Ingvord (Bitbucket: Ingvord, GitHub: Ingvord)
Instead of
#!json
{
"name":"DbGetDeviceInfo",
"input":"sys/tg_test/1",
"output":{
"lvalue":[1,5495],
"svalue":["sys/tg_test/1","IOR:0100000017000000...3100"
,"4","TangoTest/test","precision-deb","4th March 2016 at 23:06:44","26th February 2016 at 23:03:07","TangoTest"
]},
"_links":{"_self":"/rc2/devices/sys/database/2/commands/DbGetDeviceInfo"}
}
return
#!json
{
"lvalue":[1,5495],
"svalue":["sys/tg_test/1","IOR:0100000017000000...3100"
,"4","TangoTest/test","precision-deb","4th March 2016 at 23:06:44","26th February 2016 at 23:03:07","TangoTest"
]}
subj
subj.
subj
subj
GET .../hosts/tree
[
{
id: 'host1:10000'
name: 'host1:10000',
data:[
{ id: 'aliases'},
{
id: 'domains',
data:[...]
}
]
},
...
]
We could have a request like this:
"https://mstatus.esrf.fr:443/tango/rest/rc4/hosts/tangorest01.esrf.fr/10000/devices/sys/mcs/facade/attributes/state/change?timeout=30000&lastEvent=1507277908»
… which would return the first event received after the provided timestamp (if any), or wait until the timeout expires.
subj
Use standard HTTP response headers to inform client about authorization:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="tango Realm"
versus
HTTP/1.1 401 Unauthorized
{
"x-auth-method":"basic"
}
explain status codes
add examples of different errors - 400; 404; 500; 503; etc
subj
hosts as top level resource does not make much sense, but only pollutes URL. This is due to REST API implementation does not know any Tango host in advance and can not discover them in a simple way.
The better approach seems to be is to define devices, atrtibutes, commands and pipes as top level resource:
GET /devices?host={host[:port]}&domain={name/wildcard}&family={name/wildcard}&member={name/wildcard}
GET /devices/tree?host={host[:port]}&domain={name/wildcard}&family={name/wildcard}&member={name/wildcard}
GET /attributes?host={host[:port]}&domain={name/wildcard}&family={name/wildcard}&member={name/wildcard}&name={name}
e.g.
GET /attributes/value?host=localhost&host=hzgxenvtest&domain=sys&family=*&member=*&name=State&name=Status
will response value of State and Status attributes of all devices in sys domain of localhost:10000 and hzgxenvtest:10000 tango hosts.
even if failed
GET /tango/rest/v11/attributes/value?wildcard=localhost:10000/sys/tg_test/1/no_value
[
{
host: "localhost:10000",
device: "sys/tg_test/1",
name: "no_value",
errors: [/*...*/],
quality: "FAILURE",
timestamp: 1234/*...*/
}
]
subj
GET {device}/attributes/{double-attribute}/value/plain
:
3.14
GET {device}/attributes/{string-attribute}/value/plain
:
"Hello World"
GET {device}/attributes/{array-attribute}/value/plain
:
["Hello World",3.14]
etc
with the default value = 10000
This will make url much prettier:
GET tango/rest/rc5/hosts/somehost/devices/sys/tg_test/1
refers to somehost:10000/sys/tg_test/1
with specified value:
GET tango/rest/rc5/hosts/somehost;port=10001/devices/sys/tg_test/1
refers to somehost:10001/sys/tg_test/1
This will clearly separate mete info from server response i.e.
instead of
{
"name":"attr1",
"value":"...",
"_links":{
"self":"..."
}
}
will be
HTTP/1.1 200 OK
Link: <...>; rel=self
{
"name":"attr1",
"value":"...",
}
subj
subj
required by tango-webapp-issue-91
GET hosts/tango/devices/my_test_device
same as GET hosts/tango/devices/sys/tg_test/1
providing that alias my_test_device is defined for sys/tg_test/1
We can leverage existing HTTP feature and replace plain and image path attributes with request headers i.e.
instead of
GET attr/value/plain
do
GET attr/value
Accept: text/plain
AND
instead of
GET attr/value/image
do
GET attr/value
Accept: image/jpeg
As default cache resolution is in seconds it will be useful to provide millis value in the cache extension, see HTTP/1.1 section 14.9.6
Originally reported by: Ingvord (Bitbucket: Ingvord, GitHub: Ingvord)
When deserializing from JSON only three types are available: boolean, double and string.
To work around this pipes PUT request body must look like the following:
#!JSON
{
"name":"DevPipeBlob",
"data":[
{
"name":"DevPipeBlobValue1",
"type":"DevString",
"value":["Hello Tango!"]
},
{
"name":"DevPipeBlobValue2",
"type":"DevUShort",
"value":[123]
},
{
"name":"DevPipeBlobValue3",
"type": "DevPipeBlob",
"value":[{
"name":"DevPipeBlobValueInnerBlob",
"data":[...]
}]
}
]
}
All url values must be lowerCased
e.g.
GET devices?wildcard=localhost/*/*/*
responses with all devices at localhost tango host i.e. same as GET hosts/localhost/devices
GET devices?wildcard=localhost/sys/*/*
responses with all devices in localhost/sys domain
GET devices?wildcard=localhost/sys/*/*&wildcard=hzgxenvtest/sys/*/*
responses with all devices in localhost/sys and hzgxenvtest/sys domains
GET attributes?wildcard=localhost/sys/*/*/State&wildcard=hzgxenvtest/p05/motor/rot.x/Position
responses with all State attributes in localhost/sys domain and Position of hzgxenvtest/p05/motor/rot.x
This will allow to remove security-constraints hence solve CORS problem for opening an event stream
This will improve developer experience of Java clients
Currently these belong to device, but if make them available directly under a host, it will allow efficient (de)multiplexing of calls to read multiple attributes/pipes/execute commands from multiple devices at once
Originally reported by: Ingvord (Bitbucket: Ingvord, GitHub: Ingvord)
Should we introduce a list of error codes for failure results, i.e. when DevFailed occurs?
For instance, server gets communication failed error then error response could look like this:
#!JSON
{
"errors":[
{
"severity":"ERR",
"reason" : "DevFailed - API_CommunicationFailed",
"code":1000,
"description":"Device sys/tg_test/1 is not exported",
"origin":"rest/rc1/devices/sys/tg_test/1"
}
],
"quality":"FAILURE",
"timestamp":123456789
}
Originally reported by: Ingvord (Bitbucket: Ingvord, GitHub: Ingvord)
To be able to change device's events properties (aka change abs) for an attribute info_ex must be provided:
GET/PUT devices/{device}/attributes/{attribute}/info_ex
#!json
{
"name": "float",
"writable": "READ",
"data_format": "SCALAR",
"data_type": 4,
"max_dim_x": 1,
"max_dim_y": 0,
"description": "No description",
"label": "float",
"unit": "No unit",
"standard_unit": "No standard unit",
"display_unit": "No display unit",
"format": "%6.2f",
"min_value": "Not specified",
"max_value": "Not specified",
"min_alarm": "Not specified",
"max_alarm": "Not specified",
"writable_attr_name": "None",
"level": "OPERATOR",
"extensions": [],
"alarms": {
"min_alarm": "Not specified",
"max_alarm": "Not specified",
"min_warning": "Not specified",
"max_warning": "Not specified",
"delta_t": "Not specified",
"delta_val": "Not specified",
"extensions": [],
"tangoObj": {
"min_alarm": "Not specified",
"max_alarm": "Not specified",
"min_warning": "Not specified",
"max_warning": "Not specified",
"delta_t": "Not specified",
"delta_val": "Not specified",
"extensions": []
}
},
"events": {
"ch_event": {
"rel_change": "Not specified",
"abs_change": "Not specified",
"extensions": []
},
"per_event": {
"period": "100",
"extensions": []
},
"arch_event": {
"rel_change": "Not specified",
"abs_change": "Not specified",
"period": "Not specified",
"extensions": []
},
"per_event": {
"period": "100",
"extensions": []
},
"arch_event": {
"rel_change": "Not specified",
"abs_change": "Not specified",
"period": "Not specified",
"extensions": []
}
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.