export AL_USERNAME=''; export AL_PASSWORD=''; aims_url='api.global.alertlogic.com'; auth=$(curl -X POST -s -u $AL_USERNAME:$AL_PASSWORD "https://$aims_url/aims/v1/authenticate"); export AL_ACCOUNT_ID=$(echo $auth | jq -r '.authentication.account.id'); export AL_USER_ID=$(echo $auth | jq -r '.authentication.user.id'); export AL_TOKEN=$(echo $auth | jq -r '.authentication.token'); if [ -z $AL_TOKEN ]; then echo "Authentication failure"; unset AL_USERNAME; unset AL_PASSWORD; else roles=$(curl -sH "x-aims-auth-token: $AL_TOKEN" "https://$aims_url/aims/v1/$AL_ACCOUNT_ID/users/$AL_USER_ID/roles"); is_admin=$(echo $roles | jq '.roles | map(select(.name=="Administrator")) | length'); if [ -z $is_admin ]; then echo "Error: user $AL_USERNAME is not an administrator"; else if [ $is_admin -eq 1 ]; then echo "Success: user $AL_USERNAME is an administrator"; else echo "Error: user $AL_USERNAME is not an administrator"; fi; fi; fi;