2.1.0 • Published 6 years ago

devicehive v2.1.0

Weekly downloads
6
License
Apache-2.0
Repository
github
Last release
6 years ago

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: 1. Clone repo; 2. Inside repo folder run npm install; 3. Inside repo folder run npm run build; 4. Get devicehive.js/devicehive.min.js in dist 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 = 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();

Using WebSocket

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();

Using Models

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;

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 = 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));

API Reference

DeviceHive

DeviceHive module

new DeviceHive(options)

DeviceHive module

ParamTypeDescription
optionsobjectInitial settings
options.accessTokenstringAccess token
options.refreshTokenstringRefresh token
options.loginstringLogin
options.passwordstringPassword
options.mainServiceURLstringMain Service URL
options.authServiceURLstringAuth Service URL (required only for http)
options.pluginServiceURLstringPlugin Service URL (required only for http)
options.autoUpdateSessionbooleanFlag 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) |

DeviceHive.models : Object

Returns DeviceHive models

DeviceHive.command: Object

Look at DeviceCommandAPI.

DeviceHive.configuration : Object

Look at ConfigurationAPI.

DeviceHive.device: Object

Look at DeviceAPI.

DeviceHive.deviceType: Object

Look at deviceTypeAPI.

DeviceHive.info: Object

Look at InfoAPI.

DeviceHive.notification: Object

Look at DeviceNotificationAPI.

DeviceHive.network: Object

Look at NetworkAPI.

DeviceHive.plugin: Object

Look at PluginAPI.

DeviceHive.token: Object

Look at TokenAPI.

DeviceHive.user: Object

Look at UserAPI.


Nested DeviceHive API

ConfigurationAPI

Returns information about the current configuration

configurationAPI.get(name) ⇒ Promise

Creates ConfigurationAPI

ParamType
namenumber

configurationAPI.put(configuration) ⇒ Promise

Updates a configuration

ParamType
configurationConfiguration

configurationAPI.delete(name) ⇒ Promise

Deletes an existing configuration

ParamType
namenumber

DeviceAPI

Returns information about the current device

deviceAPI.get(deviceId) ⇒ Promise

Creates DeviceAPI

ParamType
deviceIdstring

deviceAPI.list(deviceListQuery) ⇒ Promise

Return a list of devices

ParamType
deviceListQueryDeviceListQuery

deviceAPI.count(deviceCountQuery) ⇒ Promise

Returns count of devices

ParamType
deviceCountQueryDeviceCountQuery

deviceAPI.add(device) ⇒ Promise

Registers or updates a device

ParamTypeDescription
deviceobjectdata

deviceAPI.delete(deviceId) ⇒ Promise

Deletes an existing device

ParamType
deviceIdstring

DeviceCommandAPI

Returns information about the current command

deviceCommandAPI.get(deviceId, commandId) ⇒ Promise

Creates DeviceCommandAPI

ParamTypeDescription
deviceIdnumberDevice ID
commandIdnumberCommand ID

deviceCommandAPI.list(commandListQuery) ⇒ Promise

Return a list of commands

ParamType
commandListQueryCommandListQuery

deviceCommandAPI.insert(deviceId, command) ⇒ Promise

Registers a command

ParamTypeDescription
deviceIdnumberDevice ID
commandCommand

deviceCommandAPI.update(command) ⇒ Promise

Updates a command

ParamType
commandCommand

deviceCommandAPI.poll(commandPollQuery) ⇒ Promise

ParamType
commandPollQueryCommandPollQuery

deviceCommandAPI.pollMany(commandPollManyQuery) ⇒ Promise

ParamType
commandPollManyQueryCommandPollManyQuery

deviceCommandAPI.wait(deviceId, commandId) ⇒ Promise

Param
deviceId
commandId

deviceCommandAPI.subscribe(commandPollQuery) ⇒ Promise

ParamType
commandPollQueryCommandPollQuery

deviceCommandAPI.unsubscribe(subscriptionId) ⇒ Promise

ParamType
subscriptionIdNumber

DeviceNotificationAPI

Returns information about the current notification

deviceNotificationAPI.get(deviceId, notificationId) ⇒ Promise

Creates DeviceNotificationAPI

ParamTypeDescription
deviceIdnumberDevice ID
notificationIdnumberNotification ID

deviceNotificationAPI.list(notificationListQuery) ⇒ Promise

Return a list of notifications

ParamType
notificationListQueryNotificationListQuery

deviceNotificationAPI.insert(notification) ⇒ Promise

Registers a notification

ParamType
notificationNotification

deviceNotificationAPI.poll(notificationPollQuery) ⇒ *

ParamType
notificationPollQueryNotificationPollQuery

deviceNotificationAPI.pollMany(notificationPollManyQuery) ⇒ *

ParamType
notificationPollManyQueryNotificationPollManyQuery

deviceNotificationAPI.subscribe(notificationPollQuery) ⇒ Promise

ParamType
notificationPollQueryNotificationPollQuery

deviceNotificationAPI.unsubscribe(subscriptionId) ⇒ Promise

ParamType
subscriptionIdNumber

DeviceTypeAPI

Returns information about the current deviceType

deviceTypeAPI.get(deviceTypeId) ⇒ Promise

Creates DeviceTypeAPI

ParamType
deviceTypeIdnumber

deviceTypeAPI.list(deviceTypeListQuery) ⇒ Promise

Return a list of deviceTypes

ParamType
deviceTypeListQueryDeviceTypeListQuery

deviceTypeAPI.count(deviceTypeCountQuery) ⇒ Promise

Returns count of deviceTypes

ParamType
deviceTypeCountQueryDeviceTypeCountQuery

deviceTypeAPI.insert(deviceType) ⇒ Promise

Registers a deviceType

ParamTypeDescription
deviceTypeDeviceTypedata

deviceTypeAPI.update(deviceType) ⇒ Promise

Updates a deviceType

ParamTypeDescription
deviceTypeDeviceTypedata

deviceTypeAPI.delete(deviceTypeDeleteQuery) ⇒ Promise

Deletes an existing deviceType

ParamType
deviceTypeDeleteQuerydeviceTypeDeleteQuery

NetworkAPI

Returns information about the current network

networkAPI.get(networkId) ⇒ Promise

Returns a network

ParamType
networkIdnumber

networkAPI.list(networkListQuery) ⇒ Promise

Return a list of networks

ParamType
networkListQueryNetworkListQuery

networkAPI.count(networkCountQuery) ⇒ Promise

Returns count of networks

ParamType
networkCountQueryNetworkCountQuery

networkAPI.insert(network) ⇒ Promise

Registers a network

ParamTypeDescription
networkNetworkdata

networkAPI.update(networkId, network) ⇒ Promise

Updates a network

ParamTypeDescription
networkIdnumber
networkNetworkdata

networkAPI.delete(networkDeleteQuery) ⇒ Promise

Deletes an existing network

ParamType
networkDeleteQuerynetworkDeleteQuery

PluginAPI

Returns information about the current plugin

pluginAPI.list(pluginListQuery) ⇒ Promise

Return a list of plugins

ParamType
pluginListQueryPluginListQuery

pluginAPI.count(pluginCountQuery) ⇒ Promise

Returns count of plugins

ParamType
pluginCountQueryPluginCountQuery

pluginAPI.insert(plugin, pluginRegisterQuery) ⇒ Promise

Registers a plugin

ParamType
pluginPlugin
pluginRegisterQueryPluginRegisterQuery

pluginAPI.update(plugin) ⇒ Promise

Updates a plugin

ParamType
pluginPromise

pluginAPI.delete(Plugin) ⇒ Promise

Deletes an existing plugin

ParamType
Pluginobject

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

ParamType
loginstring
passwordstring

tokenAPI.authPlugin(token)

Create user token

ParamTypeDescription
tokenstringPlugin token

tokenAPI.createUserToken(userToken)

Create user token

ParamType
userTokenUserToken

tokenAPI.createPluginToken(pluginToken)

Create plugin token

ParamType
pluginTokenPluginToken

tokenAPI.refresh(refreshToken)

Refresg token

ParamType
refreshTokenstring

UserAPI

ConfigurationAPI

Returns information about the current configuration

configurationAPI.get(name) ⇒ Promise

Creates ConfigurationAPI

Returns: Promise - selected configuration

ParamType
namenumber

configurationAPI.put(configuration) ⇒ Promise

Updates a configuration

Returns: Promise - count of configuration

ParamType
configurationConfiguration

configurationAPI.delete(name) ⇒ Promise

Deletes an existing configuration

ParamType
namenumber

DeviceAPI

