New example administrative scripts! find expired credentials, remove an unwanted proxy, etc

hi Friends!

I love a challenge A Couple days ago, someone asked here on the Apigee community if there was a way to automate the removal of an API Proxy that was no longer wanted or needed. Including removing it from any API Products.

That's a simple enough job, using the Apigee administrative UI. but if there will be more than 1 or 2 proxies to remove, the job should be done by an automated script.

The good news is, (a) there is a complete, documented, supported Administrative API for Apigee, and ... (2) there are libraries that wrap that API to make it easier to use from Powershell, Nodejs, or PHP. (Not sure about Java!)

When building tools and scripts for administrative tasks, I lean toward nodejs, myself. I find that it's pretty easy to build things quickly. Because a challenge like this is always hard for me to resist, I produced the "remove a proxy" script. Then, I produced a couple other new examples. Here's a quick summary.

  1. removeProxy.js

    The way this one works: it queries all the API Products in an organization, then filters that list for the API Products that explicitly include a particular API Proxy. Then removes that proxy from each API Product. Then queries for the deployment status of ANY revision of the API Proxy, undeploys as necessary, and then finally removes the API Proxy. This script includes a --doit option; omitting it allows you to check what would happen if you actually made the changes.

  2. deleteExpiredCredentials.js

    This tool scans all apps in the Apigee organization, searching for credentials that are expired. It then removes those credentials from the apps. Pretty simple! As with the above script, there is a --doit option; omitting it allows you to check what credentials the tools would remove.

  3. showAppsByCredentialStatus.js

    This tool shows app credentials in the organization, grouped into sets: non-expiring, expired, soon-to-expire, and will expire "later". You can specify the timeframe that defines "soon". With this tool you can check which app credentials will expire within 30 days, for example. You might use this tool to figure out which developers need to be notified about soon-to-expire credentials.

These are just the latest example administrative scripts I published to the apigee-edge-js-examples repo.

There are now 50 different examples there, showing you practical examples for how to write your own nodejs scripts to automate the administration of Apigee. And they're usable tools, too! Some examples of the existing tools:

There are lots more.

How can you get started using these tools, and maybe in creating your own nodejs scripts?Just follow the instructions in the README on that repo. Make sure you have git, node, and npm. Then, Clone the repo, and get started.

Happy Scripting!

Comments
Not applicable

nice one. I really needed this findProxyForBasepath.js

Version history
Last update:
‎11-05-2020 07:59 AM
Updated by: