Get list of router for each Org and Env

Hello,

I need to get list (uuid) of router for each Org/Env,

I can use Curl but I have many Env in a specific Org, and I would like to get all of them with one command or script.

In one Org I have many Env, I would like to track them...


Thanks for suggestion.

,

Hello,

I need to get list (uuid) of router for each Org/Env,

I can use Curl but I have many Env in a specific Org, and I would like to get all of them with one command or script.

Thanks for suggestion.

0 1 204
1 REPLY 1

The following bash function can be used for listing hosts of all router pods of a given Apigee organization. In this I am using Resty: https://github.com/micha/resty and jq: https://stedolan.github.io/jq/. You could change '.internalHostName' to '.uUID' and generate a list of UUIDs if needed.

function generate_router_hosts() {
   org=$1
   if [ -z ${org} ]; then
      echo "Usage: generate_router_hosts [org]"
      return 1
   fi
   echo "Reading router pods..."
   GET /o/$org/pods | jq -c '.[]' | while read i; do
      pod=$(echo $i | jq -c '.name' | sed s/\"//g)
      region=$(echo $i | jq -c '.region' | sed s/\"//g)
      filename="$org-$region-$pod-router.hosts"
      
      echo "Reading server list for region=$region/pod=$pod"
      GET /regions/$region/pods/$pod/servers | jq -c '.[] | select( .type | tostring | contains("router")) | .internalHostName' | sed s/\"//g > $filename
      echo "File written: $filename"
   done
}