Welcome to the Agile SDK documentation.
This document aims to describe all the functions supported by the SDK, as well as showing examples of their expected usage.
If you feel something is missing, not clear or could be improved, please don't hesitate to open an issue in GitHub, we'll be happy to help.
Kind: global namespace
Type | Description |
---|---|
Object |
including the api base url, idm base url (if not provided defaults to the same api host but default idm port), and a token. |
Example
var agile = require('agile-sdk')({
api:'http://agile-core:8080',
idm: 'http://agile-core:3000',
data: 'http://agile-data:1338',
token: 'zIOycOqbEQh4ayw7lGAm9ILBIr'
})
- agile ⇒
Object
- .protocolManager :
object
- .discovery :
object
- .start([protocolId]) ⇒
Promise
- .stop([protocolId]) ⇒
Promise
- .status([protocolId]) ⇒
Promise
- .start([protocolId]) ⇒
- .get() ⇒
Promise
- .delete(protocolId) ⇒
Promise
- .create(protocolId) ⇒
Promise
- .devices() ⇒
Promise
- .discovery :
- .deviceManager :
object
- .get([deviceId]) ⇒
Promise
- .delete(deviceId) ⇒
Promise
- .create(deviceOverview, type) ⇒
Promise
- .typeof(deviceOverview) ⇒
Promise
- .get([deviceId]) ⇒
- .device :
object
- .status(deviceId) ⇒
Promise
- .get(deviceId, [componentId]) ⇒
Promise
- .connect(deviceId) ⇒
Promise
- .disconnect(deviceId) ⇒
Promise
- .execute(deviceId, command) ⇒
Promise
- .lastUpdate(deviceId, [componentId]) ⇒
Promise
- .subscribe(deviceId, componentId) ⇒
Promise
- .unsubscribe(deviceId, componentId) ⇒
Promise
- .status(deviceId) ⇒
- .protocol :
object
- .disconnect(protocolId, deviceId) ⇒
Promise
- .connect(protocolId, deviceId) ⇒
Promise
- .read(protocolId, deviceId) ⇒
Promise
- .write(protocolId, deviceId, data) ⇒
Promise
- .disconnect(protocolId, deviceId) ⇒
- .idm :
object
- .group :
object
- .get([owner], [groupName]) ⇒
Promise
- .create(groupName) ⇒
Promise
- .delete(owner, groupName) ⇒
Promise
- .addEntity(containing) ⇒
Promise
- .removeEntity(containing) ⇒
Promise
- .get([owner], [groupName]) ⇒
- .user :
object
- .getCurrentUserInfo() ⇒
Promise
- .get(userName, authType) ⇒
Promise
- .create(including, authType, [options]) ⇒
Promise
- .delete(userName, authType) ⇒
Promise
- .resetPassword(userName, authType, newPassword) ⇒
Promise
- .updatePassword(oldPassword, newPassword) ⇒
Promise
- .getCurrentUserInfo() ⇒
- .entity :
object
- .getByType(entityType) ⇒
Promise
- .getByAttributeValue(constraints) ⇒
Promise
- .get(entityId, entityType) ⇒
Promise
- .create(entityId, entityType, entity) ⇒
Promise
- .delete(entityId, entityType) ⇒
Promise
- .setAttribute(with) ⇒
Promise
- .deleteAttribute(entityId, entityType, attributeName-) ⇒
Promise
- .getEntitiesSchema() ⇒
Promise
- .getByType(entityType) ⇒
- .authentication :
object
- .authenticateClient(client, secret) ⇒
Promise
- .authenticateClient(client, secret) ⇒
- .group :
- .data :
object
- .subscription :
object
- .create([subscription]) ⇒
Promise
- .delete([subscriptionID]) ⇒
Promise
- .update([subscriptionID], [subscription]) ⇒
Promise
- .get([query]) ⇒
Promise
- .create([subscription]) ⇒
- .record :
object
- .get([query]) ⇒
Promise
- .delete([query]) ⇒
Promise
- .get([query]) ⇒
- .settings :
object
- .get() ⇒
Promise
- .update(settings) ⇒
Promise
- .get() ⇒
- .subscription :
- .cloud :
object
- .getCloudsInfo() ⇒
Promise
- .getCloudInfo(cloudName) ⇒
Promise
- .exportDataToCloud(cloudName, dataQuery, customArgs) ⇒
Promise
- .getCloudsInfo() ⇒
- .policies :
object
- .pdp :
object
- .evaluate(PDP) ⇒
Promise
- .evaluate(PDP) ⇒
- .pap :
object
- .get(including) ⇒
Promise
- .set(including) ⇒
Promise
- .delete(including) ⇒
Promise
- .get(including) ⇒
- .pdp :
- .audit :
object
- .getUserActions() ⇒
Promise
- .getActionsOnUsersEntities() ⇒
Promise
- .cleanActionsOnUsersEntities() ⇒
Promise
- .getUserActions() ⇒
- .tokenSet(token) ⇒
String
- .tokenGet() ⇒
String
- .tokenDelete() ⇒
String
- .protocolManager :
Kind: static namespace of agile
- .protocolManager :
object
- .discovery :
object
- .start([protocolId]) ⇒
Promise
- .stop([protocolId]) ⇒
Promise
- .status([protocolId]) ⇒
Promise
- .start([protocolId]) ⇒
- .get() ⇒
Promise
- .delete(protocolId) ⇒
Promise
- .create(protocolId) ⇒
Promise
- .devices() ⇒
Promise
- .discovery :
Kind: static namespace of protocolManager
- .discovery :
object
- .start([protocolId]) ⇒
Promise
- .stop([protocolId]) ⇒
Promise
- .status([protocolId]) ⇒
Promise
- .start([protocolId]) ⇒
Kind: static method of discovery
Summary: Start device discovery on all or single protocol
Access: public
Fulfil: null
Param | Description |
---|---|
[protocolId] | Agile protocol Id |
Example
agile.protocolManager.discovery.start().then(function() {
console.log('All protocols discovery is on');
});
agile.protocolManager.discovery.start('Bluetooth LE').then(function() {
console.log('Bluetooth LE protocols discovery is on');
});
Kind: static method of discovery
Summary: Stop device discovery on all or single protocol
Access: public
Fulfil: null
Param | Description |
---|---|
[protocolId] | Agile protocol Id |
Example
agile.protocolManager.discovery.stop().then(function() {
console.log('All protocols discovery is off');
});
agile.protocolManager.discovery.stop('Bluetooth LE').then(function() {
console.log('Bluetooth LE discovery is off');
});
Kind: static method of discovery
Summary: Return the status object of discovery on the all or single protocol
Access: public
Fulfil: Array|Object
Param | Description |
---|---|
[protocolId] | Agile protocol Id |
Example
agile.protocolManager.discovery.status().then(function(protocols) {
console.log(protocols);
});
agile.protocolManager.discovery.status('Bluetooth LE').then(function(protocol) {
console.log(protocol.status);
});
Kind: static method of protocolManager
Summary: Get the list of registered protocols
Access: public
Fulfil: Array
- protocols
Example
agile.protocolManager.protocols.get().then(function(protocols) {
console.log(protocols);
});
Kind: static method of protocolManager
Summary: Unregister a Dbus Protocol object reference
Access: public
Fulfil: null
Param | Type | Description |
---|---|---|
protocolId | String |
Agile protocol Id |
Example
agile.protocolManager.protocols.delete(protocolId).then(function() {
console.log('protocol has been unregistered');
});
Kind: static method of protocolManager
Summary: Register a new Dbus object implementing the protocol API
Access: public
Fulfil: null
Param | Type | Description |
---|---|---|
protocolId | String |
Agile protocol Id |
Example
agile.protocolManager.protocols.create(protocolId).then(function() {
console.log('protocol has been registered');
});
Kind: static method of protocolManager
Summary: List all discovered devices on all available protocols
Access: public
Fulfil: Array
- devices
Example
agile.protocolManager.devices().then(function(devices) {
console.log(devices);
});
Kind: static namespace of agile
- .deviceManager :
object
- .get([deviceId]) ⇒
Promise
- .delete(deviceId) ⇒
Promise
- .create(deviceOverview, type) ⇒
Promise
- .typeof(deviceOverview) ⇒
Promise
- .get([deviceId]) ⇒
Kind: static method of deviceManager
Summary: Get all or single device definition
Access: public
Fulfil: Array
- devices
Param | Type | Description |
---|---|---|
[deviceId] | String |
Agile device Id |
Example
agile.deviceManager.get('bleB0B448BE5084').then(function(device) {
console.log(device);
});
Kind: static method of deviceManager
Summary: Delete a device definition and unregister it
Access: public
Fulfil: undefined
Param | Type | Description |
---|---|---|
deviceId | String |
Agile device Id |
Example
agile.deviceManager.delete('bleB0B448BE5084').then(function() {
console.log('Device bleB0B448BD1085 deleted');
});
Kind: static method of deviceManager
Summary: Register a new device based on information from ProtocolManager and device type
Access: public
Fulfil: Object
- device
Param | Type |
---|---|
deviceOverview | Object |
type | string |
Example
const deviceOverview = {
"name": "CC2650 SensorTag",
"protocol": "iot.agile.protocol.BLE",
"id": "B0:B4:48:BD:10:85",
"status": "CONNECTED"
};
const type = "TI SensorTag";
agile.deviceManager.create(deviceOverview, type).then(function(newDevice) {
console.log(newDevice);
});
Kind: static method of deviceManager
Summary: Get matching types for a device overview
Access: public
Fulfil: Array
- deviceTypes
Param | Type |
---|---|
deviceOverview | Object |
Example
const deviceOverview = {
"name": "CC2650 SensorTag",
"protocol": "iot.agile.protocol.BLE",
"id": "B0:B4:48:BD:10:85",
"status": "CONNECTED"
};
agile.deviceManager.typeof(deviceOverview).then(function(deviceTypes) {
console.log(deviceTypes);
});
Kind: static namespace of agile
- .device :
object
- .status(deviceId) ⇒
Promise
- .get(deviceId, [componentId]) ⇒
Promise
- .connect(deviceId) ⇒
Promise
- .disconnect(deviceId) ⇒
Promise
- .execute(deviceId, command) ⇒
Promise
- .lastUpdate(deviceId, [componentId]) ⇒
Promise
- .subscribe(deviceId, componentId) ⇒
Promise
- .unsubscribe(deviceId, componentId) ⇒
Promise
- .status(deviceId) ⇒
Kind: static method of device
Summary: Get the device status
Access: public
Fulfil: String
- status
Param | Type | Description |
---|---|---|
deviceId | String |
Agile device Id |
Example
agile.device.status('bleB0B448BE5084').then(function(status) {
console.log(status);
});
Kind: static method of device
Summary: Read values of all components from the device
Access: public
Fulfil: Object|Array
Single Component readings returned as object, Device readings returned as Array of Objects.
Param | Type | Description |
---|---|---|
deviceId | String |
Agile device Id |
[componentId] | String |
Agile component name, like a sensor |
Example
agile.device.get('bleB0B448BE5084').then(function(deviceComponents) {
console.log(deviceComponents);
});
Example
agile.device.get('bleB0B448BE5084', 'Temperature').then(function(deviceComponent) {
console.log(deviceComponent);
});
Kind: static method of device
Summary: Connect the device at protocol level
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
deviceId | String |
Agile device Id |
Example
agile.device.connect('bleB0B448BE5084').then(function() {
console.log('Connected!');
});
Kind: static method of device
Summary: Disconnect device at protocol level
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
deviceId | String |
Agile device Id |
Example
agile.device.disconnect('bleB0B448BE5084').then(function() {
console.log('Disconnected!');
});
Kind: static method of device
Summary: Perform an action on the device
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
deviceId | String |
Agile device Id |
command | String |
Operation name to be performed |
Example
agile.device.execute('bleB0B448BE5084', command).then(function() {
console.log(`executed ${command}!``);
});
Kind: static method of device
Summary: Get the last record fetched from the device or component
Access: public
Fulfil: Object|Array
Single Component readings returned as object, Device readings returned as Array of Objects.
Param | Type | Description |
---|---|---|
deviceId | String |
Agile device Id |
[componentId] | String |
Agile component name, like a sensor |
Example
agile.device.lastUpdate('bleB0B448BE5084', 'Temperature').then(function(temperatureReading) {
console.log(temperatureReading);
});
Example
agile.device.lastUpdate('bleB0B448BE5084').then(function(componentsReading) {
console.log(componentsReading);
});
Kind: static method of device
Summary: Enable a subscription to a data stream. Asynchronous data updates will be delivered via websocket.
Access: public
Fulfil: Object
- websocket instance - https://www.w3.org/TR/websockets/
Param | Type | Description |
---|---|---|
deviceId | String |
Agile device Id |
componentId | String |
Operation name to be performed |
Example
agile.device.subscribe('bleB0B448BE5084', 'Temperature').then(function(stream) {
stream.onerror = () => {
console.log('Connection Error');
};
stream.onopen = () => {
console.log('WebSocket Client Connected');
};
stream.onclose = () => {
console.log('echo-protocol Client Closed');
};
stream.onmessage = (e) => {
if (typeof e.data === 'string') {
console.log("Received: '" + e.data + "'");
}
};
});
Kind: static method of device
Summary: Unsubscribe from a data stream
Access: public
Fulfil: undefined
Param | Type | Description |
---|---|---|
deviceId | String |
Agile device Id |
componentId | String |
Agile component name, like a sensor |
Example
agile.device.unsubscribe('bleB0B448BE5084', 'Temperature').then(function() {
console.log('Unsubscribed!');
});
Kind: static namespace of agile
- .protocol :
object
- .disconnect(protocolId, deviceId) ⇒
Promise
- .connect(protocolId, deviceId) ⇒
Promise
- .read(protocolId, deviceId) ⇒
Promise
- .write(protocolId, deviceId, data) ⇒
Promise
- .disconnect(protocolId, deviceId) ⇒
Kind: static method of protocol
Summary: Disconnect from the device
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
protocolId | String |
Agile Id of the protocol |
deviceId | String |
Agile internal Id of the protocol |
Example
agile.protocol.disconnect('Bluetooth LE', 'bleB0B448BE5084').then(function() {
console.log('Disconnected!');
});
Kind: static method of protocol
Summary: Connect to the device
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
protocolId | String |
Agile Id of the protocol |
deviceId | String |
Agile internal Id of the protocol |
Example
agile.protocol.connect('Bluetooth LE', 'bleB0B448BE5084').then(function() {
console.log('Connected!');
});
Kind: static method of protocol
Summary: Call a read via protocol
Access: public
Fulfil: Object
Param | Type | Description |
---|---|---|
protocolId | String |
Agile Id of the protocol |
deviceId | String |
Agile internal Id of the protocol |
Example
agile.protocol.read('Bluetooth LE', 'bleB0B448BE5084').then(function(data) {
console.log(data);
});
Kind: static method of protocol
Summary: Call a write via protocol
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
protocolId | String |
Agile Id of the protocol |
deviceId | String |
Agile internal Id of the protocol |
data | object |
An object containing the content to write |
Example
agile.protocol.write('Bluetooth LE', 'bleB0B448BE5084', data).then(function() {
console.log('wrote data!');
});
Kind: static namespace of agile
- .idm :
object
- .group :
object
- .get([owner], [groupName]) ⇒
Promise
- .create(groupName) ⇒
Promise
- .delete(owner, groupName) ⇒
Promise
- .addEntity(containing) ⇒
Promise
- .removeEntity(containing) ⇒
Promise
- .get([owner], [groupName]) ⇒
- .user :
object
- .getCurrentUserInfo() ⇒
Promise
- .get(userName, authType) ⇒
Promise
- .create(including, authType, [options]) ⇒
Promise
- .delete(userName, authType) ⇒
Promise
- .resetPassword(userName, authType, newPassword) ⇒
Promise
- .updatePassword(oldPassword, newPassword) ⇒
Promise
- .getCurrentUserInfo() ⇒
- .entity :
object
- .getByType(entityType) ⇒
Promise
- .getByAttributeValue(constraints) ⇒
Promise
- .get(entityId, entityType) ⇒
Promise
- .create(entityId, entityType, entity) ⇒
Promise
- .delete(entityId, entityType) ⇒
Promise
- .setAttribute(with) ⇒
Promise
- .deleteAttribute(entityId, entityType, attributeName-) ⇒
Promise
- .getEntitiesSchema() ⇒
Promise
- .getByType(entityType) ⇒
- .authentication :
object
- .authenticateClient(client, secret) ⇒
Promise
- .authenticateClient(client, secret) ⇒
- .group :
Kind: static namespace of idm
- .group :
object
- .get([owner], [groupName]) ⇒
Promise
- .create(groupName) ⇒
Promise
- .delete(owner, groupName) ⇒
Promise
- .addEntity(containing) ⇒
Promise
- .removeEntity(containing) ⇒
Promise
- .get([owner], [groupName]) ⇒
Kind: static method of group
Summary: Get a particular group by name and owner
Access: public
Fulfil: Array
all groups if no arguments are provided, otherwise the group with given name and owner.
Param | Type | Description |
---|---|---|
[owner] | String |
Owner of the group |
[groupName] | String |
Name of the group |
Example
agile.idm.group.get('agile!@!agile-local','my-group').then(function(group) {
console.log('this is my group '+JSON.stringify(group));
});
agile.idm.group.get().then(function(groups) {
console.log('these are all groups '+JSON.stringify(groups));
});
Kind: static method of group
Summary: Create a group onwned by the authenticated user
Access: public
Fulfil: Object
group created
Param | Type | Description |
---|---|---|
groupName | String |
Name of the group |
Example
agile.idm.group.create('ble-devices').then(function(group) {
console.log('group created!'+group);
});
Kind: static method of group
Summary: Delete a group
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
owner | String |
Owner of the group |
groupName | String |
Name of the group |
Example
agile.idm.group.delete('agile!@!agile-local','my-group').then(function() {
console.log('group removed!');
});
Kind: static method of group
Summary: Add entity to a group
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
containing | Object |
the owner of the group, the name of the group, the id of the entity to be added to the group, and the Type of the entity |
Example
agile.idm.group.addEntity({
owner: 'agile!@!agile-local',
name: 'my-group',
entityId: '1',
entityType: 'device'
}).then(function(updated) {
console.log('entity updated !'+updated);
});
Kind: static method of group
Summary: Remove entity from a group
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
containing | Object |
the owner of the group, the name of the group, the id of the entity to be removed to the group, and the Type of the entity |
Example
agile.idm.group.removeEntity({
owner: 'agile!@!agile-local',
name: 'my-group',
entityId: '1',
entityType: 'device'
}).then(function(updated) {
console.log('entity updated !'+updated);
});
Kind: static namespace of idm
- .user :
object
- .getCurrentUserInfo() ⇒
Promise
- .get(userName, authType) ⇒
Promise
- .create(including, authType, [options]) ⇒
Promise
- .delete(userName, authType) ⇒
Promise
- .resetPassword(userName, authType, newPassword) ⇒
Promise
- .updatePassword(oldPassword, newPassword) ⇒
Promise
- .getCurrentUserInfo() ⇒
Kind: static method of user
Summary: Get the user information for the user currently logged in, i.e. token provided when agileSDK was created
Access: public
Fulfil: Object
userInfo - object with user information
Example
agile.idm.user.getCurrentUserInfo().then(function(info) {
console.log(info);
});
Kind: static method of user
Summary: Show information for a particular user by username and authentication type
Access: public
Fulfil: Object
user found
Param | Type | Description |
---|---|---|
userName | String |
user name |
authType | String |
authentication type |
Example
agile.idm.user.get('alice','agile-local').then(function(user) {
console.log(user);
});
Kind: static method of user
Summary: Create user
Access: public
Fulfil: Object
user created
Param | Type | Description |
---|---|---|
including | object |
userName user name |
authType | String |
authentication type |
[options] | Object |
continaing role of the user as 'role' and password as 'password' |
Example
agile.idm.user.create('bob','agile-local',{'role':'admin', 'password':'secret'}).then(function(user) {
console.log('user created!'+user);
});
Kind: static method of user
Summary: Delete a user
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
userName | String |
user name |
authType | String |
authentication type |
Example
agile.idm.user.delete('bob','agile-local').then(function() {
console.log('user removed!');
});
Kind: static method of user
Summary: Reset password for any user. The user executing this action needs to be allowed to do this, e.g. admin.
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
userName | String |
user name |
authType | String |
authentication type |
newPassword | String |
new password |
Example
agile.idm.user.resetPassword('bob','agile-local',"myNewPassword").then(function() {
console.log('password updated!');
});
Kind: static method of user
Summary: update password for himself
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
oldPassword | String |
old password |
newPassword | String |
new password |
Example
agile.idm.user.updatePassword("myOldPassword","myNewPassword").then(function() {
console.log('password updated!');
});
Kind: static namespace of idm
- .entity :
object
- .getByType(entityType) ⇒
Promise
- .getByAttributeValue(constraints) ⇒
Promise
- .get(entityId, entityType) ⇒
Promise
- .create(entityId, entityType, entity) ⇒
Promise
- .delete(entityId, entityType) ⇒
Promise
- .setAttribute(with) ⇒
Promise
- .deleteAttribute(entityId, entityType, attributeName-) ⇒
Promise
- .getEntitiesSchema() ⇒
Promise
- .getByType(entityType) ⇒
Kind: static method of entity
Summary: List all entities by type
Access: public
Fulfil: Array
all entities with a given type
Param | Type | Description |
---|---|---|
entityType | String |
type of entity |
Example
agile.idm.entity.getByType('device').then(function(entities) {
console.log(entities);
});
Kind: static method of entity
Summary: List all entities which have a particular attribute value
Access: public
Fulfil: Array
all entities with a given type
Param | Type | Description |
---|---|---|
constraints | Array |
contains objects containing objects with the property 'attributeType' to specify the attribute type and with the property 'attributeValue' to specify the expected attribute value |
Example
agile.idm.entity.getByAttributeValue([{attributeType:'credentials.dropbox','attributeValue':'expected attribute value for dropbox credentials'}]).then(function(entities) {
console.log(entities);
});
Kind: static method of entity
Summary: get Entity by entity id and type
Access: public
Fulfil: Object
entity entity
Param | Type | Description |
---|---|---|
entityId | String |
id of entity |
entityType | String |
type of entity |
Example
agile.idm.entity.get('1','device').then(function(result) {
console.log('entity created!'+result);
});
Kind: static method of entity
Summary: Create a group onwned by the authenticated user
Access: public
Fulfil: Object
entity created
Param | Type | Description |
---|---|---|
entityId | String |
id of entity |
entityType | String |
type of entity |
entity | object |
An object containing the entity |
Example
agile.idm.entity.create('1','device',{'name':'entity name'}).then(function(result) {
console.log('entity created!'+result);
});
Kind: static method of entity
Summary: Delete entity
Access: public
Fulfil: Undefined
Param | Type | Description |
---|---|---|
entityId | String |
id of entity |
entityType | String |
type of entity |
Example
agile.idm.entity.delete('1','device').then(function() {
console.log('group removed!');
});
Kind: static method of entity
Summary: Set Entity's attribute
Access: public
Fulfil: Object
entity updated
Param | Type | Description |
---|---|---|
with | Object |
entityId - id of entity, entityType - type of entity, attributeName- name of the attribute, attribute - An object or a String containing the entity's attribute value |
Example
agile.idm.entity.setAttribute({
entityId: '1',
entityType: 'device',
attributeType: 'credentials',
attributeValue: {'dropbox':'entity credentials for drop'}
}).then(function(result) {
console.log('entity created!'+result);
});
Kind: static method of entity
Summary: Delete Entity's attribute
Access: public
Fulfil: Object
entity updated entity
Param | Type | Description |
---|---|---|
entityId | String |
id of entity |
entityType | String |
type of entity |
attributeName- | String |
name of the attribute |
Example
agile.idm.entity.deleteAttribute('1','device','credentials').then(function(result) {
console.log('entity updated!'+result);
});
Kind: static method of entity
Summary: Get Entities schema
Access: public
Fulfil: Object
JSON Schema with the configuration for the entity format
Example
agile.idm.entity.getEntitiesSchema().then(function(jsonschema) {
console.log('schema for the entities'+jsonschema);
});
Kind: static namespace of idm
Kind: static method of authentication
Summary: Authenticate a client with client secret and client name.
Access: public
Fulfil: Object
Authentication information including token_type and access_token
Param | Type | Description |
---|---|---|
client | String |
client name. This is the client name provided to the create Entity when you register an Oauth2 client in AGILE-IDM. For more info: https://github.com/Agile-IoT/agile-idm-oauth2-client-example |
secret | String |
client secret. This is the client name provided to the create Entity when you register an Oauth2 client in AGILE-IDM. For more info: https://github.com/Agile-IoT/agile-idm-oauth2-client-example |
Example
agile.idm.authentication.authenticateClient('MyAgileClient2','WLnhhc3LnesbYj0GspNA13zgJEroN8V').then(function(result) {
console.log(credentials.access_token);
console.log(credentials.token_type);
});
Kind: static namespace of agile
- .data :
object
- .subscription :
object
- .create([subscription]) ⇒
Promise
- .delete([subscriptionID]) ⇒
Promise
- .update([subscriptionID], [subscription]) ⇒
Promise
- .get([query]) ⇒
Promise
- .create([subscription]) ⇒
- .record :
object
- .get([query]) ⇒
Promise
- .delete([query]) ⇒
Promise
- .get([query]) ⇒
- .settings :
object
- .get() ⇒
Promise
- .update(settings) ⇒
Promise
- .get() ⇒
- .subscription :
Kind: static namespace of data
- .subscription :
object
- .create([subscription]) ⇒
Promise
- .delete([subscriptionID]) ⇒
Promise
- .update([subscriptionID], [subscription]) ⇒
Promise
- .get([query]) ⇒
Promise
- .create([subscription]) ⇒
Kind: static method of subscription
Summary: Create subscription for device component
Access: public
Fulfil: Object
Param | Type | Description |
---|---|---|
[subscription] | Object |
New Subscription configuration |
Example
agile.data.subscription.create({
deviceID: 'myDevice',
componentID: 'temperature',
interval: 3000,
retention: '7d'
})
.then(function(subscription) {
console.log(subscription);
});
Kind: static method of subscription
Summary: Delete subscription for device component
Access: public
Fulfil: null
Param | Type | Description |
---|---|---|
[subscriptionID] | String |
Agile data subscriptionID |
Example
agile.data.subscription.delete('128484893938')
.then(function(subscription) {
console.log('Subscription deleted!');
});
Kind: static method of subscription
Summary: Update subscription
Access: public
Fulfil: Object
Param | Type | Description |
---|---|---|
[subscriptionID] | String |
Agile data subscriptionID |
[subscription] | Object |
Updated Subscription configuration |
Example
agile.data.subscription.update('5991b583553d6897bd14f87d', {
interval : 25000
})
.then(function(subscription) {
console.log(subscription);
});
Kind: static method of subscription
Summary: Get single or all subscriptions on gateway
Access: public
Fulfil: Object|Array
Param | Type | Description |
---|---|---|
[query] | String |
Basic query that is transformed to influx sql |
Example
agile.data.subscription.get('id=5991b583553d6897bd14f87d')
.then(function(subscription) {
console.log(subscription);
});
agile.data.subscription.get()
.then(function(subscriptions) {
console.log(subscriptions);
});
Kind: static namespace of data
- .record :
object
- .get([query]) ⇒
Promise
- .delete([query]) ⇒
Promise
- .get([query]) ⇒
Kind: static method of record
Summary: Get records from gateway
Access: public
Fulfil: Array
Param | Type | Description |
---|---|---|
[query] | String |
Basic query that is transformed to influx sql |
Example
agile.data.record.get()
.then(function(subscription) {
console.log(subscription);
});
// you can use any valid mongo-querystring
// https://www.npmjs.com/package/mongo-querystring
const query = 'deviceID=mySensor'
agile.data.record.get(query)
.then(function(records) {
console.log(records);
});
Kind: static method of record
Summary: Delete records from gateway
Access: public
Fulfil: null
Param | Type | Description |
---|---|---|
[query] | String |
Basic query that is transformed to influx sql |
Example
agile.data.record.delete('deviceID="myDevice&componentID="temperature""')
.then(function() {
console.log('Data deleted!');
});
Kind: static namespace of data
- .settings :
object
- .get() ⇒
Promise
- .update(settings) ⇒
Promise
- .get() ⇒
Kind: static method of settings
Summary: Get settings for agile data
Access: public
Fulfil: Array
Example
agile.data.settings.get()
.then(function(settings) {
console.log(settings);
});
Kind: static method of settings
Summary: Update settings for agile data
Access: public
Fulfil: Array
Param | Type | Description |
---|---|---|
settings | Object |
Updated settings values |
Example
agile.data.settings.update({
retention: '4d'
})
.then(function(newSettings) {
console.log(newSettings);
});
Kind: static namespace of agile
- .cloud :
object
- .getCloudsInfo() ⇒
Promise
- .getCloudInfo(cloudName) ⇒
Promise
- .exportDataToCloud(cloudName, dataQuery, customArgs) ⇒
Promise
- .getCloudsInfo() ⇒
Kind: static method of cloud
Summary: Get the list of cloud related data from Agile Data
Access: public
Fulfil: Object
- Description of supported cloud providers
Example
agile.cloud.getCloudsInfo().then(function(providers) {
console.log(providers.clouds);
});
Kind: static method of cloud
Summary: Get the description of a supported cloud provider
Access: public
Fulfil: Object
- Description of the cloud provider
Param | Type | Description |
---|---|---|
cloudName | String |
The name of the cloud provider |
Example
agile.cloud.getCloudInfo('owncloud').then(function(description) {
console.log(description.cloudName);
console.log(description.requiredFields);
});
Kind: static method of cloud
Summary: Export local data to a cloud
Access: public
Fulfil: null
Param | Type | Description |
---|---|---|
cloudName | String |
The name of the cloud provider |
dataQuery | Object |
An object encoding a sql query |
customArgs | Object |
Cloud provider specific custom arguments |
Example
const customArgs = {
username: 'x',
password: 'y',
owncloudServer: 'z'
}
const query = {
deviceID: 'dummy',
componentID: 'y',
between: '1523831000000 | 1523832000000'
}
agile.cloud.exportDataToCloud('owncloud', query, customArgs).then(function() {
console.log('Data uploaded')
});
Kind: static namespace of agile
- .policies :
object
- .pdp :
object
- .evaluate(PDP) ⇒
Promise
- .evaluate(PDP) ⇒
- .pap :
object
- .get(including) ⇒
Promise
- .set(including) ⇒
Promise
- .delete(including) ⇒
Promise
- .get(including) ⇒
- .pdp :
Kind: static namespace of policies
Kind: static method of pdp
Summary: Evaluate policies for a particular entity and action or attribute
Access: public
Fulfil: Array
boolean - each elemtn in the array is a boolean value mapeed one-to-one to the PDP requests objects. Each boolean shows whether the policy evaluated in the same potition of the array was allowed or not.
Param | Type | Description |
---|---|---|
PDP | Array |
request - each element in the array includes entityId, entityType, field indicating the attribute or action to be executed. Finally the method can be read or write depending on the action to be performed. For instance the example shows the evaluation of a policy showing whether the user logged in can read the attribute password for the user with id sam!@!agile-local |
Example
agile.policies.pdp.evaluate([{
entityId : 'sam!@!agile-local',
entityType: 'user',
field : 'password',
method : 'read'
}]).then(function(results) {
console.log(results);
});
Kind: static namespace of policies
- .pap :
object
- .get(including) ⇒
Promise
- .set(including) ⇒
Promise
- .delete(including) ⇒
Promise
- .get(including) ⇒
Kind: static method of pap
Summary: Get policies for a particular entity and action or attribute
Access: public
Fulfil: Object
Policy for the query, in case it is there
Param | Type | Description |
---|---|---|
including | Object |
entityType, entityId, and field optionally. If provided, field represents the attribute or action for which the policy is being queried. The example shows how to obtain the (read and write) policy for the user with id sam!@!agile-local. |
Example
agile.policies.pap.get({
entityId : 'sam!@!agile-local',
entityType: 'user',
field : 'password'
}).then(function(results) {
console.log(results);
});
Kind: static method of pap
Summary: Set policies for a particular entity and action or attribute
Access: public
Fulfil: Object
Policy for the entity resulting after the update
Param | Type | Description |
---|---|---|
including | Object |
entityType, entityId, policy, and field optionally. If provided, field represents the attribute or action for which the policy is being queried. The example shows how to make the password of sam!@!agile-local readable and writable to anyone (do not do this in production!). |
Example
agile.policies.pap.set({
entityId : 'sam!@!agile-local',
entityType: 'user',
field : 'password',
policy : [
{
op: "write"
},
{
op: "read"
}
]
}).then(function(results) {
console.log(results);
});
Kind: static method of pap
Summary: Delete policies for a particular entity and action or attribute
Access: public
Fulfil: Object
Policy for the entity resulting after the update
Param | Type | Description |
---|---|---|
including | Object |
entityType, entityId, and field optionally. If provided, field represents the attribute or action for which the policy is to be deleted. The example shows how to delete the (read and write) policy for the user with id sam!@!agile-local. |
Example
agile.policies.pap.delete({
entityId : 'sam!@!agile-local',
entityType: 'user',
field : 'password'
}).then(function(results) {
console.log(results);
});
Kind: static namespace of agile
- .audit :
object
- .getUserActions() ⇒
Promise
- .getActionsOnUsersEntities() ⇒
Promise
- .cleanActionsOnUsersEntities() ⇒
Promise
- .getUserActions() ⇒
Kind: static method of audit
Summary: Get actions performed by currently logged in user
Access: public
Fulfil: Array
Actions actions performed by the user authenticated with the token used by the SDK. Each action has a user, entity and time field to show who executed where action when on which entity.
Example
agile.policies.audit.getUserActions( ).then(function(results) {
console.log(results);
});
Kind: static method of audit
Summary: Get actions performed on entities owned by the user currently logged in
Access: public
Fulfil: Array
Actions actions performed by the user authenticated with the token used by the SDK. Each action has a user, entity and time field to show who executed where action when on which entity.
Example
agile.policies.audit.getActionsOnUsersEntities( ).then(function(results) {
console.log(results);
});
Kind: static method of audit
Summary: Removes actions performed on entities owned by the user currently logged in
Access: public
Example
agile.policies.audit.cleanActionsOnUsersEntities( ).then(function(results) {
console.log(results);
});
Kind: static method of agile
Summary: Set/Update Idm Authentication token
Returns: String
- token - Newly set Idm Authentication token
Access: public
Param | Type | Description |
---|---|---|
token | String |
Idm Authentication token |
Example
agile.tokenSet('1234');
Kind: static method of agile
Summary: Get Idm Authentication token
Access: public
Example
agile.tokenGet();
Kind: static method of agile
Summary: Unset/delete Idm Authentication token
Access: public
Example
agile.tokenDelete();