# Example: reboot equipment command execution

# Send the operation request to OpenGate

Click bellow to see how to send the operation request to your device.

Using curl
curl 'https://api.opengate.es/north/v80/operation/jobs' \
  -H 'X-ApiKey: your-api-key' \
  -H 'Content-Type: application/json' \
  -H 'Accept: */*' \
  --data '{
  "job": {
      "request": {
          "operationParameters": {
              "timeout": 90000,
              "retries": 0,
              "retriesDelay": 0
          },
          "name": "REBOOT_EQUIPMENT",
          "schedule": {
              "stop": {
                  "delayed": 120000
              }
          },
          "parameters": {
              "type": "HARDWARE"
          },
          "target": {
              "append": {
                  "entities": [
                      "649843"
                  ]
              }
          },
          "active": true
      }
  }
}'

# Receiving operation request into device

You must be connected to OpenGate MQTT connector as subscriber to topic odm/request/your-device-id, if so then you'll receive the an operation request like this:

{
  "operation": {
    "request": {
      "timestamp": 1614253699108,
      "name": "REBOOT_EQUIPMENT",
      "parameters": {
        "type": "HARDWARE"
      },
      "id": "05d17fb4-b2a8-49d8-8461-cda0d24f852b"
    }
  }
}

# Answering the operation

Your device must publish a message to the topic odm/response/your-device-id to let know OpenGate it's going to anwer the operation:

{
  "operation": {
    "response": {
      "name": "REBOOT_EQUIPMENT",
      "timestamp": 1614253700835,
      "resultDescription": "Success",
      "steps": [
        {
          "timestamp": 1614253700835,
          "description": "The system will be rebooted",
          "name": "REBOOT_EQUIPMENT",
          "result": "SUCCESSFUL"
        }
      ],
      "deviceId": "649843",
      "resultCode": "SUCCESSFUL",
      "id": "05d17fb4-b2a8-49d8-8461-cda0d24f852b"
    }
  },
  "version": "1.0"
}