How to Operate Devices
Requirements
-
A Valid API Key:Provisioned and provided by your platform administrator for South API.
Method |
|
Platform API Endpoint |
|
Device API Endpoint |
|
Two alternatives can be used to implement the Device side operations:
-
Synchronous The simplest way is using the Synchronous flow strategy that requires implementing a webservice in the device that can receive HTTP POST to the above defined URI and embedded the response JSON in to the HTTP response body
-
Asynchronous Using the Synchronous flow strategy requires:
-
Implementing a webservice in the device that can receive HTTP
POST
to the above defined URI -
Sending from the device a HTTP
POST
request to the above defined paltform URI
-
in both cases including a correctly formatted JSON documents in the POST body to set operation configurable parameters.
Find all options in the South API Operations section |
Find the Platform side in How to remote operate devices through North API |
curl --request POST \ --data-binary @opengate-api-south-operation-request.json \ --header "X-ApiKey: YOUR_API_KEY_HERE" \ --verbose \ http://[your_device_address]/south/v80/devices/{device.id}/operation/request \ -H "Content-type: application/json"
{ "operation": { "request": { "timestamp": 1432454277950, "name": "REBOOT_EQUIPMENT", "parameters": { "type": "HARDWARE" }, "id": "072b08d1-0fcb-4a0c-a2d8-99773f9b9327" } } }
HTTP/1.1 201 Created
{ "version": "7.0", "operation": { "response": { "timestamp": 1432454278000, "name": 'REBOOT_EQUIPMENT', "id": "072b08d1-0fcb-4a0c-a2d8-99773f9b9327", "resultCode": "SUCCESSFUL", "resultDescription": "No Error.", "variableList": [], "steps": [] } } }
curl --request POST \ --data-binary @opengate-api-south-operation-request.json \ --header "X-ApiKey: YOUR_API_KEY_HERE" \ --verbose \ http://[your_device_address]/south/v80/devices/{device.id}/operation/request \ -H "Content-type: application/json"
{ "operation": { "request": { "timestamp": 1432454277950, "name": "REBOOT_EQUIPMENT", "parameters": { "type": "HARDWARE" }, "id": "072b08d1-0fcb-4a0c-a2d8-99773f9b9327" } } }
HTTP/1.1 201 Created
curl --request POST \ --data-binary @operation_response.json \ --header "X-ApiKey: YOUR_API_KEY_HERE" \ --verbose \ http://[your_opengate_address]/south/v80/devices/{device.id}/operation/response \ -H "Content-type: application/json"
{ "version": "7.0", "operation": { "response": { "timestamp": 1432454278000, "name": 'REBOOT_EQUIPMENT', "id": "072b08d1-0fcb-4a0c-a2d8-99773f9b9327", "resultCode": "SUCCESSFUL", "resultDescription": "No Error.", "variableList": [], "steps": [] } } }