-
Couldn't load subscription status.
- Fork 4
Integration with API
Get the image tagged as pdp-refactor from agile-security in your docker-compose configuration from agile-stack
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.
This shows the mappings between the PDP, and the API ( API in bash comment after the PDP call )
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XGET 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/status' # GET /device/{deviceId}/status
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XGET 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/components/componentId' # GET /device/{deviceId}/ ........ This happens for each componentId
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/components/componentId' #POST /device/{deviceId}/{componentId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XGET 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/components/componentId' # GET /device/{deviceId}/lastUpdate ........ This happens for each componentId - What is the difference between this and GET /device/{deviceId}?
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/connection' # POST /device/{deviceId}/connection
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XDELETE 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/connection' # DELETE /device/{deviceId}/connection
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/execute/{command}' # POST/device/{deviceId}/execute/{command}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/components/componentId/subscribe' # POST/device/{deviceId}/{componentId}/subscribe
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XDELETE 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/components/componentId/subscribe' # DELETE /device/{deviceId}/{componentId}/subscribe
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XGET 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/description' # 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/gateway/self/actions/device' # POST /devices/
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XGET 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/description' # 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" -XGET 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/description' # GET/devices/{deviceId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPUT 'http://agilegw.local:3000/api/v1/pdp/device/dummy001122334455/actions/description' # PUT/devices/{deviceId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XDELETE 'http://agilegw.local:3000/api/v1/pdp/data/device/dummy001122334455/actions/description' # DELETE /devices/{deviceId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XGET 'http://agilegw.local:3000/api/v1/pdp/gateway/self/actions/protocols/{protocolId}' .. this happens for each protocol # GET/protocols
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XGET 'http://agilegw.local:3000/api/v1/pdp/gateway/self/actions/protocols/{protocolId}' # GET /protocols/{protocolId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/gateway/self/actions/protocols/{protocolId}' # POST /protocols/{protocolId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XDELETE 'http://agilegw.local:3000/api/v1/pdp/gateway/self/actions/protocols/{protocolId}' # DELETE /protocols/{protocolId}
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XGET 'http://agilegw.local:3000/api/v1/pdp/device/123/actions/description' # GET/protocols/devices ........ This happens for each device description
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XGET 'http://agilegw.local:3000/api/v1/pdp/gateway/self/actions/discovery' # GET/protocols/discovery
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XPOST 'http://agilegw.local:3000/api/v1/pdp/gateway/self/actions/discovery # POST /protocols/discovery
curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -XDELETE 'http://agilegw.local:3000/api/v1/pdp/gateway/self/actions/discovery' # DELETE /protocols/discovery