Giter Site home page Giter Site logo

rest-api's Introduction

rest-api's People

Contributors

beenje avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rest-api's Issues

Change image API

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.

Add high level api calls

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?!

Should command repsonse contains only result value?

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"
]}

add hosts/tree

GET .../hosts/tree

[
  {
    id: 'host1:10000'
    name: 'host1:10000',
    data:[
      { id: 'aliases'},
      { 
        id: 'domains',
        data:[...]
      }
    ]
  },
  ...
]

Remove hosts resource

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.

Attributes plain value

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

Replace host port with matrix parameter

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

Lookup devices using aliases

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

Restructure Tango REST project

  • extract tests into a dedicated project: rest-test-suite which will produce test-jar
  • move version related classes into dedicated package e.g. org.tango.rest.rc4.AttributeValue
  • transfer mtangorest.server to tango-controls and allow support of multiple Tango REST API versions

Replace *plain* and *image* with Accept header

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

Client has to specify data type when writting into pipes.

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":[...]
                    }]
            }
        ]
}


Generalize query parameter using wildcards

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

Failure status code value???

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
}


Add attribute's info_ex

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": []
      }
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.