Wednesday, May 7, 2014

Clean-up old revisions of API proxies from Apigee Org

The revisions of proxies tend to grow, specifically in an Apigee org used as development environment. Cleaning old un-deployed revisions not only de-clutters the UI but also eliminates unnecessary storage. At times speeds up deployment process too.

Following is a simple perl script I use to automatically clean up un-deployed versions of the proxy. The perl script use the resty command line client to clean up the revisions it found in the org.

#!/usr/bin/perl
use strict;
use JSON;
use Data::Dumper;

my @proxies=("apiproxy1","apiproxy2", "apiproxy3","apiproxy4");

$\ = "\n";
$user="username";
$passwd="password";

foreach my $p (@proxies) {
 print "Processing proxy: $p";
 my $res=`curl -s https://api.enterprise.apigee.com/v1/o/<orgname>/apis/$p -u $user:$passwd`;

 my $json=decode_json $res;
 my @revs=@{$json->{'revision'}};
 foreach my $rev (@revs) {
  print `curl -s -X DELETE https://api.enterprise.apigee.com/v1/o/<orgname>/apis/$p/revisions/$rev -u $user:$passwd`;
 }
}


2 comments:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Apigee, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on Apigee. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us:
    Name : Arunkumar U
    Email : arun@maxmunus.com
    Skype id: training_maxmunus
    Contact No.-+91-9738507310
    Company Website –http://www.maxmunus.com



    ReplyDelete
  2. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Apigee , kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on TECHNOLOGY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Sangita Mohanty
    MaxMunus
    E-mail: sangita@maxmunus.com
    Skype id: training_maxmunus
    Ph:(0) 9738075708 / 080 - 41103383
    http://www.maxmunus.com/



    ReplyDelete