-
Notifications
You must be signed in to change notification settings - Fork 4
Integration with API
Checkout the pdp tag from docker-hub for IDM (https://hub.docker.com/r/agileiot/agile-idm-armv7l/tags/)
Then execute the following code updating your token.
var token = "MhydyN9dEfGvLUiqXqgAkCuAQ8l8U9pukrzyDDwzj9xiPW5ZpNTFBHutQIkxdb5z";
var api = ''
var idmurl = 'http://agilegw.local:3000';
var agile = require('agile-sdk')({
api: api,
idm: idmurl,
token: token
});
agile.idm.entity.create("dummy001122334455","device",{"name":"Dummy"})
.then(function(entity){
console.log('device created !'+JSON.stringify(entity))
}).catch(function(err) {
console.log(err)
});
Alternatively, you can checkout the agile-ui security branch and execute it with npm (and pass the token as query argument, i.e. /?token=blabla. When you register a device, this UI is already creating the device in IDM.
Now, set the TOKEN as an env variables, and to test the pdp, execute the following CURL lines.
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"status", "operation":"get"}' # GET /device/{deviceId}/status
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"components", "operation":"get"}' # GET /device/{deviceId}/
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"components", "operation":"post"}' #POST /device/{deviceId}/{componentId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"components", "operation":"get"}' # GET /device/{deviceId}/lastUpdate
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"connection", "operation":"post"}' # POST /device/{deviceId}/connection
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"execute", "operation":"post"}' # POST/device/{deviceId}/execute/{command}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/componentId' -d '{"action":"subscribe", "operation":"post"}' # POST/device/{deviceId}/{componentId}/subscribe
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"description", "operation":"get"}' # GET/devices ........ This happens for each device description
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/management/' -d '{"action":"device", "operation":"post"}' # POST /devices/
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"description", "operation":"get"}' # POST/devices/typeof ...maybe this is equivalent to finding out the information of a device?? talk to Csaba
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"description", "operation":"get"}' # GET/devices/{deviceId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"description", "operation":"put"}' # PUT/devices/{deviceId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/' -d '{"action":"description", "operation":"delete"}' # DELETE /devices/{deviceId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/management/' -d '{"action":"protocol", "operation":"get"}' # GET/protocols
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/management/' -d '{"action":"protocol", "operation":"get"}' # GET /protocols/{protocolId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/management/' -d '{"action":"protocol", "operation":"post"}' # POST /protocols/{protocolId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/management/' -d '{"action":"protocol", "operation":"delete"}' # DELETE /protocols/{protocolId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/data/device/123/' -d '{"action":"description", "operation":"get"}' # GET/protocols/devices ........ This happens for each device description
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/management/' -d '{"action":"discovery", "operation":"get"}' # GET/protocols/discovery
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/management/' -d '{"action":"discovery", "operation":"post"}' # POST /protocols/discovery
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/management/' -d '{"action":"discovery", "operation":"delete"}' # DELETE /protocols/discovery