-
Notifications
You must be signed in to change notification settings - Fork 13
Methods
Methods are used in a request to retrieve data. They specify what type of data is needed and will return it. Permissions affect how data is interacted with by a user.
Request fields are sent in the top level JSON request. Response fields return in the updates field, methods will go into more detail on how updates are received.
- list
- set
- remove
- invoke
- subscribe
- unsubscribe
- close
This method will retrieve a list of children, attributes, and configs. However, children without the read permission will not be displayed.
The response of list will update on any node change available to the current requester, there is no need to list on same node twice in same requester because second stream will return same state as the previous list stream's final state.
- path (string)
- Path of the node to retrieve a list on
-
name
-
Name of the field
-
Names that start with '$' are configs that can affect how system works
- "$is"
- profile of the node, must be the first update of a list stream, otherwise requester will treat it as a new node and clear other existing data
- profile node should also be loaded to get all predefined configs/attributes of a node
- profile nodes locate in /defs/profile/
- "$permission"
- a enum of the following values
- read user has read access to the node, can be omitted
- write user has write access to the node, can read node and write to node and its attributes
- config user has full access to the node, can read/write and change configs
- a enum of the following values
- "$is"
-
Names that start with '@' are custom attributes
-
Other names are children nodes, with map value of the children properties
- children node must include $name if it has a display name
- children node must include $is in the child object
- children node must include $permission if it's not 'read'
- children node should include $invokable if user is allowed to invoke it
- children node should include $type if node support subscription
- children node should include $interface if it's defined
- $interface are not needed if it's already defined in $is profile.
- other properties of children nodes shouldn't appear in the list response.
-
Names must not be blank or contain these characters:
. / \ ? * : | “ < >
-
When % is used in name, it must be used only for UTF-8 based percent encode, not for other purpose.
-
value
-
updated value of the field
- change (optional enum configuration)
- enum value, can be "remove" or "update"
- default value is "update"
{
"rid": 1,
"method": "list",
"path": "/light"
}
{
"rid": 1,
"stream": "open",
"update": [
[
"$is",
"point/light"
],
[
"$permission",
"write"
],
[
"@city",
"San Francisco"
],
[
"point1",
{
"$is": "temperaturePoint",
"$name": "Custom Name for Point1",
"$invokable": "read",
"$interface": "tempUnit"
}
],
[
"point2",
{
"$is": "numericPoint",
"$invokable": "write",
}
],
{
"name": "point3",
"change": "remove"
}
]
}
This method will set values on a node.
- path (type:path)
- path of the node to set, can be a node path or attribute/config path
- value (any primitive type)
- The type of the value must be acceptable to the type of the node.
No response update.
The value in this usage turns the lights on (true) or off (false).
{
"rid": 1,
"method": "set",
"path": "/lights/Lights A",
"value": false
}
{
"rid": 1,
"stream": "closed"
}
This method will remove attributes or configs. Remove a overwritten config/attribute value will restore it to default value defined in profile
- path (type:path)
- attribute/config path to remove
No response update.
{
"rid": 1,
"method": "remove",
"path": "/light/@city"
}
{
"rid": 1,
"stream": "closed"
}
This method will invoke an action on a node. params list and
- params (map, optional)
- The parameters are defined in the action node
- Can be omitted if the action takes no parameters
columns list is defined in the action node or its profile but invoke response can also return a column structure to overwrite the value the columns structure can only be returned once per action invoke
columns results can have one or multiple rows if the invoke response' streamstatus is still "open", it can have more updates rows in future response until requester or responder close the stream
{
"rid": 1,
"method": "invoke",
"path": "/echo",
"params": {
"string": "dsaisawesome"
}
}
{
"rid": 1,
"stream": "closed",
"columns": [
{"name": "result", "type": "string"}
],
"updates": [
["dsaisawesome"]
]
}
{
"rid": 1,
"stream": "open",
"columns": [
{"name": "changes", "type": "string"}
],
"updates": [
["first update"]
]
}
{
"rid": 1,
"stream": "closed",
"updates": [
["second update"]
]
}
This method will subscribe to a datapoint node to receive its value and value updatea.
- paths (type:list)
- a list of JSON objects about the subscription
- path - Path of the node
- sid - Subscription ID
- cache (optional, default of 1) - The cache of values the responder contains. If the responder can't write a subscription update to the requester then it will use the cache of values.
- a list of JSON objects about the subscription
No response update to the direct response. the value update will be sent in the main subscription stream, which has the following columns
There are multiple elements in the updates field. Each element will contain:
- sid
- Subscription ID (requester must keep track of which SIDs belong to which node)
- value
- updated value
- ts (time string in iso8601 format)
- last update time of the value
- status (optional enum)
- status of the value
- ok - No issues with the node value (default is status is omitted)
- stale - The value could potentially be out of date
- disconnected - Never set by a dslink. The broker sets this if a connection is lost between the dslink and the broker.
- status of the value
- count (optional int)
- if the response skip some value, this shows how many updates have happened since last response
- only valid value is counted, if value status is not ok, and count is not specified explicitly, the count this updated is treated as 0\
- skip value will happen when responder connection is slow, or when change happens on requester fater than the updateInterval
- sum (optional number)
- the sum value if one or more numeric value is skipped
- only valid numeric value is added to sum
- max (optional number)
- the max value if one or more numeric value is skipped
- min (optional number)
- the min value if one or more numeric value is skipped
- part (optional string)
- used when sending a very big string or very big List value
- the value of part will be a fraction number, i.e. "1/2" "2/2"
{
"rid": 1,
"method": "subscribe",
"paths": [
{"path": "/point1", "sid": 0, "cache": 5},
{"path": "/point2", "sid": 1},
{"path": "/point3", "sid": 2}
]
}
{
"rid": 1,
"stream": "closed"
}
"rid":0 is reserved for the subscription update and this stream will always be open
{
"rid": 0,
"updates": [
[
0,
12,
"2014-11-27T09:11.000-08:00"
],
{
"sid": 1,
"status": "disconnected",
"ts": "2014-11-27T09:11.000-08:00"
},
{
"sid": 2,
"value": 10,
"ts": "2014-11-27T09:11.000-08:00",
"count": 5,
"sum": 75,
"min": 10,
"max": 20
}
]
}
This method will unsubscribe from a datapoint and stop receiving new values on a node.
- sids (list)
- a list of subscription IDs to unsubscribe
No response fields sent.
{
"rid": 1,
"method": "unsubscribe",
"sids": [0]
}
{
"rid": 1,
"stream": "closed"
}
This method will close a stream
{
"rid": 1,
"method": "close"
}
If request is closed from requester side, response is not needed
Protocol
◌ Design
◌ Initializing Connection
◌ Node API
◌ Methods
◌ Broker
◌ Broker Discovery
◌ Configs
◌ Value Types
◌ Tokens
◌ Quality of Service
DSLink Manager
◌ dslink.json
◌ Startup Command
SDK Development
◌ Implementation Guide
DSA Server
◌ Installation
◌ Update Server
◌ Server Configuration
◌ CLI Tools
◌ DSA Permission Basics
◌ DSA Permission Model
◌ Permission List for the Root
◌ Authentication
◌ OpenID Connect
◌ Password Hasher
◌ DGLux Server SSL (HTTPS)
◌ Docker
◌ Audit
◌ Data Node
◌ Install NGINX with DSA Server
◌ Configure Ubuntu Linux to auto start DSA server
◌ Troubleshooting