Skip to content

Instantly share code, notes, and snippets.

@imobachgs
Created November 6, 2025 15:40
Show Gist options
  • Save imobachgs/64873c98de8c1315b7dda72bbe08e0d3 to your computer and use it in GitHub Desktop.
Save imobachgs/64873c98de8c1315b7dda72bbe08e0d3 to your computer and use it in GitHub Desktop.
Interacting with Agama's API

Interacting with Agama's API

This document includes some small scripts that you can use to interact with Agama's API from the CLI. You must define the Agama's server URL using the AGAMA_URL (e.g., https://192.168.122.10).

Logging in

The following script logs in and writes the headers to use in the subsequent calls in the headers.txt file. Adjust the password (linux) to your use case.

#!/usr/bin/bash

set -x

echo $AGAMA_URL
TOKEN=$(curl -k --silent $AGAMA_URL/api/auth -d '{"password": "linux"}' \
  -H "Content-Type: application/json" | jq .token | tr -d '"')

echo "Content-Type: application/json" >headers.txt
echo -n "Authorization: Bearer " >>headers.txt
echo $TOKEN >>headers.tx

Setting the product

The following script sets a new configuration ("SLES" with the "gnome" pattern).

#!/usr/bin/bash

# reset the configuration (if you want)
curl -k -H @headers.txt -X PUT $AGAMA_URL/api/v2/config -d '{}'

# partially update the configuration
curl -k -H @headers.txt -X PATCH $AGAMA_URL/api/v2/config -d '{"update": {"product": {"id": "SLES"}, "software": {"patterns": ["gnome"] }}}'

curl -k -H @headers.txt -X GET $AGAMA_URL/api/v2/config | jq

Getting the system, the proposal, etc.

#!/usr/bin/bash

curl -k -H @headers.txt -X GET $AGAMA_URL/api/v2/system | jq
curl -k -H @headers.txt -X GET $AGAMA_URL/api/v2/proposal | jq
curl -k -H @headers.txt -X GET $AGAMA_URL/api/v2/issues | jq
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment