How do I get the list of all proxies using a specific policy ?

If you are looking to extract a list of all proxies that contain a specific policy, eg. to get list of proxies that have "messageLoggingGscApigee" policy, then this article offers some suggestions.

First off, there is no direct management API that you can call for that retrieval, unfortunately.

The work around essentially requires downloading the deployed proxies to some temp folder and search for the term within the downloaded bundles.

There are 2 alternatives:

1. 3rd party tool run on nodejs :
https://github.com/mecclesgoogle/apigee-bundle-search

2. Re-use the following script, please do modify to suit your usage:

Step1. get the list of all proxies deployed for an org + env
Step2. for each of of the proxy found in step 1, download the bundle. Use script [1].
Step3. Now you have a list of .zip file (bundles) in your machine.
For each of these zip files, open it up, you will see a folder /apiproxy/, which in turn has an xml file. That xml file defines the structure of your proxy.
Search the xml file, to find reference to your target server.

Pre-requisite:
(1) server runs in Linux.
(2) "jq" installed.

===>

Script [1]

#!/bin/sh
apibase=https://api.enterprise.apigee.com
orgname={your_org_name}
envname={your_env_name}

10867-deployments-script.png

for i in $deployments
do
  i=`echo $i | sed 's/"//g'`
  proxy=`echo $i | awk -F'|' '{print $1}'`
  rev=`echo $i | awk -F'|' '{print $2}'`
  #download bundle
  curl "$apibase/v1/o/$orgname/apis/$proxy/revisions/$rev?format=bundle -o $proxy-$rev.zip"
done;

Script [2]

#!/bin/bash
for i in $(ls *.zip)
do
  unzip -c $i apiproxy/proxies/default.xml > "$i"-default.xml
done

Script [3]

grep {policy_name} *.xml
Comments
dchiesa1
Staff

Here's another option for doing same: finding policies by name.

findPoliciesByName.js

This script can optionally check proxies, SharedFlows, or both.

MayhemRitual
Bronze 1
Bronze 1

Thanks for sharing all this! I'll try to test in my own skin, and we'll see how it goes.

Version history
Last update:
‎03-15-2021 11:43 PM
Updated by: