System information
If you have already logged in to the Satellite 6 WebUI, you can see the default results of GET requests
at /api/v2/<API-NAME>/. For example:
https://satellite6.example.com/api/v2/users/
https://satellite6.example.com/api/v2/users/3
Usin g Satellite 6 API Requ ests on t h e Command Lin e
You can use the curl command to interact with the Satellite 6 API. For example:
Examp le 4 .1. Examp le G ET Requ ests
Example GET requests to list organizations, hosts, and users within Satellite 6.
# SATUSER=admin
# SATPASS='changeme'
# SATURL="https://localhost"
# curl -k -u $SATUSER:$SATPASS -X GET -H 'Accept: application/json'
$SATURL/api/v2/organizations | json_reformat
# curl -k -u $SATUSER:$SATPASS -X GET -H 'Accept: application/json'
$SATURL/api/v2/hosts | json_reformat
# curl -k -u $SATUSER:$SATPASS -X GET -H 'Accept: application/json'
$SATURL/api/v2/users | json_reformat
# curl -k -u $SATUSER:$SATPASS -X GET -H 'Accept: application/json'
$SATURL/api/v2/users/3 | json_reformat
Examp le 4 .2. Examp le DELETE Requ est
An example DELETE request to remove an existing user with known ID "9" based on a previous list
of users.
# curl -k -u $SATUSER:$SATPASS -X DELETE -H 'Accept: application/json'
$SATURL/api/v2/users/9 | json_reformat
Examp le 4 .3. Examp le PO ST R eq u est
An example POST request to create a new user called exampl e, passing the true flag to enable
administrator privileges for the user.
# curl -k -u $SATUSER:$SATPASS -X POST -d '{ "mail": "root@ localhost",
"firstname": "Example", "lastname": "User", "login": "example",
"password": "redhat", "admin": 'true', "auth_source_id": 1 }' -H
'Accept: application/json' -H 'Content-Type: application/json'
$SATURL/api/v2/users | json_reformat
Examp le 4 .4 . Examp le PUT Req u est
An example PUT request to change the email address of the existing exampl e user with known ID
"10" to example@ localhost.
Chapt er 4 . Advanced T ransit ioning
53