Returns information about the current device

deviceAPI.get(deviceId) ⇒ Promise

Creates DeviceAPI

Returns: Promise - selected device

ParamType
deviceIdstring

deviceAPI.list(deviceListQuery) ⇒ Promise

Return a list of devices

Returns: Promise - list of devices

ParamType
deviceListQueryDeviceListQuery

deviceAPI.count(deviceCountQuery) ⇒ Promise

Returns count of devices

Returns: Promise - count of devices

ParamType
deviceCountQueryDeviceCountQuery

deviceAPI.add(device) ⇒ Promise

Registers or updates a device

Returns: Promise - count of devices

ParamTypeDescription
deviceobjectdata

deviceAPI.delete(deviceId) ⇒ Promise

Deletes an existing device

ParamType
deviceIdstring

DeviceCommandAPI

Returns information about the current command

deviceCommandAPI.get(deviceId, commandId) ⇒ Promise

Creates DeviceCommandAPI

Returns: Promise - selected command

ParamTypeDescription
deviceIdnumberDevice ID
commandIdnumberCommand ID

deviceCommandAPI.list(commandListQuery) ⇒ Promise

Return a list of commands

Returns: Promise - list of commands

ParamType
commandListQueryCommandListQuery

deviceCommandAPI.insert(deviceId, command) ⇒ Promise

Registers a command

Returns: Promise - count of commands

ParamTypeDescription
deviceIdnumberDevice ID
commandCommand

deviceCommandAPI.update(command) ⇒ Promise

Updates a command

Returns: Promise - count of commands

ParamType
commandCommand

deviceCommandAPI.poll(commandPollQuery) ⇒ Promise

ParamType
commandPollQueryCommandPollQuery

deviceCommandAPI.pollMany(commandPollManyQuery) ⇒ Promise

ParamType
commandPollManyQueryCommandPollManyQuery

deviceCommandAPI.wait(deviceId, commandId) ⇒ Promise

Param
deviceId
commandId

deviceCommandAPI.subscribe(commandPollQuery) ⇒ Promise

ParamType
commandPollQueryCommandPollQuery

deviceCommandAPI.unsubscribe(subscriptionId) ⇒ Promise

ParamType
subscriptionIdNumber

DeviceNotificationAPI

Returns information about the current notification

deviceNotificationAPI.get(deviceId, notificationId) ⇒ Promise

Creates DeviceNotificationAPI

Returns: Promise - selected notification

ParamTypeDescription
deviceIdnumberDevice ID
notificationIdnumberNotification ID

deviceNotificationAPI.list(notificationListQuery) ⇒ Promise

Return a list of notifications

Returns: Promise - list of notifications

ParamType
notificationListQueryNotificationListQuery

deviceNotificationAPI.insert(deviceId, notification) ⇒ Promise

Registers a notification

Returns: Promise - count of notifications

ParamType
deviceIdNumber
notificationNotification

deviceNotificationAPI.poll(notificationPollQuery) ⇒ *

ParamType
notificationPollQueryNotificationPollQuery

deviceNotificationAPI.pollMany(notificationPollManyQuery) ⇒ *

ParamType
notificationPollManyQueryNotificationPollManyQuery

deviceNotificationAPI.subscribe(notificationPollQuery) ⇒ Promise

ParamType
notificationPollQueryNotificationPollQuery

deviceNotificationAPI.unsubscribe(subscriptionId) ⇒ Promise

ParamType
subscriptionIdNumber

DeviceTypeAPI

Returns information about the current deviceType

deviceTypeAPI.get(deviceTypeId) ⇒ Promise

Creates DeviceTypeAPI

Returns: Promise - selected deviceType

ParamType
deviceTypeIdnumber

deviceTypeAPI.list(deviceTypeListQuery) ⇒ Promise

Return a list of deviceTypes

Returns: Promise - list of deviceTypes

ParamType
deviceTypeListQueryDeviceTypeListQuery

deviceTypeAPI.count(deviceTypeCountQuery) ⇒ Promise

Returns count of deviceTypes

Returns: Promise - count of deviceTypes

ParamType
deviceTypeCountQueryDeviceTypeCountQuery

deviceTypeAPI.insert(deviceType) ⇒ Promise

Registers a deviceType

Returns: Promise - count of deviceTypes

ParamTypeDescription
deviceTypeDeviceTypedata

