Skip to content

Instantly share code, notes, and snippets.

@cdelashmutt-pivotal
Last active July 10, 2018 18:48
Show Gist options
  • Save cdelashmutt-pivotal/ae780a4119740db7209b7f5e18e148f3 to your computer and use it in GitHub Desktop.
Save cdelashmutt-pivotal/ae780a4119740db7209b7f5e18e148f3 to your computer and use it in GitHub Desktop.
OpsMan API Call to convert retrieved properties on a staged time to the format needed for setting those properties
#!/bin/bash
opsman_host_or_ip=YOUR_OPSMAN_IP_OR_HOSTNAME
uaac target "https://$opsman_host_or_ip/uaa" --skip-ssl-validation
uaac token owner get opsman <OPS-MAN-ADMIN-USER>
#Client secret: JUST_PRESS_ENTER
#Password: YOUR_PASSWORD_HERE
access_token=$(uaac context | grep access_token | tr -d " " | cut -d ':' -f 2)
product_guid=$(curl "https://$opsman_host_or_ip/api/v0/staged/products" -X GET -H "Authorization: Bearer $access_token" -k | jq -r '.[] | select(.type=="some-product-name")| .guid')
curl "https://$opsman_host_or_ip/api/v0/staged/products/$product_guid/properties" -X GET -H "Authorization: Bearer $access_token" -k | jq '.properties | to_entries | map(select(.key | match("^your-regex-here.*$"))) | from_entries | map_values({value: .value}) | {properties: .}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment