Using the Edge management API to download a proxy revision is an easy way to migrate proxies between different organizations. Downloading proxies is also used during API lifecycle management processes. This is a very straightforward process and is easy to integrate into your SDLC.
In the video we show how to download a proxy using the UI and the management API. We also provide a simple script to download all the proxies in an organization.
Check out documentation on the Edge Management API, including the specific documentation for exporting an API proxy revision.
The example script to export all proxies in an org is as follows:
<code>host=https://api.enterprise.apigee.com;org=ORGNAME; \ for proxy in `curl $host/v1/o/$org/apis | jq '.[]' | \ sed -e 's/"//g'`; do echo "downloading to $proxy.zip..."; \ curl $host/v1/o/cdmo/apis/$proxy/revisions/`curl \ $host/v1/organizations/$org/apis/$proxy | jq '.revision \ | max | tonumber'`?format=bundle -o $proxy.zip; done
While at first blush this is complex, stepping through the construction of it should clarify things. ** There may well be more elegant scripts to do this. If you have a nicer solution, please share! **
<code>ApigeeCorporation in ~ ☯ host=https://api.enterprise.apigee.com;org=cdmo; \ → curl $host/v1/o/$org/apis [ "rot13", "bucketlist", "identity-demo-app", "weather-sample", "tester", "identity-consentmgmt-api", "second-problem", "idwapi", "konakart", "jsonpath", "identity-usermgmt-api", <snip>
<code> ApigeeCorporation in ~ ☯ host=https://api.enterprise.apigee.com;org=cdmo; \ → curl $host/v1/o/$org/apis | jq '.[]' "rot13" "bucketlist" "identity-demo-app" "weather-sample" "tester" "identity-consentmgmt-api" "second-problem" "idwapi" "konakart" "jsonpath" "identity-usermgmt-api"
<code>ApigeeCorporation in ~ ☯ host=https://api.enterprise.apigee.com;org=cdmo; \ → curl $host/v1/o/$org/apis | jq '.[]' | sed -e 's/"//g' rot13 bucketlist identity-demo-app weather-sample tester identity-consentmgmt-api second-problem idwapi konakart jsonpath identity-usermgmt-api
Now we have something we can loop through in bash and create a curl call to download the proxy.
<code>ApigeeCorporation in ~ ☯ host=https://api.enterprise.apigee.com;org=cdmo; \ → curl $host/v1/o/$org/apis/presos { "metaData": { "createdAt": 1391191116356, "lastModifiedAt": 1391461096594 }, "name": "presos", "revision": [ "1", "2", "3", "4", "5", "6", "7", "8", "9" ] }
<code>ApigeeCorporation in ~ ☯ host=https://api.enterprise.apigee.com;org=cdmo; \ → curl $host/v1/o/$org/apis/presos | jq '.revision | max | tonumber' 9
Now we have a list of proxies we can loop through easily, and a one-liner to get the revision number for each proxy. Putting it all together gives us our final script:
<code>host=https://api.enterprise.apigee.com;org=ORGNAME; \ for proxy in `curl $host/v1/o/$org/apis | jq '.[]' | \ sed -e 's/"//g'`; do echo "downloading to $proxy.zip..."; \ curl $host/v1/o/cdmo/apis/$proxy/revisions/`curl \ $host/v1/organizations/$org/apis/$proxy | jq '.revision \ | max | tonumber'`?format=bundle -o $proxy.zip; done