Skip to content
No description, website, or topics provided.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
tests
.gitignore
LICENSE
README.md
index.js
jest.config.js
package.json

README.md

netFIELD-node-SDK

license

netFIELD Node SDK (node.js version >=0.6.x) and Node samples for REST API.

Installation

Install sdk trough 'npm' or download folder in your project

npm install edgePortal-rest-sdk --save

Require 'edgeportal-rest-sdk' in your file

var edgePortal = require('edgePortal-rest-sdk');

Configuration

Basic configuration options

edgePortal.setConfiguration({
    clientId: 'your-client-id',
    clientPassword: 'your-client-password'
});

Advanced configuration options.

edgePortal.setConfiguration({
   version: '1.0.0',
   schema: 'https', // http or https
   host: 'api.netfield.io',
   post: 443,
   headers: {
       'Content-type': 'application/json',
       'Accept': 'application/json',
       'Authorization': 'your-token'
   }
});

Token configuration.

edgePortal.setToken('your-token'); //Done authomaticly by auth
edgePortal.removeToken('your-token'); //Done authomaticly by revoke

Helper functions.

const token = edgePortal.getToken();
const options = edgePortal.getConfiguration();

Method Usage

Callbacks (old way)

const params = { email: 'my@email.de', password: 'my-password' };

edgePortal.auth.auth(params, function (error, data) {
    if(error){
        throw new Error(error.message);
    }

    edgePortal.setToken(data.token);
});

Promices (new way)

const params = { email: 'my@email.de', password: 'my-password' };

edgePortal.auth.auth(params)
    .then(data => {
        edgePortal.setToken(data.token);
    })
    .catch(error => {
        throw new Error(error.message);
    });

Methods

  1. edgePortal.auth.resetPassword(email, [callback])

  2. edgePortal.auth.setPassword(params, [callback])

  3. edgePortal.users.create(params, [callback])

  4. edgePortal.users.createselfuser(params, [callback])

  5. edgePortal.users.getAll(organisationId, page, [callback])

  6. edgePortal.users.get(userId, [callback])

  7. edgePortal.users.getverifyuser(email, [callback])

  8. edgePortal.users.suggest(params, [callback])

  9. edgePortal.users.update(userId, params, [callback])

  10. edgePortal.users.verifyuser(params, [callback])

  11. edgePortal.users.delete(userId, [callback])

  12. edgePortal.users.profile.get([callback])

  13. edgePortal.users.profile.update(params, [callback])

  14. edgePortal.organisation.get(organisationId, depth, [callback])

  15. edgePortal.organisation.update(organisationId, params, [callback])

  16. edgePortal.organisation.create(organisationId, params, [callback])

  17. edgePortal.organisation.delete(organisationId, [callback])

  18. edgePortal.devices.create(params, [callback])

  19. edgePortal.devices.get(deviceId, [callback])

  20. edgePortal.devices.getAll(organisationId, page, deviceId, [callback])

  21. edgePortal.devices.update(deviceId, params, [callback])

  22. edgePortal.devices.delete(deviceId, [callback])

  23. edgePortal.devices.onBoard(deviceId, [callback])

  24. edgePortal.devices.offBoard(deviceId, [callback])

  25. edgePortal.devices.customFields.create(deviceId, params, [callback])

  26. edgePortal.devices.customFields.getAll(deviceId, [callback])

  27. edgePortal.devices.customFields.get(deviceId, fieldId, [callback])

  28. edgePortal.devices.customFields.update(deviceId, fieldId, params, [callback])

  29. edgePortal.devices.customFields.delete(deviceId, fieldId, [callback])

  30. edgePortal.devices.snapshots.get(deviceId, snapshotId, [callback])

  31. edgePortal.device.snapshots.getAll(deviceId, page, [callback])

  32. edgePortal.device.snapshots.delete(deviceId, page, [callback])

  33. edgePortal.device.snapshots.upload(deviceId, page, [callback])

  34. edgePortal.device.telemetry.get(deviceId, limit, [callback])

  35. edgePortal.device.createDeviceNotification(deviceId, params, [callback])

  36. edgePortal.device.deleteNotification(deviceId, notificationid, [callback])

  37. edgePortal.device.deleteAllNotifications(deviceId, [callback])

  38. edgePortal.device.getTopology(deviceId, [callback])

  39. edgePortal.device.getTopologyLayout(deviceId, layoutId [callback])

  40. edgePortal.device.getTopologyLayouts(deviceId, page, limit, sortBy, sortOrder [callback])

  41. edgePortal.device.createTopologyLayout(deviceId, params [callback])

  42. edgePortal.device.deleteTopologyLayout(deviceId, layoutId [callback])

  43. edgePortal.device.updateTopologyLayout(deviceId, layoutId, params [callback])

  44. edgePortal.roles.create(organisationId, params, [callback])

  45. edgePortal.roles.get(organisationId, roleName, [callback])

  46. edgePortal.roles.update(organisationId, params, [callback])

  47. edgePortal.roles.getAll(organisationId, page, [callback])

  48. edgePortal.roles.delete(organisationId, roleName, [callback])

  49. edgePortal.modules.get(moduleId, [callback])

  50. edgePortal.modules.getAllModules([callback])

  51. edgePortal.modules.create(params, [callback])

  52. edgePortal.modules.delete(moduleId, [callback])

  53. edgePortal.modules.deviceModules(deviceId, [callback])

  54. edgePortal.modules.createDeviceModules(moduleId, deviceId, params [callback])

  55. edgePortal.modules.deleteDeviceModules(moduleId, deviceId, [callback])

  56. edgePortal.modules.update(moduleId, deviceId, params [callback])

  57. edgePortal.modules.routes.get(deviceId, [callback])

  58. edgePortal.modules.routes.create(deviceId, params [callback])

  59. edgePortal.modules.routes.update(routeId, deviceId, params [callback])

  60. edgePortal.modules.routes.delete(routeId, deviceId, [callback])

  61. edgePortal.modules.getModuleProperties(deviceId, moduleId, [callback])

  62. edgePortal.permissions.devices(deviceIds, [callback])

  63. edgePortal.permissions.modules(moduleIds, [callback])

  64. edgePortal.permissions.organisations(organisationIds, [callback])

  65. edgePortal.permissions.users(userIds, [callback])

  66. edgePortal.permissions.roles(roles, [callback])

  67. edgePortal.permissions.tenants(tenantIds, [callback])

  68. edgePortal.permissions.edgeos(edgeosIds, [callback])

  69. edgePortal.keys.create([callback])

  70. edgePortal.keys.delete(organisationId, [callback])

  71. edgePortal.keys.getkey(organisationId, [callback])

  72. edgePortal.keys.getkeys(keyId, [callback])

  73. edgePortal.edgeos.getEdgeos(page, limit, sortBy, sortOrder, [callback])

  74. edgePortal.edgeos.get(edgeosId, [callback])

  75. edgePortal.edgeos.deletegetEdgeos(edgeosId, [callback])

  76. edgePortal.edgeos.creategetEdgeos(formData, [callback])

  77. edgePortal.edgeos.updategetEdgeos(edgeosId, formData, [callback])

  78. edgePortal.tenants.create(params, [callback])

  79. edgePortal.tenants.update(tenantId, params, [callback])

  80. edgePortal.tenants.get(tenantId, [callback])

  81. edgePortal.tenants.getAll(page, limit, sortBy, sortOrder, [callback])

  82. edgePortal.tenants.delete(organisationId, [callback])

auth

Gets user authentication token.

* @param {object} params
* @param {function} callback optional
const params = {
    grantType: "password",
    email: 'my@email.de',
    password: 'my-password'
};

edgePortal.auth.auth(params, [callback]);

//Or refresh token

const params = {
    grantType: "refreshToken",
    refreshToken: '{my-refresh-token}'
};

edgePortal.auth.auth(params, [callback]);

verify

Verify token if it's valid

* @param {function} callback optional
edgePortal.auth.verify([callback])

revoke

Revoke token (logout)

* @param {function} callback optional
edgePortal.auth.revoke([callback])

resetPassword

Send email with password reset token.

* @param {string} email
* @param {function} callback optional
const email = 'my@email.de';
edgePortal.auth.resetPassword(email, [callback])

reset

Set new user password.

* @param {object} params
* @param {function} callback optional
const params = {
    "email": "my@email.de",
    "password": "new-password",
    "code": "reset-token"
};

edgePortal.auth.setPassword(params, [callback])

createuser

Create new user.

* @param {object} params
* @param {function} callback optional
const params = {
    "organisationId": 1,
    "password": "secret",
    "locked": true,
    "firstName": "Alen",
    "lastName": "Turing",
    "email": "alen@mail.uk",
    "jobTitle": "PC God",
    "department": "M6",
    "mobilePhone": "0879654321",
    "telephone": "655113",
    "street": "unknown",
    "houseNumber": "13",
    "addressSuplement": "Bletchley Park",
    "zipCode": "6598",
    "city": "London",
    "country": "Great Britan"
}
edgePortal.users.create(params, [callback])

createselfuser

Self registration for user (uses public token).

* @param {object} params
* @param {function} callback optional
const params = {
    "organisationId": 1,
    "password": "secret",
    "locked": true,
    "firstName": "Alen",
    "lastName": "Turing",
    "email": "alen@mail.uk",
    "jobTitle": "PC God",
    "department": "M6",
    "mobilePhone": "0879654321",
    "telephone": "655113",
    "street": "unknown",
    "houseNumber": "13",
    "addressSuplement": "Bletchley Park",
    "zipCode": "6598",
    "city": "London",
    "country": "Great Britan"
}
edgePortal.users.createselfusers(params, [callback])

getusers

Get users by organisationId.

* @param {number} organisationId
* @param {number} page (optional)
* @param {number} limit (optional)
* @param {string} sortBy (optional)
* @param {string} sortOrder (optional)
* @param {function} callback (optional)
const organisationId = 1;
const page = 1;
edgePortal.users.getAll(organisationId, page?, limit?, sortBy?, sortOrder?, [callback])

getuser

Get user by userId.

* @param {number} userId
* @param {function} callback optional
const userId = 1;
edgePortal.users.get(userId, [callback])

suggestuser

Suggest user.

* @param {object} params 
* @param {function} callback optional
const params = {
    organisationId: 1, // OPTIONAL (gets user's organisation by default)
    search: "test"
}
        
edgeSDK.users.suggest( params, [callback] );

getverifyuser

Resend user verification code to email

* @param {string} email
* @param {function} callback optional
const email = 'yolo@mail.de';
edgePortal.users.getverifyuser(email, [callback])

updateuser

Update user.

* @param {number} userId
* @param {object} params
* @param {function} callback optional
const userId = 1;
const params = {
    jobTitle: "Admin",
}
edgePortal.users.update(userId, params, [callback])

verifyuser

Verify user by code send trough email.

* @param {object} params
* @param {function} callback optional
const params = {
  "email": "test@mail.de",
  "code": 642157
}
edgePortal.users.verifyuser(params, [callback])

deleteuser

Delete user by userId.

* @param {number} userId
* @param {function} callback optional
const userId = 1;

edgePortal.users.delete(userId, [callback])

getprofile

Get user profile.

* @param {function} callback optional
edgePortal.users.profile.get([callback])

updateprofile

Update user profile

* @param {object} params
* @param {function} callback optional
const params = {
    "mobilePhone": "0895661233",
}
edgePortal.users.profile.update(params, [callback])

getorganisation

Get organisation by organisationId.

* @param {number} organisationId
* @param {number} depth
* @param {function} callback optional
const organisationId = 1;
const depth = 1;
edgePortal.organisation.get(organisationId, depth, [callback])

updateogranization

Update organisation by organisationId.

* @param {number} organisationId
* @param {object} params
* @param {function} callback optional
const organisationId = 1;
const params = {
    phoneNumber: '098563256'
};
edgePortal.organisation.update(organisationId, params, [callback])

createorganisation

Create Organisation.

* @param {number} parentOrganisationId
* @param {object} params
* @param {function} callback optional
const parentOrganisationId = 1;
const params = {
    "name": "Test organisation",
    "phoneNumber": "0879654321",
    "street": "Test str.",
    "houseNumber": "2569863",
    "addressSupplement": "Test str.",
    "zipCode": "9000",
    "city": "Varna",
    "country": "Bulgaria",
    "notes": "This is organisation for test"
}
edgePortal.organisation.create(parentOrganisationId, params, [callback])

deleteorganisation

Delete organisation by organisationId.

* @param {number} organisationId
* @param {function} callback optional
const organisationId = 1;
edgePortal.organisation.delete(organisationId, [callback])

getorganisationdevices

Get devices per organisationId and child organisations.

* @param {number} organisationId
* @param {number} page
* @param {string} attribute
* @param {string} sort
* @param {string} depth
* @param {function} callback optional
const organisationId = 1;
const page = 1;
const attribute = 'name, organisationId';
const sort = 'asc';
const depth = 'one';
edgePortal.organisation.devices.get(organisationId, page, attribute, sort, depth, [callback])

createdevice

Create Device.

* @param {object} params
* @param {function} callback optional
const params = {
    organisationId: 1,
    serialNumber: "195365884"
};
edgePortal.devices.create(params, [callback])

getdevice

Get device by deviceId.

* @param {string} deviceId
* @param {function} callback optional
const deviceId = '5b332f43f9373638f8e46c4f';
edgePortal.devices.get(deviceId, [callback])

getdevices

Get devices by organisationId

* @param {number} organisationId
* @param {number} page
* @param {number} limit
* @param {string} sortBy
* @param {string} sortOrder
* @param {function} callback
const deviceId = '5b332f43f9373638f8e46c4f';
edgePortal.devices.getAll(organisationId, page, limit, sortBy, sortOrder, [callback])

updatedevice

Update device by deviceId.

* @param {string} deviceId
* @param {object} params
* @param {function} callback optional
const deviceId = '5b332f43f9373638f8e46c4f';
const params = {
    name: 'Test Device Name',
};
edgePortal.devices.update(deviceId, params, [callback])

deletedevice

Delete device by deviceId.

* @param {string} deviceId
* @param {function} callback optional
const deviceId = '5b332f43f9373638f8e46c4f';
edgePortal.devices.delete(deviceId, [callback])

onBoard

Onboard a device.

* @param {object}
const params = {
  "activationCode": "string",
  "serialNumber": "string"
}
edgePortal.device.onBoard(params, [callback])

offBoard

Offboard a device.

* @param {object}
const params = {
  "serialNumber": "string"
}
edgePortal.device.offBoard(params, [callback])

createdevicecustomfields

Create device custom fields.

* @param {string} deviceId
* @param {object} params
* @param {function} callback optional
const deviceId = '5b332f43f9373638f8e46c4f';
const params = {
    fieldId: 'vieldValue'
}
edgePortal.devices.customFields.create(deviceId, params, [callback])

getdevicecustomfields

Get device custom fields.

* @param {string} deviceId
* @param {function} callback optional
const deviceId = '5b332f43f9373638f8e46c4f';
edgePortal.devices.customFields.getAll(deviceId, [callback])

getdevicecustomfield

Get device custom field.

* @param {string} deviceId
* @param {string} fieldId
* @param {function} callback optional
const deviceId = '5b332f43f9373638f8e46c4f';
const fieldId = 'fieldId';
edgePortal.devices.customFields.get(deviceId, fieldId, [callback])

updatedevicesutomfield

Update device custom field.

* @param {string} deviceId
* @param {string} fieldId
* @param {object} params
* @param {function} callback optional
const deviceId = '5b332f43f9373638f8e46c4f';
const fieldId = 'fieldId';
const params = {
    fieldValue: 'newFieldValue'
}
edgePortal.devices.customFields.update(deviceId, fieldId, params, [callback])

deletedevicecustomfields

Delete device custom field.

* @param {string} deviceId
* @param {string} fieldId
* @param {function} callback optional
const deviceId = '5b332f43f9373638f8e46c4f';
const fieldId = 'fieldId';
edgePortal.devices.customFields.delete(deviceId, fieldId, [callback])

getsnapshot

Get snapshot.

* @param {string} deviceId
* @param {string} snapshotId
const deviceId = '5b332f43f9373638f8e46c4f';
const snapshotId = 'string';
edgePortal.devices.snapshots.get(deviceId, snapshotId, [callback])

getsnapshots

Get snapshots.

* @param {string} deviceId
* @param {number} page
* @param {number} limit
* @param {string} sortBy
* @param {string} sortOrder
const deviceId = '5b332f43f9373638f8e46c4f';
const snapshotId = 'string';
edgePortal.devices.snapshots.getAll(deviceId, page, limit, sortBy, sortOder [callback])

deletesnapshots

Delete snapshots.

* @param {string} deviceId
* @param {string} snapshotId
const deviceId = '5b332f43f9373638f8e46c4f';
const snapshotId = 'string';
edgePortal.devices.snapshots.delete(deviceId, snapshotId [callback])

uploadsnapshots

Upload snapshots.

* @param {string} deviceId
* @param {any} formData
const deviceId = '5b332f43f9373638f8e46c4f';
const formData = { data: 'anyData' };
edgePortal.devices.snapshots.upload(deviceId, formData [callback])

gettelemetry

Get device telemetry.

* @param {string} deviceId
* @param {number} limit
const deviceId = '5b332f43f9373638f8e46c4f';
const limit = 1;
edgePortal.devices.telemetry.get(deviceId, limit [callback])

createNotification

Create device notification.

* @param {string} deviceId
* @param {object} params
const deviceId = '5b332f43f9373638f8e46c4f';
const params = {
    "serialNumber": "123456789",
    "level": "Information",
    "message": "Test Notification"
 }
edgePortal.devices.createNotification(deviceId, params [callback])

deletenotification

Delete only one device notification.

* @param {string} deviceId
* @param {string} notificationId
const deviceId = '5b332f43f9373638f8e46c4f';
const notificationId = '4a222f43f1354638f8e46b5d';
edgePortal.devices.deleteNotification(deviceId, notificationId, [callback])

deleteallnotification

Delete all device notification by device id.

* @param {string} deviceId
const deviceId = '5b332f43f9373638f8e46c4f';
edgePortal.devices.deleteAllNotifications(deviceId, [callback])

gettopology

Get the network topology of a specific device.

* @param {string} deviceId
const deviceId = '5b332f43f9373638f8e46c4f';
edgePortal.devices.getTopology(deviceId, [callback])

gettopologylayout

Get a specific topology layout of a desired device

* @param {string} deviceId
* @param {string} layoutId
const deviceId = '5b332f43f9373638f8e46c4f';
const layoutId = '5b111f43f5465438f7a46c2c';
edgePortal.devices.getTopologyLayout(deviceId, layoutId, [callback])

gettopologylayouts

Get a list of all topology layouts for this device

* @param {string} deviceId
* @param {number} page 
* @param {number} limit 
* @param {string} sortBy 
* @param {string} sortOrder 
* @param {function} callback 
const deviceId = '5b332f43f9373638f8e46c4f';
const layoutId = '5b111f43f5465438f7a46c2c';
edgePortal.devices.getTopologyLayouts(deviceId, page, limit, sortBy, sortOrder, [callback])

createtopology

Create a new layout definition for displaying topologies

* @param {string} deviceId
* @param {object} params
const deviceId = '5b332f43f9373638f8e46c4f';
const params = {
  "schemaVersion": 1,
  "name": "string",
  "location": {
    "nodes": [
      {
        "key": "string",
        "loc": "string"
      }
    ]
  }
};
edgePortal.devices.createTopologyLayout(deviceId, params, [callback])

deletetopology

Delete topology layout

* @param {string} deviceId
* @param {string} layoutId
const deviceId = '5b332f43f9373638f8e46c4f';
const layoutId = '5b111f43f5465438f7a46c2c';
edgePortal.devices.deleteTopologyLayout(deviceId, layoutId, [callback])

updatelayout

Update a topology layout

* @param {string} deviceId
* @param {string} layoutId
* @param {number} page 
* @param {number} limit 
* @param {string} sortBy 
* @param {string} sortOrder 
* @param {function} callback 
const deviceId = '5b332f43f9373638f8e46c4f';
const layoutId = '5b111f43f5465438f7a46c2c';
const params = {
  "schemaVersion": 1,
  "name": "string",
  "location": {
    "nodes": [
      {
        "key": "string",
        "loc": "string"
      }
    ]
  }
};
edgePortal.devices.updateTopologyLayout(deviceId, layoutId, params, [callback])

createrole

Create role.

* @param {number} organisationId
* @param {object} params
* @param {function} callback optional
const organisationId = 1;
const params = {
    "role": "Jedi-Master",
    "resources": [
        {
            "resource": "users",
            "permissions": [
                "create"
            ]
        }
    ]
}
edgePortal.roles.create(organisationId, params, [callback])

getrole

Get role by organisationId and rolename.

* @param {number} organisationId
* @param {string} rolename
* @param {function} callback optional
const organisationId = 1;
const roleName = 'Jedi-Master';
edgePortal.roles.get(organisationId, roleName, [callback])

updaterole

Update role.

* @param {number} organisationId
* @param {object} params
* @param {function} callback optional
const organisationId = 1;
const params = {
    "role": "Jedi-Master",
    "resources": [
        {
            "resource": "users",
            "permissions": [
                "create"
            ]
        }
    ]
}
edgePortal.roles.update(organisationId, params, [callback])

getroles

Get roles by organisationId.

* @param {number} organisationId
* @param {number} page
* @param {function} callback optional
const organisationId = 1;
const page = 1;
edgePortal.roles.getAll(organisationId, page, [callback])

deleterole

Delete role.

* @param {number} organisationId
* @param {string} roleName
* @param {function} callback optional
const organisationId = 1;
const roleName = "Jedi-Master";
edgePortal.roles.delete(organisationId, roleName, [callback])

getmodule

Get module.

* @param {string} moduleId
* @param {function} callback optional
const moduleId = "d8223c46-e779-4eec-aaed-2722976dd0ae";
edgePortal.modules.get(moduleId, [callback])

getmodules

Get all modules.

* @callback {function}
edgePortal.modules.get([callback])

createmodules

Create modules.

* @params {any} params
const params = {
  "displayName": "string",
  "moduleName": "string",
  "type": "string",
  "version": "string",
  "restartPolicy": "string",
  "desiredStatus": "string",
  "imageUri": "string",
  "moduleTwinDesiredOptions": {},
  "environmentVariables": [
    {
      "key": "string",
      "value": "string"
    }
  ],
  "registryType": "string"
}
edgePortal.modules.create(params, [callback])

deletemodules

Delete modules.

* @moduleId {string} moduleId
const moduleId = "d8223c46-e779-4eec-aaed-2722976dd0ae"
edgePortal.modules.delete(moduleId, [callback])

devicemodules

Get device modules.

* @moduleId {string} moduleId
const deviceId = "5bbded649671f321dc944f5b"
edgePortal.modules.deviceModules(deviceId, [callback])

createdevicemodules

Create device for a given module.

* @moduleId {string} moduleId
* @deviceId {string} deviceId
* @params {any} params
const moduleId = "d8223c46-e779-4eec-aaed-2722976dd0ae"
const deviceId = "5bbded649671f321dc944f5b"
const params = {
  "displayName": "string",
  "moduleName": "string",
  "type": "string",
  "version": "string",
  "restartPolicy": "string",
  "desiredStatus": "string",
  "imageUri": "string",
  "moduleTwinDesiredOptions": {},
  "environmentVariables": [
    {
      "key": "string",
      "value": "string"
    }
  ],
  "registryType": "string"
}
edgePortal.modules.createDeviceModule(moduleId, deviceId, params, [callback])

deletedevicemodule

Delete device from modules. * @moduleId {string} moduleId * @deviceId {string} deviceId

const moduleId = "d8223c46-e779-4eec-aaed-2722976dd0ae";
const deviceId = "5bbded649671f321dc944f5b";
edgePortal.modules.deleteDeviceModule(moduleId ,deviceId, [callback])

updatemodule

Update module.

* @moduleId {string} moduleId
* @deviceId {string} deviceId
* @params {any} params
const moduleId = "d8223c46-e779-4eec-aaed-2722976dd0ae";
const deviceId = "5bbded649671f321dc944f5b";
const params = {
  "displayName": "string",
  "moduleName": "string",
  "type": "string",
  "version": "string",
  "restartPolicy": "string",
  "desiredStatus": "string",
  "imageUri": "string",
  "moduleTwinDesiredOptions": {},
  "environmentVariables": [
    {
      "key": "string",
      "value": "string"
    }
  ],
  "registryType": "string"
}
edgePortal.modules.update(moduleId ,deviceId, params, [callback])

getmoduleroutes

Get module routes.

* @deviceId {string} deviceId
const deviceId = "5bbded649671f321dc944f5b";
edgePortal.modules.routes.get(deviceId, [callback])

createmoduleroutes

Create module routes.

* @deviceId {string} deviceId
* @params {any} params
const deviceId = "5bbded649671f321dc944f5b";
const params = {
  "name": "string",
  "source": "string",
  "condition": "string",
  "target": "string"
}
edgePortal.modules.routes.create(deviceId, params [callback])

updatemoduleroutes

Update module routes.

* @routeId {string} routeId
* @deviceId {string} deviceId
* @params {any} params
const routeId = "5bbc99d0cd9e1d35180338b4";
const deviceId = "5bbded649671f321dc944f5b";
const params = {
  "name": "string",
  "source": "string",
  "condition": "string",
  "target": "string"
}
edgePortal.modules.routes.update(routeId, deviceId, params [callback])

deletemoduleroutes

Delete module routes.

* @routeId {string} routeId
* @deviceId {string} deviceId
const routeId = "5bbc99d0cd9e1d35180338b4";
const deviceId = "5bbded649671f321dc944f5b";

edgePortal.modules.routes.delete(routeId, deviceId, [callback])

getmoduleproperties

Get module properties.

* @deviceId {string} deviceId
* @moduleId {string} moduleId
const deviceId = "5bbded649671f321dc944f5b";
const moduleId = "d8223c46-e779-4eec-aaed-2722976dd0ae";

edgePortal.modules.getmoduleproperties(deviceId, moduleId, [callback])

devicepermissions

Check device permissions.

* @deviceId {string[]} deviceId
const deviceIds = ["5bbded649671f321dc944f5b"];

edgePortal.permissions.device(deviceIds, [callback])

modulepermissions

Check device permissions.

* @moduleIds {string[]} moduleIds
const moduleIds = ["d8223c46-e779-4eec-aaed-2722976dd0ae"];

edgePortal.permissions.module(moduleIds, [callback])

organisationpermissions

Check organisations permissions.

* @organisationId {number[]} organisationId
const organisationId = ["d8223c46-e779-4eec-aaed-2722976dd0ae"];

edgePortal.permissions.organisations(organisationId, [callback])

userpermissions

Check users permissions.

* @userIds {number[]} userIds
const userIds = [1];

edgePortal.permissions.users(userIds, [callback])

rolepermissions

Check roles permissions.

* @roles {any} roles
const roles = {
  "roles": {
    "1": [
      "admin"
    ]
  }
};

edgePortal.permissions.roles(roles, [callback])

tenantspermissions

Check tenants permissions.

* @tenantIds {number[]} tenantIds
const tenantIds = [1];


edgePortal.permissions.tenants(tenantIds, [callback])

edgeospermissions

Check EdgeOS permissions.

* @edgeosIds {string[]} edgeosId
const edgeosIds = ["5bbded649671f321dc944f5b"];

edgePortal.permissions.edgeos(edgeosIds, [callback])

createkey

Create key.

* @param {function} optional
edgePortal.keys.create([callback])

deletekey

Delete key by organisationId.

 * @param {organisationId} number
 * @param {function} callback optional
const organisationId = 1;

edgePortal.keys.delete(organisationId, [callback])

getkey

Get key by organisationId.

 * @param {organisationId} number
 * @param {function} callback optional
const organisationId = 1;

edgePortal.keys.getkey(organisationId, [callback])

getkeys

Get key by keyId.

 * @param {keyId} string
 * @param {function} callback optional
const keyId = "5bd17d7442dffe35c8e5915a";

edgePortal.keys.getkey(keyId, [callback])

getEdgeos

Get all EdgeOS.

 * @param {number} page
 * @param {string} attribute name, organisationId, id
 * @param {string} sort asc, desc
 * @param {string} depth one, all
 * @param {function} callback optional
edgePortal.edgeos.getAll([callback])

getSingleEdgeos

Get single EdgeOS.

 * @param {string} edgeosId
 * @param {function} callback optional
edgePortal.edgeos.get(edgeosId, [callback])

deleteEdgeos

Delete a EdgeOS by Id

 * @param {string} edgeosId
 * @param {function} callback optional
const edgeosId = "5c62d4be51d00e1e58ad1aff";

edgePortal.edgeos.delete(edgeosId, [callback])

createEdgeos

Create a EdgeOS.

 * @param {object} formData
 * @param {function} callback optional
const formData = new FormData();
formData.append("version", '0.0.1');
formData.append("name", 'Test-EdgeOS');
formData.append("platform", 'NETFIELD');
formData.append("type", 'update');
formData.append('file', fs.createReadStream('test.json'));

edgePortal.edgeos.create(formData, [callback])

updateEdgeos

Update a EdgeOS

 * @param {keyId} string
 * @param {function} callback optional
const edgeosId = "5c62d4be51d00e1e58ad1aff";

const newFormData = new FormData();
newFormData.append("version", '0.0.1');
newFormData.append("name", 'Test-EdgeOS');
newFormData.append("platform", 'NETFIELD');
newFormData.append("type", 'update');
newFormData.append('file', fs.createReadStream('test.json'));

edgePortal.edgeos.update(edgeosId, newFormData, [callback]);

createTenant

Create tenant's root organization.

 * @param {object} params
 * @param {function} callback optional
const creationParams = {
    "name": "string",
    "admin": {
        "email": "asdf@mail.de",
        "firstName": "string",
        "lastName": "string",
        "jobTitle": "string",
        "department": "string",
        "mobilePhone": "string",
        "telephone": "string",
        "street": "string",
        "houseNumber": "string",
        "addressSuplement": "string",
        "zipCode": "string",
        "city": "string",
        "country": "string"
    },
    "phoneNumber": "number",
    "street": "string",
    "houseNumber": "string",
    "addresSupplement": "string",
    "zipCode": "string",
    "city": "string",
    "country": "string",
    "notes": "string",
    "childOrganisationsLimit": "number",
    "usersLimit": "number",
    "devicesLimit": "number",
    "keysLimit": "number"
};

edgePortal.tenants.create(creationParams, [callback]);

updateTenant

Update tenant by the tenant's Id.

 * @param {number} tenantId
 * @param {object} params
 * @param {function} callback optional
let tenantId = 10;

let updateParams = {
    "childOrganisationsLimit": 10,
    "usersLimit": 10,
    "devicesLimit": 10,
    "keysLimit": 10
}

edgePortal.tenants.update(tenantId, updateParams, [callback])

getTenant

Get a tenant by tenant Id * @param {number} tenantId * @param {function} callback optional

let tenantId = 10;

edgePortal.tenants.get(id, [callback]);

getTenants

Get All tenat organizations.

 * @param {number} page
 * @param {number} limit
 * @param {number} sortBy optional
 * @param {number} sortOrder optional
 * @param {function} callback optional
edgeSDK.tenants.getAll(1, 10,"name", "asc"  [callback]);

deleteTenant

Delete tenant by root organisation Id.

 * @param {number} organisationId
 * @param {function} callback optional
const tenantId = 10;

edgePortal.tenants.delete(tenantId, [callback])

Tests

Setup your testing enviorment to localmachine and change configuration troug method

edgePortal.setConfiguration({
    version: '1.0.0',
    schema: 'http', // http or https
    host: '127.0.0.1',
    post: 5000,
    headers: {
        'Content-type': 'application/json',
        'Accept': 'application/json'
    }
});

Edit setings in configure file and chaneg enviorment.js to be development

const enviorment = exports.enviorment = {
    enviorment: 'development'
}

Run tests

npm run test

Error response

Error responses are structured in fallowing object

let error = {
    error: "Not Found" // Status message,
    message: "OrganisationId not found." // Description message
}

License

See LICENSE file in project.

You can’t perform that action at this time.