deviceTypeAPI.update(deviceType) ⇒ Promise

Updates a deviceType

Returns: Promise - count of deviceTypes

ParamTypeDescription
deviceTypeDeviceTypedata

deviceTypeAPI.delete(deviceTypeDeleteQuery) ⇒ Promise

Deletes an existing deviceType

ParamType
deviceTypeDeleteQuerydeviceTypeDeleteQuery

NetworkAPI

Returns information about the current network

networkAPI.get(networkId) ⇒ Promise

Returns a network

Returns: Promise - selected network

ParamType
networkIdnumber

networkAPI.list(networkListQuery) ⇒ Promise

Return a list of networks

Returns: Promise - list of networks

ParamType
networkListQueryNetworkListQuery

networkAPI.count(networkCountQuery) ⇒ Promise

Returns count of networks

Returns: Promise - count of networks

ParamType
networkCountQueryNetworkCountQuery

networkAPI.insert(network) ⇒ Promise

Registers a network

Returns: Promise - Network

ParamTypeDescription
networkNetworkdata

networkAPI.update(network) ⇒ Promise

Updates a network

Returns: Promise - Network

ParamTypeDescription
networkNetworkdata

networkAPI.delete(networkDeleteQuery) ⇒ Promise

Deletes an existing network

Returns: Promise - Network

ParamType
networkDeleteQuerynetworkDeleteQuery

PluginAPI

Returns information about the current plugin

pluginAPI.list(pluginListQuery) ⇒ Promise

Return a list of plugins

Returns: Promise - list of plugins

ParamType
pluginListQueryPluginListQuery

pluginAPI.count(pluginCountQuery) ⇒ Promise

Returns count of plugins

Returns: Promise - count of plugins

ParamType
pluginCountQueryPluginCountQuery

pluginAPI.register(plugin, pluginRegisterQuery) ⇒ Promise

Registers a plugin

Returns: Promise - Plugin

ParamType
pluginPlugin
pluginRegisterQueryPluginRegisterQuery

pluginAPI.update(pluginUpdateQuery) ⇒ Promise

Updates a plugin

Returns: Promise - Plugin

ParamType
pluginUpdateQueryPluginUpdateQuery

pluginAPI.delete(topicName) ⇒ Promise

Deletes an existing plugin

Returns: Promise - Plugin

ParamType
topicNamestring

InfoAPI

Get server info

infoAPI.getServerInfo() ⇒ Promise

Get server info

infoAPI.getCacheInfo() ⇒ Promise

Get cache info

infoAPI.getClusterInfo() ⇒ Promise

Get cluster info

TokenAPI

Authenticate using login and password

tokenAPI.login(login, password)

Creates TokenAPI

ParamType
loginstring
passwordstring

tokenAPI.authPlugin(token)

Create user token

ParamTypeDescription
tokenstringPlugin token

tokenAPI.createUserToken(userToken)

Create user token

ParamType
userTokenUserToken

tokenAPI.createPluginToken(pluginToken)

Create plugin token

ParamType
pluginTokenPluginToken

tokenAPI.refresh(refreshToken)

Refresh token

ParamType
refreshTokenstring

UserAPI

Return a list of users

userAPI.list(userListQuery) ⇒ Promise

Creates UserAPI

Returns: Promise - list of users

ParamType
userListQueryUserListQuery

userAPI.count(userCountQuery) ⇒ Promise

Returns count of users

Returns: Promise - count of users

ParamType
userCountQueryUserCountQuery

userAPI.get(userId) ⇒ Promise

Returns information about the current user

Returns: Promise - selected user

ParamType
userIdnumber

userAPI.insert(user) ⇒ Promise

Registers a user

Returns: Promise - count of users

ParamTypeDescription
userUserdata

userAPI.update(user) ⇒ Promise

Updates a user (only for administrators)

Returns: Promise - count of users

ParamTypeDescription
userUserdata

userAPI.delete(userId) ⇒ Promise

Deletes an existing user

ParamType
userIdnumber

userAPI.getCurrent() ⇒ Promise

Returns information about the current user

Returns: Promise - selected user

userAPI.updateCurrent(user) ⇒ Promise

Updates a user (only for administrators)

Returns: Promise - count of users

ParamTypeDescription
userUserdata

userAPI.getDeviceTypes(userId) ⇒ Promise

Param
userId

