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).
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.txThe 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#!/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
```