DeviceHive-javascript
DeviceHive-javascript is promise-based library for using DeviceHive.
Installation Instructions
For Node.js use case (Node v4.x on Mac, Linux, or Windows on a x86 or x64 processor), DeviceHive-javascript will install nice and easy with:
npm install devicehive
Generation bundle for browser usage
In case you want to use DeviceHive-javascript in the browser:
- Clone repo;
- Inside repo folder run
npm install
; - Inside repo folder run
npm run build
; - Get
devicehive.js
/devicehive.min.js
indist
folder.
Usage
During development you can use this library with Promises, and Async/Await functions.
Connecting to DeviceHive
Using HTTP/HTTPS
Note: Using HTTP/HTTPS you need to pass 3 different service URL`s: mainServiceURL, authServiceURL and pluginServiceURL.
const DeviceHive = ;const httpDeviceHive =login: 'login'password: 'password'mainServiceURL: 'http://<host>:<port>/<path>'authServiceURL: 'http://<host>:<port>/<path>'pluginServiceURL: 'http://<host>:<port>/<path>';httpDeviceHive;
Using WebSocket
Note: Using WebSocket you need to pass only one service URL: mainServiceURL.
const DeviceHive = ;const wsDeviceHive=login: 'login'password: 'password'mainServiceURL: 'ws://<host>:<port>/<path>';wsDeviceHive;
Using Models
You can use models described in DeviceHive.models
// Getting Device modelconst Device = DeviceHivemodelsDevice;// Getting Device list query modelconst DeviceListQuery = DeviceHivemodelsqueryDeviceListQuery;
Full Example and using API
You can use API described in DeviceHive.command, DeviceHive.configuration, DeviceHive.device, DeviceHive.deviceType, DeviceHive.info, DeviceHive.notification, DeviceHive.network, DeviceHive.plugin, DeviceHive.token, DeviceHive.user.
Here is example of how you can use DeviceHive-javascript:
const DeviceHive = ;// Getting Device modelconst Device = DeviceHivemodelsDevice// Getting Device list query modelconst DeviceListQuery = DeviceHivemodelsqueryDeviceListQuery;// Configurating DeviceHiveconst myDeviceHive =login: 'login'password: 'password'mainServiceURL: 'ws://<host>:<port>/<path>';// Configurating Device modelconst device =id: 'myTestId'name: 'myTestName'networkId: 1deviceTypeId: 1blocked: false;// Configurating Device List queryconst myDeviceListQuery =networkId: 1;// Push message handlermyDeviceHive;// Error handlermyDeviceHive;// Connecting and usin APImyDeviceHive;
API Reference
DeviceHive
DeviceHive module
- DeviceHive
- new DeviceHive(options)
- instance
- static
- .models :
Object
- .models :
new DeviceHive(options)
DeviceHive module
Param | Type | Description |
---|---|---|
options | object |
Initial settings |
[options.accessToken] | string |
Access token |
[options.refreshToken] | string |
Refresh token |
[options.login] | string |
Login |
[options.password] | string |
Password |
options.mainServiceURL | string |
Main Service URL |
[options.authServiceURL] | string |
Auth Service URL (required only for http) |
[options.pluginServiceURL] | string |
Plugin Service URL (required only for http) |
[options.autoUpdateSession] | boolean |
Flag to enable/disable autoupdating session. Default: true |
deviceHive.connect({ accessToken, refreshToken, login, password, reconnectionAttempts, reconnectionInterval })
Connect and authorize
Params:
Param | Type | Description |
---|---|---|
options.accessToken | string |
Access token (default DeviceHive constructor configuration) (optional) |
options.refreshToken | string |
Refresh token (default DeviceHive constructor configuration) (optional) |
options.login | string |
Login (default DeviceHive constructor configuration) (optional) |
options.password | string |
Password (default DeviceHive constructor configuration) (optional) |
options.reconnectionAttempts | number |
Reconnection attempts (default infinity (-1)) (optional) |
options.reconnectionInterval | number |
Reconnection interval in ms (default 5000) (optional) |
Object
DeviceHive.models : Returns DeviceHive models
- Command
- Configuration
- DeviceType
- Network
- Notification
- UserToken
- PluginToken
- User
- query
- CommandListQuery
- CommandPollManyQuery
- CommandPollQuery
- CommandWaitQuery
- DeviceCountQuery
- DeviceListQuery
- DeviceTypeCountQuery
- DeviceTypeListQuery
- DeviceTypeDeleteQuery
- PluginUpdateQuery
- NetworkCountQuery
- NetworkListQuery
- NetworkDeleteQuery
- NotificationListQuery
- NotificationPollManyQuery
- NotificationPollQuery
- UserCountQuery
- UserListQuery
- PluginCountQuery
- PluginListQuery
- PluginRegisterQuery
Object
DeviceHive.command: Look at DeviceCommandAPI.
Object
DeviceHive.configuration : Look at ConfigurationAPI.
Object
DeviceHive.device: Look at DeviceAPI.
Object
DeviceHive.deviceType: Look at deviceTypeAPI.
Object
DeviceHive.info: Look at InfoAPI.
Object
DeviceHive.notification: Look at DeviceNotificationAPI.
Object
DeviceHive.network: Look at NetworkAPI.
Object
DeviceHive.plugin: Look at PluginAPI.
Object
DeviceHive.token: Look at TokenAPI.
Object
DeviceHive.user: Look at UserAPI.
Nested DeviceHive API
ConfigurationAPI
Returns information about the current configuration
- ConfigurationAPI
- .get(name) ⇒
Promise
- .put(configuration) ⇒
Promise
- .delete(name) ⇒
Promise
- .get(name) ⇒
Promise
configurationAPI.get(name) ⇒ Creates ConfigurationAPI
Param | Type |
---|---|
name | number |
Promise
configurationAPI.put(configuration) ⇒ Updates a configuration
Param | Type |
---|---|
configuration | Configuration |
Promise
configurationAPI.delete(name) ⇒ Deletes an existing configuration
Param | Type |
---|---|
name | number |
DeviceAPI
Returns information about the current device
- DeviceAPI
- .get(deviceId) ⇒
Promise
- .list(deviceListQuery) ⇒
Promise
- .count(deviceCountQuery) ⇒
Promise
- .add(device) ⇒
Promise
- .delete(deviceId) ⇒
Promise
- .get(deviceId) ⇒
Promise
deviceAPI.get(deviceId) ⇒ Creates DeviceAPI
Param | Type |
---|---|
deviceId | string |
Promise
deviceAPI.list(deviceListQuery) ⇒ Return a list of devices
Param | Type |
---|---|
deviceListQuery | DeviceListQuery |
Promise
deviceAPI.count(deviceCountQuery) ⇒ Returns count of devices
Param | Type |
---|---|
deviceCountQuery | DeviceCountQuery |
Promise
deviceAPI.add(device) ⇒ Registers or updates a device
Param | Type | Description |
---|---|---|
device | object |
data |
Promise
deviceAPI.delete(deviceId) ⇒ Deletes an existing device
Param | Type |
---|---|
deviceId | string |
DeviceCommandAPI
Returns information about the current command
- DeviceCommandAPI
- .get(deviceId, commandId) ⇒
Promise
- .list(commandListQuery) ⇒
Promise
- .insert(deviceId, command) ⇒
Promise
- .update(command) ⇒
Promise
- .poll(commandPollQuery) ⇒
Promise
- .pollMany(commandPollManyQuery) ⇒
Promise
- .wait(deviceId, commandId) ⇒
Promise
- .subscribe(commandPollQuery) ⇒
Promise
- .unsubscribe(subscriptionId) ⇒
Promise
- .get(deviceId, commandId) ⇒
Promise
deviceCommandAPI.get(deviceId, commandId) ⇒ Creates DeviceCommandAPI
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
commandId | number |
Command ID |
Promise
deviceCommandAPI.list(commandListQuery) ⇒ Return a list of commands
Param | Type |
---|---|
commandListQuery | CommandListQuery |
Promise
deviceCommandAPI.insert(deviceId, command) ⇒ Registers a command
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
command | Command |
Promise
deviceCommandAPI.update(command) ⇒ Updates a command
Param | Type |
---|---|
command | Command |
Promise
deviceCommandAPI.poll(commandPollQuery) ⇒ Param | Type |
---|---|
commandPollQuery | CommandPollQuery |
Promise
deviceCommandAPI.pollMany(commandPollManyQuery) ⇒ Param | Type |
---|---|
commandPollManyQuery | CommandPollManyQuery |
Promise
deviceCommandAPI.wait(deviceId, commandId) ⇒ Param |
---|
deviceId |
commandId |
Promise
deviceCommandAPI.subscribe(commandPollQuery) ⇒ Param | Type |
---|---|
commandPollQuery | CommandPollQuery |
Promise
deviceCommandAPI.unsubscribe(subscriptionId) ⇒ Param | Type |
---|---|
subscriptionId | Number |
DeviceNotificationAPI
Returns information about the current notification
- DeviceNotificationAPI
- .get(deviceId, notificationId) ⇒
Promise
- .list(notificationListQuery) ⇒
Promise
- .insert(notification) ⇒
Promise
- .poll(notificationPollQuery) ⇒
*
- .pollMany(notificationPollManyQuery) ⇒
*
- .subscribe(notificationPollQuery) ⇒
Promise
- .unsubscribe(subscriptionId) ⇒
Promise
- .get(deviceId, notificationId) ⇒
Promise
deviceNotificationAPI.get(deviceId, notificationId) ⇒ Creates DeviceNotificationAPI
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
notificationId | number |
Notification ID |
Promise
deviceNotificationAPI.list(notificationListQuery) ⇒ Return a list of notifications
Param | Type |
---|---|
notificationListQuery | NotificationListQuery |
Promise
deviceNotificationAPI.insert(notification) ⇒ Registers a notification
Param | Type |
---|---|
notification | Notification |
*
deviceNotificationAPI.poll(notificationPollQuery) ⇒ Param | Type |
---|---|
notificationPollQuery | NotificationPollQuery |
*
deviceNotificationAPI.pollMany(notificationPollManyQuery) ⇒ Param | Type |
---|---|
notificationPollManyQuery | NotificationPollManyQuery |
Promise
deviceNotificationAPI.subscribe(notificationPollQuery) ⇒ Param | Type |
---|---|
notificationPollQuery | NotificationPollQuery |
Promise
deviceNotificationAPI.unsubscribe(subscriptionId) ⇒ Param | Type |
---|---|
subscriptionId | Number |
DeviceTypeAPI
Returns information about the current deviceType
- DeviceTypeAPI
- .get(deviceTypeId) ⇒
Promise
- .list(deviceTypeListQuery) ⇒
Promise
- .count(deviceTypeCountQuery) ⇒
Promise
- .insert(deviceType) ⇒
Promise
- .update(deviceType) ⇒
Promise
- .delete(deviceTypeDeleteQuery) ⇒
Promise
- .get(deviceTypeId) ⇒
Promise
deviceTypeAPI.get(deviceTypeId) ⇒ Creates DeviceTypeAPI
Param | Type |
---|---|
deviceTypeId | number |
Promise
deviceTypeAPI.list(deviceTypeListQuery) ⇒ Return a list of deviceTypes
Param | Type |
---|---|
deviceTypeListQuery | DeviceTypeListQuery |
Promise
deviceTypeAPI.count(deviceTypeCountQuery) ⇒ Returns count of deviceTypes
Param | Type |
---|---|
deviceTypeCountQuery | DeviceTypeCountQuery |
Promise
deviceTypeAPI.insert(deviceType) ⇒ Registers a deviceType
Param | Type | Description |
---|---|---|
deviceType | DeviceType |
data |
Promise
deviceTypeAPI.update(deviceType) ⇒ Updates a deviceType
Param | Type | Description |
---|---|---|
deviceType | DeviceType |
data |
Promise
deviceTypeAPI.delete(deviceTypeDeleteQuery) ⇒ Deletes an existing deviceType
Param | Type |
---|---|
deviceTypeDeleteQuery | deviceTypeDeleteQuery |
NetworkAPI
Returns information about the current network
- NetworkAPI
- .get(networkId) ⇒
Promise
- .list(networkListQuery) ⇒
Promise
- .count(networkCountQuery) ⇒
Promise
- .insert(network) ⇒
Promise
- .update(networkId, network) ⇒
Promise
- .delete(networkDeleteQuery) ⇒
Promise
- .get(networkId) ⇒
Promise
networkAPI.get(networkId) ⇒ Returns a network
Param | Type |
---|---|
networkId | number |
Promise
networkAPI.list(networkListQuery) ⇒ Return a list of networks
Param | Type |
---|---|
networkListQuery | NetworkListQuery |
Promise
networkAPI.count(networkCountQuery) ⇒ Returns count of networks
Param | Type |
---|---|
networkCountQuery | NetworkCountQuery |
Promise
networkAPI.insert(network) ⇒ Registers a network
Param | Type | Description |
---|---|---|
network | Network |
data |
Promise
networkAPI.update(networkId, network) ⇒ Updates a network
Param | Type | Description |
---|---|---|
networkId | number |
|
network | Network |
data |
Promise
networkAPI.delete(networkDeleteQuery) ⇒ Deletes an existing network
Param | Type |
---|---|
networkDeleteQuery | networkDeleteQuery |
PluginAPI
Returns information about the current plugin
- PluginAPI
- .list(pluginListQuery) ⇒
Promise
- .count(pluginCountQuery) ⇒
Promise
- .insert(plugin, pluginRegisterQuery) ⇒
Promise
- .update(plugin) ⇒
Promise
- .delete(Plugin) ⇒
Promise
- .list(pluginListQuery) ⇒
Promise
pluginAPI.list(pluginListQuery) ⇒ Return a list of plugins
Param | Type |
---|---|
pluginListQuery | PluginListQuery |
Promise
pluginAPI.count(pluginCountQuery) ⇒ Returns count of plugins
Param | Type |
---|---|
pluginCountQuery | PluginCountQuery |
Promise
pluginAPI.insert(plugin, pluginRegisterQuery) ⇒ Registers a plugin
Param | Type |
---|---|
plugin | Plugin |
pluginRegisterQuery | PluginRegisterQuery |
Promise
pluginAPI.update(plugin) ⇒ Updates a plugin
Param | Type |
---|---|
plugin | Promise |
Promise
pluginAPI.delete(Plugin) ⇒ Deletes an existing plugin
Param | Type |
---|---|
Plugin | object |
InfoAPI
Get server info
infoAPI.getServerInfo()
Creates InfoAPI
infoAPI.getCacheInfo()
Get cache info
infoAPI.getClusterInfo()
Get cluster info
TokenAPI
Authentificate using login and password
tokenAPI.login(login, password)
Creates TokenAPI
Param | Type |
---|---|
login | string |
password | string |
tokenAPI.authPlugin(token)
Create user token
Param | Type | Description |
---|---|---|
token | string |
Plugin token |
tokenAPI.createUserToken(userToken)
Create user token
Param | Type |
---|---|
userToken | UserToken |
tokenAPI.createPluginToken(pluginToken)
Create plugin token
Param | Type |
---|---|
pluginToken | PluginToken |
tokenAPI.refresh(refreshToken)
Refresg token
Param | Type |
---|---|
refreshToken | string |
UserAPI
- ConfigurationAPI
Returns information about the current configuration
- DeviceAPI
Returns information about the current device
- DeviceCommandAPI
Returns information about the current command
- DeviceNotificationAPI
Returns information about the current notification
- DeviceTypeAPI
Returns information about the current deviceType
- NetworkAPI
Returns information about the current network
- PluginAPI
Returns information about the current plugin
- InfoAPI
Get server info
- TokenAPI
Authenticate using login and password
- UserAPI
Return a list of users
ConfigurationAPI
Returns information about the current configuration
- ConfigurationAPI
- .get(name) ⇒
Promise
- .put(configuration) ⇒
Promise
- .delete(name) ⇒
Promise
- .get(name) ⇒
Promise
configurationAPI.get(name) ⇒ Creates ConfigurationAPI
Returns: Promise
- selected configuration
Param | Type |
---|---|
name | number |
Promise
configurationAPI.put(configuration) ⇒ Updates a configuration
Returns: Promise
- count of configuration
Param | Type |
---|---|
configuration | Configuration |
Promise
configurationAPI.delete(name) ⇒ Deletes an existing configuration
Param | Type |
---|---|
name | number |
DeviceAPI
Returns information about the current device
- DeviceAPI
- .get(deviceId) ⇒
Promise
- .list(deviceListQuery) ⇒
Promise
- .count(deviceCountQuery) ⇒
Promise
- .add(device) ⇒
Promise
- .delete(deviceId) ⇒
Promise
- .get(deviceId) ⇒
Promise
deviceAPI.get(deviceId) ⇒ Creates DeviceAPI
Returns: Promise
- selected device
Param | Type |
---|---|
deviceId | string |
Promise
deviceAPI.list(deviceListQuery) ⇒ Return a list of devices
Returns: Promise
- list of devices
Param | Type |
---|---|
deviceListQuery | DeviceListQuery |
Promise
deviceAPI.count(deviceCountQuery) ⇒ Returns count of devices
Returns: Promise
- count of devices
Param | Type |
---|---|
deviceCountQuery | DeviceCountQuery |
Promise
deviceAPI.add(device) ⇒ Registers or updates a device
Returns: Promise
- count of devices
Param | Type | Description |
---|---|---|
device | object |
data |
Promise
deviceAPI.delete(deviceId) ⇒ Deletes an existing device
Param | Type |
---|---|
deviceId | string |
DeviceCommandAPI
Returns information about the current command
- DeviceCommandAPI
- .get(deviceId, commandId) ⇒
Promise
- .list(commandListQuery) ⇒
Promise
- .insert(deviceId, command) ⇒
Promise
- .update(command) ⇒
Promise
- .poll(commandPollQuery) ⇒
Promise
- .pollMany(commandPollManyQuery) ⇒
Promise
- .wait(deviceId, commandId) ⇒
Promise
- .subscribe(commandPollQuery) ⇒
Promise
- .unsubscribe(subscriptionId) ⇒
Promise
- .get(deviceId, commandId) ⇒
Promise
deviceCommandAPI.get(deviceId, commandId) ⇒ Creates DeviceCommandAPI
Returns: Promise
- selected command
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
commandId | number |
Command ID |
Promise
deviceCommandAPI.list(commandListQuery) ⇒ Return a list of commands
Returns: Promise
- list of commands
Param | Type |
---|---|
commandListQuery | CommandListQuery |
Promise
deviceCommandAPI.insert(deviceId, command) ⇒ Registers a command
Returns: Promise
- count of commands
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
command | Command |
Promise
deviceCommandAPI.update(command) ⇒ Updates a command
Returns: Promise
- count of commands
Param | Type |
---|---|
command | Command |
Promise
deviceCommandAPI.poll(commandPollQuery) ⇒ Param | Type |
---|---|
commandPollQuery | CommandPollQuery |
Promise
deviceCommandAPI.pollMany(commandPollManyQuery) ⇒ Param | Type |
---|---|
commandPollManyQuery | CommandPollManyQuery |
Promise
deviceCommandAPI.wait(deviceId, commandId) ⇒ Param |
---|
deviceId |
commandId |
Promise
deviceCommandAPI.subscribe(commandPollQuery) ⇒ Param | Type |
---|---|
commandPollQuery | CommandPollQuery |
Promise
deviceCommandAPI.unsubscribe(subscriptionId) ⇒ Param | Type |
---|---|
subscriptionId | Number |
DeviceNotificationAPI
Returns information about the current notification
- DeviceNotificationAPI
- .get(deviceId, notificationId) ⇒
Promise
- .list(notificationListQuery) ⇒
Promise
- .insert(deviceId, notification) ⇒
Promise
- .poll(notificationPollQuery) ⇒
*
- .pollMany(notificationPollManyQuery) ⇒
*
- .subscribe(notificationPollQuery) ⇒
Promise
- .unsubscribe(subscriptionId) ⇒
Promise
- .get(deviceId, notificationId) ⇒
Promise
deviceNotificationAPI.get(deviceId, notificationId) ⇒ Creates DeviceNotificationAPI
Returns: Promise
- selected notification
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
notificationId | number |
Notification ID |
Promise
deviceNotificationAPI.list(notificationListQuery) ⇒ Return a list of notifications
Returns: Promise
- list of notifications
Param | Type |
---|---|
notificationListQuery | NotificationListQuery |
Promise
deviceNotificationAPI.insert(deviceId, notification) ⇒ Registers a notification
Returns: Promise
- count of notifications
Param | Type |
---|---|
deviceId | Number |
notification | Notification |
*
deviceNotificationAPI.poll(notificationPollQuery) ⇒ Param | Type |
---|---|
notificationPollQuery | NotificationPollQuery |
*
deviceNotificationAPI.pollMany(notificationPollManyQuery) ⇒ Param | Type |
---|---|
notificationPollManyQuery | NotificationPollManyQuery |
Promise
deviceNotificationAPI.subscribe(notificationPollQuery) ⇒ Param | Type |
---|---|
notificationPollQuery | NotificationPollQuery |
Promise
deviceNotificationAPI.unsubscribe(subscriptionId) ⇒ Param | Type |
---|---|
subscriptionId | Number |
DeviceTypeAPI
Returns information about the current deviceType
- DeviceTypeAPI
- .get(deviceTypeId) ⇒
Promise
- .list(deviceTypeListQuery) ⇒
Promise
- .count(deviceTypeCountQuery) ⇒
Promise
- .insert(deviceType) ⇒
Promise
- .update(deviceType) ⇒
Promise
- .delete(deviceTypeDeleteQuery) ⇒
Promise
- .get(deviceTypeId) ⇒
Promise
deviceTypeAPI.get(deviceTypeId) ⇒ Creates DeviceTypeAPI
Returns: Promise
- selected deviceType
Param | Type |
---|---|
deviceTypeId | number |
Promise
deviceTypeAPI.list(deviceTypeListQuery) ⇒ Return a list of deviceTypes
Returns: Promise
- list of deviceTypes
Param | Type |
---|---|
deviceTypeListQuery | DeviceTypeListQuery |
Promise
deviceTypeAPI.count(deviceTypeCountQuery) ⇒ Returns count of deviceTypes
Returns: Promise
- count of deviceTypes
Param | Type |
---|---|
deviceTypeCountQuery | DeviceTypeCountQuery |
Promise
deviceTypeAPI.insert(deviceType) ⇒ Registers a deviceType
Returns: Promise
- count of deviceTypes
Param | Type | Description |
---|---|---|
deviceType | DeviceType |
data |
Promise
deviceTypeAPI.update(deviceType) ⇒ Updates a deviceType
Returns: Promise
- count of deviceTypes
Param | Type | Description |
---|---|---|
deviceType | DeviceType |
data |
Promise
deviceTypeAPI.delete(deviceTypeDeleteQuery) ⇒ Deletes an existing deviceType
Param | Type |
---|---|
deviceTypeDeleteQuery | deviceTypeDeleteQuery |
NetworkAPI
Returns information about the current network
- NetworkAPI
- .get(networkId) ⇒
Promise
- .list(networkListQuery) ⇒
Promise
- .count(networkCountQuery) ⇒
Promise
- .insert(network) ⇒
Promise
- .update(network) ⇒
Promise
- .delete(networkDeleteQuery) ⇒
Promise
- .get(networkId) ⇒
Promise
networkAPI.get(networkId) ⇒ Returns a network
Returns: Promise
- selected network
Param | Type |
---|---|
networkId | number |
Promise
networkAPI.list(networkListQuery) ⇒ Return a list of networks
Returns: Promise
- list of networks
Param | Type |
---|---|
networkListQuery | NetworkListQuery |
Promise
networkAPI.count(networkCountQuery) ⇒ Returns count of networks
Returns: Promise
- count of networks
Param | Type |
---|---|
networkCountQuery | NetworkCountQuery |
Promise
networkAPI.insert(network) ⇒ Registers a network
Returns: Promise
- Network
Param | Type | Description |
---|---|---|
network | Network |
data |
Promise
networkAPI.update(network) ⇒ Updates a network
Returns: Promise
- Network
Param | Type | Description |
---|---|---|
network | Network |
data |
Promise
networkAPI.delete(networkDeleteQuery) ⇒ Deletes an existing network
Returns: Promise
- Network
Param | Type |
---|---|
networkDeleteQuery | networkDeleteQuery |
PluginAPI
Returns information about the current plugin
- PluginAPI
- .list(pluginListQuery) ⇒
Promise
- .count(pluginCountQuery) ⇒
Promise
- .register(plugin, pluginRegisterQuery) ⇒
Promise
- .update(pluginUpdateQuery) ⇒
Promise
- .delete(topicName) ⇒
Promise
- .list(pluginListQuery) ⇒
Promise
pluginAPI.list(pluginListQuery) ⇒ Return a list of plugins
Returns: Promise
- list of plugins
Param | Type |
---|---|
pluginListQuery | PluginListQuery |
Promise
pluginAPI.count(pluginCountQuery) ⇒ Returns count of plugins
Returns: Promise
- count of plugins
Param | Type |
---|---|
pluginCountQuery | PluginCountQuery |
Promise
pluginAPI.register(plugin, pluginRegisterQuery) ⇒ Registers a plugin
Returns: Promise
- Plugin
Param | Type |
---|---|
plugin | Plugin |
pluginRegisterQuery | PluginRegisterQuery |
Promise
pluginAPI.update(pluginUpdateQuery) ⇒ Updates a plugin
Returns: Promise
- Plugin
Param | Type |
---|---|
pluginUpdateQuery | PluginUpdateQuery |
Promise
pluginAPI.delete(topicName) ⇒ Deletes an existing plugin
Returns: Promise
- Plugin
Param | Type |
---|---|
topicName | string |
InfoAPI
Get server info
- InfoAPI
- .getServerInfo() ⇒
Promise
- .getCacheInfo() ⇒
Promise
- .getClusterInfo() ⇒
Promise
- .getServerInfo() ⇒
Promise
infoAPI.getServerInfo() ⇒ Get server info
Promise
infoAPI.getCacheInfo() ⇒ Get cache info
Promise
infoAPI.getClusterInfo() ⇒ Get cluster info
TokenAPI
Authenticate using login and password
tokenAPI.login(login, password)
Creates TokenAPI
Param | Type |
---|---|
login | string |
password | string |
tokenAPI.authPlugin(token)
Create user token
Param | Type | Description |
---|---|---|
token | string |
Plugin token |
tokenAPI.createUserToken(userToken)
Create user token
Param | Type |
---|---|
userToken | UserToken |
tokenAPI.createPluginToken(pluginToken)
Create plugin token
Param | Type |
---|---|
pluginToken | PluginToken |
tokenAPI.refresh(refreshToken)
Refresh token
Param | Type |
---|---|
refreshToken | string |
UserAPI
Return a list of users
- UserAPI
- .list(userListQuery) ⇒
Promise
- .count(userCountQuery) ⇒
Promise
- .get(userId) ⇒
Promise
- .insert(user) ⇒
Promise
- .update(user) ⇒
Promise
- .delete(userId) ⇒
Promise
- .getCurrent() ⇒
Promise
- .updateCurrent(user) ⇒
Promise
- .getDeviceTypes(userId) ⇒
Promise
- .unassignAllDeviceTypes(userId) ⇒
Promise
- .assignAllDeviceTypes(userId) ⇒
Promise
- .unassignDeviceType(userId, deviceTypeId) ⇒
Promise
- .getDeviceType(userId, deviceTypeId) ⇒
Promise
- .assignDeviceType(userId, deviceTypeId) ⇒
Promise
- .getNetwork(userId, networkId) ⇒
Promise
- .assignNetwork(userId, networkId) ⇒
Promise
- .unassignNetwork(userId, networkId) ⇒
Promise
- .list(userListQuery) ⇒
Promise
userAPI.list(userListQuery) ⇒ Creates UserAPI
Returns: Promise
- list of users
Param | Type |
---|---|
userListQuery | UserListQuery |
Promise
userAPI.count(userCountQuery) ⇒ Returns count of users
Returns: Promise
- count of users
Param | Type |
---|---|
userCountQuery | UserCountQuery |
Promise
userAPI.get(userId) ⇒ Returns information about the current user
Returns: Promise
- selected user
Param | Type |
---|---|
userId | number |
Promise
userAPI.insert(user) ⇒ Registers a user
Returns: Promise
- count of users
Param | Type | Description |
---|---|---|
user | User |
data |
Promise
userAPI.update(user) ⇒ Updates a user (only for administrators)
Returns: Promise
- count of users
Param | Type | Description |
---|---|---|
user | User |
data |
Promise
userAPI.delete(userId) ⇒ Deletes an existing user
Param | Type |
---|---|
userId | number |
Promise
userAPI.getCurrent() ⇒ Returns information about the current user
Returns: Promise
- selected user
Promise
userAPI.updateCurrent(user) ⇒ Updates a user (only for administrators)
Returns: Promise
- count of users
Param | Type | Description |
---|---|---|
user | User |
data |
Promise
userAPI.getDeviceTypes(userId) ⇒ Param |
---|
userId |
Promise
userAPI.unassignAllDeviceTypes(userId) ⇒ Param |
---|
userId |
Promise
userAPI.assignAllDeviceTypes(userId) ⇒ Param |
---|
userId |
Promise
userAPI.unassignDeviceType(userId, deviceTypeId) ⇒ Param |
---|
userId |
deviceTypeId |
Promise
userAPI.getDeviceType(userId, deviceTypeId) ⇒ Param |
---|
userId |
deviceTypeId |
Promise
userAPI.assignDeviceType(userId, deviceTypeId) ⇒ Param |
---|
userId |
deviceTypeId |
Promise
userAPI.getNetwork(userId, networkId) ⇒ Gets information about user/network association
Param | Type | Description |
---|---|---|
userId | number |
User ID |
networkId | number |
Network ID |
Promise
userAPI.assignNetwork(userId, networkId) ⇒ Associates network with the user
Param | Type | Description |
---|---|---|
userId | number |
User ID |
networkId | number |
Network ID |
Promise
userAPI.unassignNetwork(userId, networkId) ⇒ Removes association between network and user
Param | Type | Description |
---|---|---|
userId | number |
User ID |
networkId | number |
Network ID |
Models
- Configuration
Configuration model
- Device
Device model
- DeviceCommand
DeviceCommand model
- DeviceNotification
DeviceNotification model
- DeviceType
DeviceType model
- Network
Network model
- Plugin
Plugin model
- PluginToken
PluginToken model
- User
User model
- UserToken
UserToken model
Configuration
Configuration model
new Configuration(options)
Creates new Configuration model
Param | Type | Description |
---|---|---|
options | Object |
model options object |
options.name | string |
Configuration parameter name. |
options.value | string |
Configuration parameter value. |
options.entityVersion | number |
Specifies the version field or property of an entity class. |
Object
configuration.toObject() ⇒ Returns instance as a plain JS object
Device
Device model
- Device
- new Device(options)
- .toObject() ⇒
Object
new Device(options)
Creates new Device model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.id | string |
Device unique identifier |
options.name | string |
Device display name |
options.data | object |
Device data, a JSON object with an arbitrary structure |
options.networkId | number |
Associated network id |
options.deviceTypeId | number |
Associated deviceType id |
options.blocked | boolean |
Indicates whether device is blocked |
Object
device.toObject() ⇒ Returns instance as a plain JS object
DeviceCommand
DeviceCommand model
new DeviceCommand(options)
Creates new DeviceCommand model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.id | number |
Command identifier |
options.command | string |
Command name |
options.timestamp | string |
Command UTC datetime (yyyy-MM-dd'T'HH:mm:ss.SSS ISO 8601) |
options.lastUpdated | string |
Last command update UTC datetime (yyyy-MM-dd'T'HH:mm:ss.SSS ISO 8601) |
options.userId | number |
Associated user identifier |
options.deviceId | string |
Device unique identifier |
options.networkId | number |
Network unique identifier |
options.deviceTypeId | number |
DeviceType unique identifier |
options.parameters | object |
Command parameters, a JSON object with an arbitrary structure |
options.lifetime | number |
Command lifetime, a number of seconds until this command expires |
options.status | string |
Command status, as reported by device or related infrastructure |
options.result | object |
Command execution result, an optional value that could be provided by device |
Object
deviceCommand.toObject() ⇒ Returns instance as a plain JS object
DeviceNotification
DeviceNotification model
new DeviceNotification(options)
Creates new DeviceNotification model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.id | number |
Notification identifier |
options.deviceId | string |
Device unique identifier |
options.networkId | number |
Network unique identifier |
options.deviceTypeId | number |
Device type unique identifier |
options.notification | string |
Notification name |
options.timestamp | string |
Notification UTC datetime (yyyy-MM-dd'T'HH:mm:ss.SSS ISO 8601) |
options.parameters | object |
Notification parameters, a JSON object with an arbitrary structure |
Object
deviceNotification.toObject() ⇒ Returns instance as a plain JS object
DeviceType
DeviceType model
- DeviceType
- new DeviceType(options)
- .toObject() ⇒
Object
new DeviceType(options)
Creates new DeviceType model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.id | number |
Device type identifier |
options.name | string |
Device type name |
options.description | string |
Device type description |
Object
deviceType.toObject() ⇒ Returns instance as a plain JS object
Network
Network model
- Network
- new Network(options)
- .toObject() ⇒
Object
new Network(options)
Creates new Network model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.id | number |
Network identifier |
options.name | string |
Network name |
options.description | string |
Network description |
Object
network.toObject() ⇒ Returns instance as a plain JS object
Plugin
Plugin model
- Plugin
- new Plugin(options)
- .toObject() ⇒
Object
new Plugin(options)
Creates new Plugin model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.id | id |
Plgin unique idnetifier |
options.name | string |
Plugin name |
options.description | string |
Plugin description |
options.topicName | string |
Plugin topic name |
options.filter | string |
Plugin filter |
options.status | string |
Plugin status |
options.subscriptionId | string |
Plugin subscribtion id |
options.userId | number |
Plugin user id |
options.parameters | object |
Json object with parameters |
Object
plugin.toObject() ⇒ Returns instance as a plain JS object
PluginToken
PluginToken model
new PluginToken(options)
Creates new PluginToken model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.actions | Array |
Plugin Token actions |
options.expiration | string |
Plugin expiration |
options.type | number |
Plugin type |
options.topicName | string |
Plugin topic name |
Object
pluginToken.toObject() ⇒ Returns instance as a plain JS object
User
User model
- User
- new User(options)
- .toObject() ⇒
Object
new User(options)
Creates new User model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.id | numebr |
User identifier |
options.login | string |
User login using during authentication |
options.role | number |
User role. Available values: 0: Administrator role, 1: Client role. |
options.status | number |
User status. Available values: 0: The user is active, 1: The user has been locked out due to invalid login attempts, 2: The user has been disabled |
options.lastLogin | string |
User last login timestamp (UTC) |
options.data | object |
User data, a JSON object with an arbitrary structure |
options.password | string |
User Password |
options.introReviewed | boolean |
Indicates if user reviewed an intro |
options.allDeviceTypesAvailable | boolean |
Is all device types awailable |
Object
user.toObject() ⇒ Returns instance as a plain JS object
UserToken
UserToken model
- UserToken
- new UserToken(options)
- .toObject() ⇒
Object
new UserToken(options)
Creates new UserToken model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.userId | number |
User id |
options.actions | Array |
User Actions |
options.networkIds | Array |
Network id's |
options.deviceTypeIds | Array |
Devicetype id's |
options.expiration | string |
Token expiration datetme |
Object
userToken.toObject() ⇒ Returns instance as a plain JS object
Query models
- CommandListQuery
CommandListQuery class
- CommandPollManyQuery
CommandPollManyQuery class
- CommandPollQuery
CommandPollQuery class
- CommandWaitQuery
CommandWaitQuery class
- DeviceCountQuery
DeviceCountQuery class
- DeviceListQuery
DeviceListQuery class
- DeviceTypeCountQuery
DeviceTypeCountQuery class
- DeviceTypeListQuery
DeviceTypeListQuery class
- NetworkCountQuery
NetworkCountQuery class
- NetworkListQuery
NetworkListQuery class
- NotificationListQuery
NotificationListQuery class
- NotificationPollManyQuery
NotificationPollManyQuery class
- NotificationPollQuery
NotificationPollQuery class
- PluginCountQuery
PluginCountQuery class
- PluginListQuery
PluginListQuery class
- PluginRegisterQuery
PluginRegisterQuery class
- PluginUpdateQuery
PluginUpdateQuery class
- UserCountQuery
UserCountQuery class
- UserListQuery
UserListQuery class
CommandListQuery
CommandListQuery class
new CommandListQuery(options)
Creates new CommandListQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.deviceId | string |
Device ID |
options.start | string |
Start timestamp |
options.end | string |
End timestamp |
options.command | string |
Command name |
options.status | string |
Command status |
options.sortField | string |
Sort field |
options.sortOrder | string |
Sort order |
options.take | number |
Limit param |
options.skip | number |
Skip param |
Object
commandListQuery.toObject() ⇒ Returns instance as a plain JS object
CommandPollManyQuery
CommandPollManyQuery class
new CommandPollManyQuery(options)
Creates new CommandPollManyQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.deviceIds | string |
List of device IDs |
options.networkIds | string |
List of network IDs |
options.deviceTypeIds | string |
List of devicetype IDs |
options.names | string |
Command names |
options.timestamp | string |
Timestamp to start from |
options.waitTimeout | number |
Wait timeout in seconds |
options.limit | number |
Limit number of commands |
Object
commandPollManyQuery.toObject() ⇒ Returns instance as a plain JS object
CommandPollQuery
CommandPollQuery class
new CommandPollQuery(options)
Creates new CommandPollQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.deviceId | string |
Device ID |
options.names | string |
Command names |
options.timestamp | number |
Timestamp to start from |
options.returnUpdatedCommands | boolean |
Checks if updated commands should be returned |
options.waitTimeout | number |
Wait timeout in seconds |
options.limit | number |
Limit number of commands |
Object
commandPollQuery.toObject() ⇒ Returns instance as a plain JS object
CommandWaitQuery
CommandWaitQuery class
new CommandWaitQuery(options)
Creates new CommandWaitQuery model
Param | Type | Description |
---|---|---|
options | Object |
model options object |
options.waitTimeout | Number |
wait timeout (sec) |
Object
commandWaitQuery.toObject() ⇒ Returns instance as a plain JS object
DeviceCountQuery
DeviceCountQuery class
new DeviceCountQuery(options)
Creates new DeviceCountQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.name | string |
Filter by device name |
options.namePattern | string |
Filter by device name pattern. In pattern wildcards '%' and '_' can be used |
options.networkId | number |
Filter by associated network identifier |
options.networkName | string |
Filter by associated network name |
Object
deviceCountQuery.toObject() ⇒ Returns instance as a plain JS object
DeviceListQuery
DeviceListQuery class
new DeviceListQuery(options)
Creates new DeviceListQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.name | string |
Filter by device name |
options.namePattern | string |
Filter by device name pattern. In pattern wildcards '%' and '_' can be used |
options.networkId | number |
Filter by associated network identifier |
options.networkName | string |
Filter by associated network name |
options.sortField | string |
Result list sort field |
options.sortOrder | string |
Result list sort order. The sortField should be specified |
options.take | number |
Number of records to take from the result list |
options.skip | number |
Number of records to skip from the result list |
Object
deviceListQuery.toObject() ⇒ Returns instance as a plain JS object
DeviceTypeCountQuery
DeviceTypeCountQuery class
new DeviceTypeCountQuery(options)
Creates new DeviceTypeCountQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.name | string |
Filter by device type name |
options.namePattern | string |
Filter by device type name pattern. In pattern wildcards '%' and '_' can be used |
Object
deviceTypeCountQuery.toObject() ⇒ Returns instance as a plain JS object
DeviceTypeListQuery
DeviceTypeListQuery class
new DeviceTypeListQuery(options)
Creates new DeviceTypeListQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.name | string |
Filter by device type name |
options.namePattern | string |
Filter by device type name pattern. In pattern wildcards '%' and '_' can be used |
options.sortField | string |
Result list sort field |
options.sortOrder | string |
Result list sort order. The sortField should be specified |
options.take | number |
Number of records to take from the result list |
options.skip | number |
Number of records to skip from the result list |
Object
deviceTypeListQuery.toObject() ⇒ Returns instance as a plain JS object
DeviceTypeDeleteQuery
DeviceTypeDeleteQuery class
new DeviceTypeDeleteQuery(options)
Creates new DeviceTypeDeleteQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.deviceTypeId | number |
Id of device type |
options.force | boolean |
Flag, if true then it will delete device type with existing devices |
Object
deviceTypeDeleteQuery.toObject() ⇒ Returns instance as a plain JS object
NetworkCountQuery
NetworkCountQuery class
new NetworkCountQuery(options)
Creates new NetworkCountQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.name | string |
Filter by device type name |
options.namePattern | string |
Filter by device type name pattern. In pattern wildcards '%' and '_' can be used |
Object
networkCountQuery.toObject() ⇒ Returns instance as a plain JS object
NetworkListQuery
NetworkListQuery class
new NetworkListQuery(options)
Creates new NetworkListQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.name | string |
Filter by device type name |
options.namePattern | string |
Filter by device type name pattern. In pattern wildcards '%' and '_' can be used |
options.sortField | string |
Result list sort field |
options.sortOrder | string |
Result list sort order. The sortField should be specified |
options.take | number |
Number of records to take from the result list |
options.skip | number |
Number of records to skip from the result list |
Object
networkListQuery.toObject() ⇒ Returns instance as a plain JS object
NetworkDeleteQuery
NetworkDeleteQuery class
new NetworkDeleteQuery(options)
Creates new NetworkDeleteQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.networkId | number |
Id of network |
options.force | boolean |
Flag, if true then it will delete network with existing devices |
Object
networkDeleteQuery.toObject() ⇒ Returns instance as a plain JS object
NotificationListQuery
NotificationListQuery class
new NotificationListQuery(options)
Creates new NotificationListQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.deviceId | string |
Device ID |
options.start | string |
Start timestamp |
options.end | string |
End timestamp |
options.notification | string |
Notification name |
options.status | string |
Command status |
options.sortField | string |
Sort field |
options.sortOrder | string |
Sort order |
options.take | number |
Limit param |
options.skip | number |
Skip param |
Object
notificationListQuery.toObject() ⇒ Returns instance as a plain JS object
NotificationPollManyQuery
NotificationPollManyQuery class
new NotificationPollManyQuery(options)
Creates new NotificationPollManyQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.deviceIds | string |
List of device IDs |
options.networkIds | string |
List of network IDs |
options.deviceTypeIds | string |
List of devicetype IDs |
options.names | string |
Notification names |
options.timestamp | string |
Timestamp to start from |
options.waitTimeout | number |
Wait timeout in seconds |
Object
notificationPollManyQuery.toObject() ⇒
NotificationPollQuery
NotificationPollQuery class
new NotificationPollQuery(options)
Creates new NotificationPollQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.deviceId | string |
Device ID |
options.names | string |
Notification names |
options.timestamp | number |
Timestamp to start from |
options.waitTimeout | number |
Wait timeout in seconds |
Object
notificationPollQuery.toObject() ⇒ Returns instance as a plain JS object
PluginCountQuery
PluginCountQuery class
new PluginCountQuery(options)
Creates new PluginCountQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.name | string |
Filter by plugin name |
options.namePattern | string |
Filter by plugin name pattern. In pattern wildcards '%' and '_' can be used |
options.topicName | string |
Filter by plugin topic name |
options.status | number |
Filter by plugin status |
options.userId | number |
Filter by associated user identifier. Only admin can see other users' plugins |
Object
pluginCountQuery.toObject() ⇒ Returns instance as a plain JS object
PluginListQuery
PluginListQuery class
new PluginListQuery(options)
Creates new PluginListQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
options.name | string |
Filter by plugin name |
options.namePattern | string |
Filter by plugin name pattern. In pattern wildcards '%' and '_' can be used |
options.topicName | string |
Filter by plugin topic nathis. |
options.status | string |
Filter by plugin status. |
options.userId | number |
Filter by associated user identifier. Only admin can see other users' plugins |
options.sortField | string |
Result list sort field |
options.sortOrder | string |
Result list sort order. The sortField should be specified |
options.take | number |
Number of records to take from the result list |
options.skip | number |
Number of records to skip from the result list |
Object
pluginListQuery.toObject() ⇒ Returns instance as a plain JS object
PluginRegisterQuery
PluginRegisterQuery class
new PluginRegisterQuery(options)
Creates new PluginRegisterQuery model
Param | Type | Description |
---|---|---|
options | object |
model options object |
[options.deviceId] | string |
Device device_id |
[options.networkIds] | string |
Network ids |
[options.deviceTypeIds] | string |
Device type ids |
[options.names] | string |
Command/Notification names |
[options.returnCommands] | boolean |
Checks if commands should be returned |
[options.returnUpdatedCommands] | boolean |
Checks if updated commands should be returned |
[options.returnNotifications] | boolean |
Checks if commands should be returned |
Object
pluginRegisterQuery.toObject() ⇒ Returns instance as a plain JS object
PluginUpdateQuery
PluginUpdateQuery class
new PluginUpdateQuery(options)
Creates Plugin Update Query model
Param | Type | Description |
---|---|---|
options | object |
Options for instance |
options.topicName | string |
Name of topic that was created for the plugin |
[options.deviceId] | string |
Device device_id |
[options.networkIds] | string |
Network ids |
[options.deviceTypeIds] | string |
Device type ids |
[options.names] | string |
Command/Notification names |
[options.returnCommands] | boolean |
Checks if commands should be returned |
[options.returnUpdatedCommands] | boolean |
Checks if updated commands should be returned |
[options.returnNotifications] | boolean |
Checks if commands should be returned |
[options.status] | string |
Plugin status - active or disabled (ACTIVE |
[options.name] | string |
Plugin name |
[options.description] | string |
Plugin description |
[options.parameters] | string |
Plugin parameters |
Object
pluginUpdateQuery.toObject() ⇒
UserCountQuery
UserCountQuery class
new UserCountQuery(options)
Creates User Count Query
Param | Type | Description |
---|---|---|
options | object |
Options for instance |
options.login | string |
Filter by user login |
options.loginPattern | string |
Filter by user login pattern |
options.role | number |
Filter by user login patter |
options.status | number |
Filter by user status. 0 is Active, 1 is Locked Out, 2 is Disabled |
Object
userCountQuery.toObject() ⇒ Returns instance as a plain JS object
UserListQuery
UserListQuery class
new UserListQuery(options)
Creates User List Query
Param | Type | Description |
---|---|---|
options | object |
Options for instance |
options.login | string |
Filter by user login |
options.loginPattern | string |
Filter by user login pattern |
options.role | number |
Filter by user login patter |
options.status | number |
Filter by user status. 0 is Active, 1 is Locked Out, 2 is Disabled |
options.sortField | string |
Result list sort field |
options.sortOrder | string |
Result list sort order. The sortField should be specified |
options.take | number |
Number of records to take from the result list |
options.skip | number |
Number of records to skip from the result list |
Object
userListQuery.toObject() ⇒ Returns instance as a plain JS object