userAPI.unassignAllDeviceTypes(userId) ⇒ Promise

Param
userId

userAPI.assignAllDeviceTypes(userId) ⇒ Promise

Param
userId

userAPI.unassignDeviceType(userId, deviceTypeId) ⇒ Promise

Param
userId
deviceTypeId

userAPI.getDeviceType(userId, deviceTypeId) ⇒ Promise

Param
userId
deviceTypeId

userAPI.assignDeviceType(userId, deviceTypeId) ⇒ Promise

Param
userId
deviceTypeId

userAPI.getNetwork(userId, networkId) ⇒ Promise

Gets information about user/network association

ParamTypeDescription
userIdnumberUser ID
networkIdnumberNetwork ID

userAPI.assignNetwork(userId, networkId) ⇒ Promise

Associates network with the user

ParamTypeDescription
userIdnumberUser ID
networkIdnumberNetwork ID

userAPI.unassignNetwork(userId, networkId) ⇒ Promise

Removes association between network and user

ParamTypeDescription
userIdnumberUser ID
networkIdnumberNetwork ID

Models

Configuration

Configuration model

new Configuration(options)

Creates new Configuration model

ParamTypeDescription
optionsObjectmodel options object
options.namestringConfiguration parameter name.
options.valuestringConfiguration parameter value.
options.entityVersionnumberSpecifies the version field or property of an entity class.

configuration.toObject() ⇒ Object

Returns instance as a plain JS object

Device

Device model

new Device(options)

Creates new Device model

ParamTypeDescription
optionsobjectmodel options object
options.idstringDevice unique identifier
options.namestringDevice display name
options.dataobjectDevice data, a JSON object with an arbitrary structure
options.networkIdnumberAssociated network id
options.deviceTypeIdnumberAssociated deviceType id
options.blockedbooleanIndicates whether device is blocked

device.toObject() ⇒ Object

Returns instance as a plain JS object

DeviceCommand

DeviceCommand model

new DeviceCommand(options)

Creates new DeviceCommand model

ParamTypeDescription
optionsobjectmodel options object
options.idnumberCommand identifier
options.commandstringCommand name
options.timestampstringCommand UTC datetime (yyyy-MM-dd'T'HH:mm:ss.SSS ISO 8601)
options.lastUpdatedstringLast command update UTC datetime (yyyy-MM-dd'T'HH:mm:ss.SSS ISO 8601)
options.userIdnumberAssociated user identifier
options.deviceIdstringDevice unique identifier
options.networkIdnumberNetwork unique identifier
options.deviceTypeIdnumberDeviceType unique identifier
options.parametersobjectCommand parameters, a JSON object with an arbitrary structure
options.lifetimenumberCommand lifetime, a number of seconds until this command expires
options.statusstringCommand status, as reported by device or related infrastructure
options.resultobjectCommand execution result, an optional value that could be provided by device

deviceCommand.toObject() ⇒ Object

Returns instance as a plain JS object

DeviceNotification

DeviceNotification model

new DeviceNotification(options)

Creates new DeviceNotification model

ParamTypeDescription
optionsobjectmodel options object
options.idnumberNotification identifier
options.deviceIdstringDevice unique identifier
options.networkIdnumberNetwork unique identifier
options.deviceTypeIdnumberDevice type unique identifier
options.notificationstringNotification name
options.timestampstringNotification UTC datetime (yyyy-MM-dd'T'HH:mm:ss.SSS ISO 8601)
options.parametersobjectNotification parameters, a JSON object with an arbitrary structure

deviceNotification.toObject() ⇒ Object

Returns instance as a plain JS object

DeviceType

DeviceType model

new DeviceType(options)

Creates new DeviceType model

ParamTypeDescription
optionsobjectmodel options object
options.idnumberDevice type identifier
options.namestringDevice type name
options.descriptionstringDevice type description

deviceType.toObject() ⇒ Object

Returns instance as a plain JS object

Network

Network model

new Network(options)

Creates new Network model

ParamTypeDescription
optionsobjectmodel options object
options.idnumberNetwork identifier
options.namestringNetwork name
options.descriptionstringNetwork description

network.toObject() ⇒ Object

Returns instance as a plain JS object

Plugin

Plugin model

new Plugin(options)

Creates new Plugin model

