JFrog Connect REST API – Triggering Updates
可以我们JFrog连接设备管理平台ed to deploy OTA updates on your Linux edge devices. However, executing an update routine on an edge device must need to be carried out cautiously to minimize the disturbance and downtime that can be caused by the update process. This can be done by 2 methods:
- Manually – Update edge devices when they are idling
- Automatically – Use the edge device to request for updates from the platform when it’s idling
Typically, since there can be many devices performing different tasks, it can be challenging to monitor the device’s usage just to push an update. Therefore, it’d be an elegant solution to add a small REST API call within the program that runs on a Linux device that can inform the dashboard of its availability to receive an update.
JFrog Connect’supdate triggerAPI call allows you to take the advantage of such a mechanism, which you may use to simply inform the dashboard whether it’s ready to receive an update or not. This API call is an HTTP POST request, of which the payload should be of JSON format.
For simplicity, the script is written in Python and the prerequisite modules arejsonandrequests. These are by default installed with every Python installation, and the scripts are cross-platform compatible.
Step 1 – Python script template for changing the update trigger
The Device Token is unique per device and each device receives one upon first enrollment/registration, and can be found at /etc/upswift/service/settings.json file on each device. The next python script includes an automatic function to pull the Device Token and the User Token that will be used to change the update trigger using an API call.
Create a new file using nano
Step 2 – Execute the script and verify the functionality
Type in the command python
Step 3 – Changing the update trigger availability
By changing thetrigger_setJSONkey’s value toTrue/Falsein the script in Step 2 and re-running the script, the device’s availability to receive updates can easily be changed on the dashboard. If thetrigger_sethas been set toTrueand the script is executed, JFrog Connect will defer any future updates until thetrigger_setflag has been set to False by a future execution of the script.
Although this example has been written in Python for clarity, basically any programming language that supports HTTP POST requests should be able to call these APIs with the required JSON format payload and perform the same task.
For more information on the JFrog Connect Change Device Details API, please feel free to refer to theofficial documentation.