You can use the Automox REST API to programmatically retrieve and install updates. This article describes how to do this and references our Automox API Guide - Dev Portal.
Step 1 - Retrieve your API Key
The API key for your account is located on the Settings → Keys page of the console. For more information about API keys, see our User Guide: Managing Keys.
Step 2 - Retrieve the list of packages for a device
Using the servers/{id}/packages API endpoint issue a call to retrieve the full list of installed and available packages (software and patches) for a device.
Endpoint:
https://console.automox.com/api/servers/{server_id}/packages?o={organization_id}
Parameters:
You can find the parameters for the servers/{id}/packages
API call by navigating to the Device Detail page for the target device in question (for example, https://console.automox.com/device-detail?s=68439&o=6
)
organization_id
: Is theo=
parameter of the query string (o=6
above)server_id
: is thes=
parameter of the query string (s=68439
above)
Request:
curl -X GET --header 'Accept: application/json' 'https://console.automox.com/api/servers/68439/packages?o=6&api_key=YOUR_API_KEY'
Response:
This will return a JSON array of packages found and available for this device. You will want to filter this JSON response by looking for packages where the installed attribute is false, such as the following excerpt from a servers/{id}/packages
response:
[ { "id": 617664440, "server_id": 68439, "package_id": 214744671, "installed": false, "ignored": false, "deferred_until": null, "name": "org.mozilla.firefox", "display_name": "Firefox", "version": "56.0.1", "repo": "Installed", "package_type_name": "other", "group_ignored": false, "group_deferred_until": null, "cves": null, "cve_score": null, "severity": "other", "package_version_id": 215219918, "os_name": "OS X", "os_version": "10.12.6", "create_time": "2017-10-10T01:51:28+0000", "requires_reboot": false, "os_classification": null, "is_uninstallable": false },... ]
Step 3 - Issue the API request to install a package
Referring to the example response from Step 2, we will issue an API request to the servers/{id}/queues API endpoint to have the Firefox update installed on this device:
Endpoint:
https://console.automox.com/api/servers/{server_id}/queues?o={organization_id}&api_key=YOUR_API_KEY
Parameters:
You can find the parameters for the servers/{id}/queues
API call by navigating to the Device Detail page for the target device in question (for example, https://console.automox.com/device-detail?s=68439&o=6
)
organization_id
: Is theo=
parameter of the query string (o=6
above)server_id
: is thes=
parameter of the query string (s=68439
above)
POST Data Parameters:
The following POST data parameters must be supplied in the request body as a JSON-formatted object:
command_type_name: ["InstallUpdate" | "Reboot"] - indicates the command you want to perform on the device. For this example, we use "InstallUpdate".
args: ["\"org.mozilla.firefox\" \"com.google.Chrome\""] - A space-delimited list of packages you want to have installed on the device. The package names are derived from the name attribute of the response JSON in Step 2. Don't forget to escape the quotes if you're specifying multiple packages.
POST Data Example:
{ "command_type_name": "InstallUpdate", "args": "org.mozilla.firefox" }
Request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ "command_type_name": "InstallUpdate", "args": "org.mozilla.firefox" } ' 'https://console.automox.com/api/servers/68439/queues?o=6&api_key=API_KEY'
Response:
A successful call to this API endpoint returns HTTP status code 201 - Created
.
Comments
0 comments
Article is closed for comments.