Send kubernetes API
This section describes the MQTT messages and topics the Management Service handles to
perform the send-kubernetes-api
action. When using AnythingDB in Studio all
of this is taken care of within the product.
Sending a Message to the Management Service
spaces/<space>/collections/cluster/things/<thing-id>/actions/send-kubernetes-api
The message format for publishing is as follows:
{
"send-kubernetes-api": {
"input": {
"correlationId": "{create-a-unique-id-for-each-message}",
"requestMethod": "{GET|POST|PUT|PATCH|DELETE}",
"href": "{see API docs}",
"requestBody": "{body if required}"
},
"status": "pending",
"timeRequested": "<datetime>",
"href": "/spaces/<space>/collections/cluster/things/<thing-id>/actions/send-kubernetes-api/<action-id>"
}
}
The requestBody
is a string. For a JSON requestBody
this means it has to be stringified first. This results in "double
JSON-encoding".
For example:
{
"send-kubernetes-api":{
"input":{
"correlationId": "666",
"requestMethod": "GET",
"href": "/api/v1/nodes",
"requestBody": ""
},
"status": "pending",
"timeRequested": "2020-05-26 15:37:46+0000",
"href": "/spaces/may-space/collections/cluster/things/my-thing-id/actions/send-kubernetes-api/1234"
}
}
Status Update After Receiving Action Request
spaces/<space>/collections/cluster/things/<thing-id>/actions
Message:
{
"send-kubernetes-api": {
"href": "/spaces/<space>/collections/cluster/things/<thing-id>/actions/send-kubernetes-api/<action-id>",
"status": "received"
}
}
Event Publish After Running Action
spaces/<space>/collections/cluster/things/<thing-id>/events
Message:
{
"send-kubernetes-api": {
"data": {
"correlationId": "{the-unique-id-from-the-request}",
"statusCode": "{an-http-status-code}",
"statusMessage": "{optional descriptive message}",
"response": "{the output of the API request}"
}
}
}
Example:
{
"send-kubernetes-api": {
"data": {
"correlationId": "666",
"statusCode": 200,
"statusMessage": "Command executed successfully",
"response": ""
}
}
}
You need to use the correlationId
to match the response to the
request.
Status Update After Completing Action
spaces/<space>/collections/cluster/things/<thing-id>/actions
Message:
{
"send-kubernetes-api": {
"href": "/spaces/<space>/collections/cluster/things/<thing-id>/actions/send-kubernetes-api/<action-id>",
"status": "completed"
}
}