Asynchronous actions
Last modified by Hostkey Admin on 2022/06/30 11:39
Some operation with the servers could take a long. Many API calls will return async key when called.
Example:
Step 1 Example request to reboot server cURL:
curl -s "https://invapi.hostkey.com/eq.php" -X POST \
--data "action=on" \
--data "token=YOUR_ACCESS_TOKEN" \
--data "id=SERVER_ID" \
--data "pin=PIN_CODE"
--data "action=on" \
--data "token=YOUR_ACCESS_TOKEN" \
--data "id=SERVER_ID" \
--data "pin=PIN_CODE"
Response:
{
"result":"OK",
"action":"on",
"callback":"f685eaa0f06e47faa2e6bb5002828b00"
}
"result":"OK",
"action":"on",
"callback":"f685eaa0f06e47faa2e6bb5002828b00"
}
it means what async request was successfully sent, async key to keep track of it is f685eaa0f06e47faa2e6bb5002828b00
Step 2 You could track state of the request:
curl -s "https://invapi.hostkey.com/eq_callback.php" -X POST \
--data "action=check" \
--data "key=f685eaa0f06e47faa2e6bb5002828b00"
--data "action=check" \
--data "key=f685eaa0f06e47faa2e6bb5002828b00"
Uncompleted task response (Result: Not ready):
{
"result":"Not ready",
"key":"f685eaa0f06e47faa2e6bb5002828b00"
}
"result":"Not ready",
"key":"f685eaa0f06e47faa2e6bb5002828b00"
}
Completed task response (Result: OK):
{
"result": "OK",
"scope": "Post is on",
"context": {
"action": "on",
"id": "SERVER_ID",
"location": "NL"
},
"debug": "Chassis Power Control: Up/On",
"key": "f685eaa0f06e47faa2e6bb5002828b00"
}
"result": "OK",
"scope": "Post is on",
"context": {
"action": "on",
"id": "SERVER_ID",
"location": "NL"
},
"debug": "Chassis Power Control: Up/On",
"key": "f685eaa0f06e47faa2e6bb5002828b00"
}
scope | message to the user |
context | JSON with initial request and some extra data. Usefull to proceed during AJAX calls |
debug | hardware output from device |
key | our async key. Its become deleted after successful response OK |