ParamTypeDescription
optionsobjectmodel options object
options.ididPlgin unique idnetifier
options.namestringPlugin name
options.descriptionstringPlugin description
options.topicNamestringPlugin topic name
options.filterstringPlugin filter
options.statusstringPlugin status
options.subscriptionIdstringPlugin subscribtion id
options.userIdnumberPlugin user id
options.parametersobjectJson object with parameters

plugin.toObject() ⇒ Object

Returns instance as a plain JS object

PluginToken

PluginToken model

new PluginToken(options)

Creates new PluginToken model

ParamTypeDescription
optionsobjectmodel options object
options.actionsArrayPlugin Token actions
options.expirationstringPlugin expiration
options.typenumberPlugin type
options.topicNamestringPlugin topic name

pluginToken.toObject() ⇒ Object

Returns instance as a plain JS object

User

User model

new User(options)

Creates new User model

ParamTypeDescription
optionsobjectmodel options object
options.idnumebrUser identifier
options.loginstringUser login using during authentication
options.rolenumberUser role. Available values: 0: Administrator role, 1: Client role.
options.statusnumberUser 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.lastLoginstringUser last login timestamp (UTC)
options.dataobjectUser data, a JSON object with an arbitrary structure
options.passwordstringUser Password
options.introReviewedbooleanIndicates if user reviewed an intro
options.allDeviceTypesAvailablebooleanIs all device types awailable

user.toObject() ⇒ Object

Returns instance as a plain JS object

UserToken

UserToken model

new UserToken(options)

Creates new UserToken model

ParamTypeDescription
optionsobjectmodel options object
options.userIdnumberUser id
options.actionsArrayUser Actions
options.networkIdsArrayNetwork id's
options.deviceTypeIdsArrayDevicetype id's
options.expirationstringToken expiration datetme

userToken.toObject() ⇒ Object

Returns instance as a plain JS object

Query models

CommandListQuery

CommandListQuery class

new CommandListQuery(options)

Creates new CommandListQuery model

ParamTypeDescription
optionsobjectmodel options object
options.deviceIdstringDevice ID
options.startstringStart timestamp
options.endstringEnd timestamp
options.commandstringCommand name
options.statusstringCommand status
options.sortFieldstringSort field
options.sortOrderstringSort order
options.takenumberLimit param
options.skipnumberSkip param

commandListQuery.toObject() ⇒ Object

Returns instance as a plain JS object

CommandPollManyQuery

CommandPollManyQuery class

new CommandPollManyQuery(options)

Creates new CommandPollManyQuery model

ParamTypeDescription
optionsobjectmodel options object
options.deviceIdsstringList of device IDs
options.networkIdsstringList of network IDs
options.deviceTypeIdsstringList of devicetype IDs
options.namesstringCommand names
options.timestampstringTimestamp to start from
options.waitTimeoutnumberWait timeout in seconds
options.limitnumberLimit number of commands

commandPollManyQuery.toObject() ⇒ Object

Returns instance as a plain JS object

CommandPollQuery

CommandPollQuery class

new CommandPollQuery(options)

Creates new CommandPollQuery model

ParamTypeDescription
optionsobjectmodel options object
options.deviceIdstringDevice ID
options.namesstringCommand names
options.timestampnumberTimestamp to start from
options.returnUpdatedCommandsbooleanChecks if updated commands should be returned
options.waitTimeoutnumberWait timeout in seconds
options.limitnumberLimit number of commands

commandPollQuery.toObject() ⇒ Object

Returns instance as a plain JS object

CommandWaitQuery

CommandWaitQuery class

new CommandWaitQuery(options)

Creates new CommandWaitQuery model

ParamTypeDescription
optionsObjectmodel options object
options.waitTimeoutNumberwait timeout (sec)

commandWaitQuery.toObject() ⇒ Object

Returns instance as a plain JS object

DeviceCountQuery

DeviceCountQuery class

new DeviceCountQuery(options)

Creates new DeviceCountQuery model

ParamTypeDescription
optionsobjectmodel options object
options.namestringFilter by device name
options.namePatternstringFilter by device name pattern. In pattern wildcards '%' and '_' can be used
options.networkIdnumberFilter by associated network identifier
options.networkNamestringFilter by associated network name

deviceCountQuery.toObject() ⇒ Object

Returns instance as a plain JS object

DeviceListQuery

DeviceListQuery class

<a name="new_DeviceListQ

2.1.0

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago