DeviceHive-javascript is promise-based library for using DeviceHive.
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
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.
During development you can use this library with Promises, and Async/Await functions.
Note: Using HTTP/HTTPS you need to pass 3 different service URL`s: mainServiceURL, authServiceURL and pluginServiceURL.
const DeviceHive = require('devicehive');
const httpDeviceHive = new DeviceHive({
login: 'login',
password: 'password',
mainServiceURL: 'http://<host>:<port>/<path>',
authServiceURL: 'http://<host>:<port>/<path>',
pluginServiceURL: 'http://<host>:<port>/<path>'
});
httpDeviceHive.connect();
Note: Using WebSocket you need to pass only one service URL: mainServiceURL.
const DeviceHive = require('devicehive');
const wsDeviceHive= new DeviceHive({
login: 'login',
password: 'password',
mainServiceURL: 'ws://<host>:<port>/<path>'
});
wsDeviceHive.connect();
You can use models described in DeviceHive.models
// Getting Device model
const Device = DeviceHive.models.Device;
// Getting Device list query model
const DeviceListQuery = DeviceHive.models.query.DeviceListQuery;
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 = require('devicehive');
// Getting Device model
const Device = DeviceHive.models.Device
// Getting Device list query model
const DeviceListQuery = DeviceHive.models.query.DeviceListQuery;
// Configurating DeviceHive
const myDeviceHive = new DeviceHive({
login: 'login',
password: 'password',
mainServiceURL: 'ws://<host>:<port>/<path>'
});
// Configurating Device model
const device = new Device({
id: 'myTestId',
name: 'myTestName',
networkId: 1,
deviceTypeId: 1,
blocked: false
});
// Configurating Device List query
const myDeviceListQuery = new DeviceListQuery({
networkId: 1
});
// Push message handler
myDeviceHive.on(DeviceHive.MESSAGE_EVENT, (message) => {
console.log(message);
});
// Error handler
myDeviceHive.on(DeviceHive.ERROR_EVENT, (error) => {
console.error(error);
});
// Connecting and usin API
myDeviceHive.connect()
.then(() => myDeviceHive.device.list(myDeviceListQuery))
.then(data => console.log(data))
.then(() => myDeviceHive.device.add(device))
.then(data => console.log(data))
.then(() => myDeviceHive.device.list(myDeviceListQuery))
.then(data => console.log(data))
.then(() => myDeviceHive.device.delete(device.id))
.then(data => console.log(data))
.then(() => myDeviceHive.device.list(myDeviceListQuery))
.then(data => console.log(data))
.catch(error => console.warn(error));
DeviceHive module
- DeviceHive
- new DeviceHive(options)
- instance
- static
- .models :
Object
- .models :
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) |
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
Look at DeviceCommandAPI.
Look at ConfigurationAPI.
Look at DeviceAPI.
Look at deviceTypeAPI.
Look at InfoAPI.
Look at DeviceNotificationAPI.
Look at NetworkAPI.
Look at PluginAPI.
Look at TokenAPI.
Look at UserAPI.
Returns information about the current configuration
- ConfigurationAPI
- .get(name) ⇒
Promise
- .put(configuration) ⇒
Promise
- .delete(name) ⇒
Promise
- .get(name) ⇒
Creates ConfigurationAPI
Param | Type |
---|---|
name | number |
Updates a configuration
Param | Type |
---|---|
configuration | Configuration |
Deletes an existing configuration
Param | Type |
---|---|
name | number |
Returns information about the current device
- DeviceAPI
- .get(deviceId) ⇒
Promise
- .list(deviceListQuery) ⇒
Promise
- .count(deviceCountQuery) ⇒
Promise
- .add(device) ⇒
Promise
- .delete(deviceId) ⇒
Promise
- .get(deviceId) ⇒
Creates DeviceAPI
Param | Type |
---|---|
deviceId | string |
Return a list of devices
Param | Type |
---|---|
deviceListQuery | DeviceListQuery |
Returns count of devices
Param | Type |
---|---|
deviceCountQuery | DeviceCountQuery |
Registers or updates a device
Param | Type | Description |
---|---|---|
device | object |
data |
Deletes an existing device
Param | Type |
---|---|
deviceId | string |
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) ⇒
Creates DeviceCommandAPI
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
commandId | number |
Command ID |
Return a list of commands
Param | Type |
---|---|
commandListQuery | CommandListQuery |
Registers a command
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
command | Command |
Updates a command
Param | Type |
---|---|
command | Command |
Param | Type |
---|---|
commandPollQuery | CommandPollQuery |
Param | Type |
---|---|
commandPollManyQuery | CommandPollManyQuery |
Param |
---|
deviceId |
commandId |
Param | Type |
---|---|
commandPollQuery | CommandPollQuery |
Param | Type |
---|---|
subscriptionId | Number |
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) ⇒
Creates DeviceNotificationAPI
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
notificationId | number |
Notification ID |
Return a list of notifications
Param | Type |
---|---|
notificationListQuery | NotificationListQuery |
Registers a notification
Param | Type |
---|---|
notification | Notification |
Param | Type |
---|---|
notificationPollQuery | NotificationPollQuery |
Param | Type |
---|---|
notificationPollManyQuery | NotificationPollManyQuery |
Param | Type |
---|---|
notificationPollQuery | NotificationPollQuery |
Param | Type |
---|---|
subscriptionId | Number |
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) ⇒
Creates DeviceTypeAPI
Param | Type |
---|---|
deviceTypeId | number |
Return a list of deviceTypes
Param | Type |
---|---|
deviceTypeListQuery | DeviceTypeListQuery |
Returns count of deviceTypes
Param | Type |
---|---|
deviceTypeCountQuery | DeviceTypeCountQuery |
Registers a deviceType
Param | Type | Description |
---|---|---|
deviceType | DeviceType |
data |
Updates a deviceType
Param | Type | Description |
---|---|---|
deviceType | DeviceType |
data |
Deletes an existing deviceType
Param | Type |
---|---|
deviceTypeDeleteQuery | deviceTypeDeleteQuery |
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) ⇒
Returns a network
Param | Type |
---|---|
networkId | number |
Return a list of networks
Param | Type |
---|---|
networkListQuery | NetworkListQuery |
Returns count of networks
Param | Type |
---|---|
networkCountQuery | NetworkCountQuery |
Registers a network
Param | Type | Description |
---|---|---|
network | Network |
data |
Updates a network
Param | Type | Description |
---|---|---|
networkId | number |
|
network | Network |
data |
Deletes an existing network
Param | Type |
---|---|
networkDeleteQuery | networkDeleteQuery |
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) ⇒
Return a list of plugins
Param | Type |
---|---|
pluginListQuery | PluginListQuery |
Returns count of plugins
Param | Type |
---|---|
pluginCountQuery | PluginCountQuery |
Registers a plugin
Param | Type |
---|---|
plugin | Plugin |
pluginRegisterQuery | PluginRegisterQuery |
Updates a plugin
Param | Type |
---|---|
plugin | Promise |
Deletes an existing plugin
Param | Type |
---|---|
Plugin | object |
Get server info
Creates InfoAPI
Get cache info
Get cluster info
Authentificate using login and password
Creates TokenAPI
Param | Type |
---|---|
login | string |
password | string |
Create user token
Param | Type | Description |
---|---|---|
token | string |
Plugin token |
Create user token
Param | Type |
---|---|
userToken | UserToken |
Create plugin token
Param | Type |
---|---|
pluginToken | PluginToken |
Refresg token
Param | Type |
---|---|
refreshToken | string |
- 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
Returns information about the current configuration
- ConfigurationAPI
- .get(name) ⇒
Promise
- .put(configuration) ⇒
Promise
- .delete(name) ⇒
Promise
- .get(name) ⇒
Creates ConfigurationAPI
Returns: Promise
- selected configuration
Param | Type |
---|---|
name | number |
Updates a configuration
Returns: Promise
- count of configuration
Param | Type |
---|---|
configuration | Configuration |
Deletes an existing configuration
Param | Type |
---|---|
name | number |
Returns information about the current device
- DeviceAPI
- .get(deviceId) ⇒
Promise
- .list(deviceListQuery) ⇒
Promise
- .count(deviceCountQuery) ⇒
Promise
- .add(device) ⇒
Promise
- .delete(deviceId) ⇒
Promise
- .get(deviceId) ⇒
Creates DeviceAPI
Returns: Promise
- selected device
Param | Type |
---|---|
deviceId | string |
Return a list of devices
Returns: Promise
- list of devices
Param | Type |
---|---|
deviceListQuery | DeviceListQuery |
Returns count of devices
Returns: Promise
- count of devices
Param | Type |
---|---|
deviceCountQuery | DeviceCountQuery |
Registers or updates a device
Returns: Promise
- count of devices
Param | Type | Description |
---|---|---|
device | object |
data |
Deletes an existing device
Param | Type |
---|---|
deviceId | string |
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) ⇒
Creates DeviceCommandAPI
Returns: Promise
- selected command
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
commandId | number |
Command ID |
Return a list of commands
Returns: Promise
- list of commands
Param | Type |
---|---|
commandListQuery | CommandListQuery |
Registers a command
Returns: Promise
- count of commands
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
command | Command |
Updates a command
Returns: Promise
- count of commands
Param | Type |
---|---|
command | Command |
Param | Type |
---|---|
commandPollQuery | CommandPollQuery |
Param | Type |
---|---|
commandPollManyQuery | CommandPollManyQuery |
Param |
---|
deviceId |
commandId |
Param | Type |
---|---|
commandPollQuery | CommandPollQuery |
Param | Type |
---|---|
subscriptionId | Number |
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) ⇒
Creates DeviceNotificationAPI
Returns: Promise
- selected notification
Param | Type | Description |
---|---|---|
deviceId | number |
Device ID |
notificationId | number |
Notification ID |
Return a list of notifications
Returns: Promise
- list of notifications
Param | Type |
---|---|
notificationListQuery | NotificationListQuery |
Registers a notification
Returns: Promise
- count of notifications
Param | Type |
---|---|
deviceId | Number |
notification | Notification |
Param | Type |
---|---|
notificationPollQuery | NotificationPollQuery |
Param | Type |
---|---|
notificationPollManyQuery | NotificationPollManyQuery |
Param | Type |
---|---|
notificationPollQuery | NotificationPollQuery |
Param | Type |
---|---|
subscriptionId | Number |
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) ⇒
Creates DeviceTypeAPI
Returns: Promise
- selected deviceType
Param | Type |
---|---|
deviceTypeId | number |
Return a list of deviceTypes
Returns: Promise
- list of deviceTypes
Param | Type |
---|---|
deviceTypeListQuery | DeviceTypeListQuery |
Returns count of deviceTypes
Returns: Promise
- count of deviceTypes
Param | Type |
---|---|
deviceTypeCountQuery | DeviceTypeCountQuery |
Registers a deviceType
Returns: Promise
- count of deviceTypes
Param | Type | Description |
---|---|---|
deviceType | DeviceType |
data |
Updates a deviceType
Returns: Promise
- count of deviceTypes
Param | Type | Description |
---|---|---|
deviceType | DeviceType |
data |
Deletes an existing deviceType
Param | Type |
---|---|
deviceTypeDeleteQuery | deviceTypeDeleteQuery |
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) ⇒
Returns a network
Returns: Promise
- selected network
Param | Type |
---|---|
networkId | number |
Return a list of networks
Returns: Promise
- list of networks
Param | Type |
---|---|
networkListQuery | NetworkListQuery |
Returns count of networks
Returns: Promise
- count of networks
Param | Type |
---|---|
networkCountQuery | NetworkCountQuery |
Registers a network
Returns: Promise
- Network
Param | Type | Description |
---|---|---|
network | Network |
data |
Updates a network
Returns: Promise
- Network
Param | Type | Description |
---|---|---|
network | Network |
data |
Deletes an existing network
Returns: Promise
- Network
Param | Type |
---|---|
networkDeleteQuery | networkDeleteQuery |
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) ⇒
Return a list of plugins
Returns: Promise
- list of plugins
Param | Type |
---|---|
pluginListQuery | PluginListQuery |
Returns count of plugins
Returns: Promise
- count of plugins
Param | Type |
---|---|
pluginCountQuery | PluginCountQuery |
Registers a plugin
Returns: Promise
- Plugin
Param | Type |
---|---|
plugin | Plugin |
pluginRegisterQuery | PluginRegisterQuery |
Updates a plugin
Returns: Promise
- Plugin
Param | Type |
---|---|
pluginUpdateQuery | PluginUpdateQuery |
Deletes an existing plugin
Returns: Promise
- Plugin
Param | Type |
---|---|
topicName | string |
Get server info
- InfoAPI
- .getServerInfo() ⇒
Promise
- .getCacheInfo() ⇒
Promise
- .getClusterInfo() ⇒
Promise
- .getServerInfo() ⇒
Get server info
Get cache info
Get cluster info
Authenticate using login and password
Creates TokenAPI
Param | Type |
---|---|
login | string |
password | string |
Create user token
Param | Type | Description |
---|---|---|
token | string |
Plugin token |
Create user token
Param | Type |
---|---|
userToken | UserToken |
Create plugin token
Param | Type |
---|---|
pluginToken | PluginToken |
Refresh token
Param | Type |
---|---|
refreshToken | string |
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) ⇒
Creates UserAPI
Returns: Promise
- list of users
Param | Type |
---|---|
userListQuery | UserListQuery |
Returns count of users
Returns: Promise
- count of users
Param | Type |
---|---|
userCountQuery | UserCountQuery |
Returns information about the current user
Returns: Promise
- selected user
Param | Type |
---|---|
userId | number |
Registers a user
Returns: Promise
- count of users
Param | Type | Description |
---|---|---|
user | User |
data |
Updates a user (only for administrators)
Returns: Promise
- count of users
Param | Type | Description |
---|---|---|
user | User |
data |
Deletes an existing user
Param | Type |
---|---|
userId | number |
Returns information about the current user
Returns: Promise
- selected user
Updates a user (only for administrators)
Returns: Promise
- count of users
Param | Type | Description |
---|---|---|
user | User |
data |
Param |
---|
userId |
Param |
---|
userId |
Param |
---|
userId |
Param |
---|
userId |
deviceTypeId |
Param |
---|
userId |
deviceTypeId |
Param |
---|
userId |
deviceTypeId |
Gets information about user/network association
Param | Type | Description |
---|---|---|
userId | number |
User ID |
networkId | number |
Network ID |
Associates network with the user
Param | Type | Description |
---|---|---|
userId | number |
User ID |
networkId | number |
Network ID |
Removes association between network and user
Param | Type | Description |
---|---|---|
userId | number |
User ID |
networkId | number |
Network ID |
- 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 model
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. |
Returns instance as a plain JS object
Device model
- Device
- new Device(options)
- .toObject() ⇒
Object
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 |
Returns instance as a plain JS object
DeviceCommand model
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 |
Returns instance as a plain JS object
DeviceNotification model
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 |
Returns instance as a plain JS object
DeviceType model
- DeviceType
- new DeviceType(options)
- .toObject() ⇒
Object
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 |
Returns instance as a plain JS object
Network model
- Network
- new Network(options)
- .toObject() ⇒
Object
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 |
Returns instance as a plain JS object
Plugin model
- Plugin
- new Plugin(options)
- .toObject() ⇒
Object
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 |
Returns instance as a plain JS object
PluginToken model
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 |
Returns instance as a plain JS object
User model
- User
- new User(options)
- .toObject() ⇒
Object
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 |
Returns instance as a plain JS object
UserToken model
- UserToken
- new UserToken(options)
- .toObject() ⇒
Object
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 |
Returns instance as a plain JS object
- 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 class
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 |
Returns instance as a plain JS object
CommandPollManyQuery class
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 |
Returns instance as a plain JS object
CommandPollQuery class
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 |
Returns instance as a plain JS object
CommandWaitQuery class
Creates new CommandWaitQuery model
Param | Type | Description |
---|---|---|
options | Object |
model options object |
options.waitTimeout | Number |
wait timeout (sec) |
Returns instance as a plain JS object
DeviceCountQuery class
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 |
Returns instance as a plain JS object
DeviceListQuery class
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 |
Returns instance as a plain JS object
DeviceTypeCountQuery class
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 |
Returns instance as a plain JS object
DeviceTypeListQuery class
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 |
Returns instance as a plain JS object
DeviceTypeDeleteQuery class
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 |
Returns instance as a plain JS object
NetworkCountQuery class
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 |
Returns instance as a plain JS object
NetworkListQuery class
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 |
Returns instance as a plain JS object
NetworkDeleteQuery class
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 |
Returns instance as a plain JS object
NotificationListQuery class
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 |
Returns instance as a plain JS object
NotificationPollManyQuery class
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 |
NotificationPollQuery class
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 |
Returns instance as a plain JS object
PluginCountQuery class
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 |
Returns instance as a plain JS object
PluginListQuery class
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 |
Returns instance as a plain JS object
PluginRegisterQuery class
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 |
Returns instance as a plain JS object
PluginUpdateQuery class
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 |
UserCountQuery class
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 |
Returns instance as a plain JS object
UserListQuery class
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 |
Returns instance as a plain JS object