Skip to content

Instantly share code, notes, and snippets.

@dmikusa
Created August 18, 2019 16:46
Show Gist options
  • Save dmikusa/3dedcf87de7ed14b11556c40cf0c26cb to your computer and use it in GitHub Desktop.
Save dmikusa/3dedcf87de7ed14b11556c40cf0c26cb to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# requires `jq`
function load_all_pages {
URL="$1"
DATA=""
until [ "$URL" == "null" ]; do
RESP=$(cf curl "$URL")
DATA+=$(echo "$RESP" | jq .resources)
URL=$(echo "$RESP" | jq -r .next_url)
done
# dump the data
echo "$DATA" | jq .[] | jq -s
}
# example usage:
function load_all_apps {
SPACE_GUID="$1"
load_all_pages "/v2/spaces/$SPACE_GUID/apps"
}
APPS=$(load_all_apps "$SPACE_GUID")
echo $APPS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment