Automate Exporting API

Not applicable

Are there any tools that help to automate the export of an API proxy and then get it checked into Git ?

We would like to allow developers use the Cloud UI to perform their development then have them "check it in" when they are done by automating ( probably via maven ) running a command that would export, unzip and then commit their changes to GIT.

I see the maven plugin, but it doesn't seem to have an export mojo.

1 10 1,162
10 REPLIES 10

Not applicable

This could be automated relatively easy with the combination of apigeetool in NPM, which provides the capability to export the API proxies,Apigee Grunt.js, and some small knowledge of Node.js. you can also achieve this with Maven along with Mojo's, but JavaScript makes it easier.

Hey, great question.

To download or export an API proxy from Apigee Edge, you can use this:

## download the bundle zip for an api proxy
GET :mgmtserver/v1/o/deecee/apis/weather-quota/revisions/1?format=bundle
Authorization: :edge-auth 

This works whether the API Proxy is deployed or not. The above assumes mgmtserver is replaced by the Admin API endpoint for your management server (in the Apigee Edge cloud, it is https://api.enterprise.apigee.com). For example, using curl from the command line, you can do this:

curl -u USER:PASSWORD \
  $MGMTSERVER/v1/o/ORGNAME/apis/APINAME/revisions/REVNUMBER?format=bundle > bundle.zip

...replacing all the UPPERCASE) things with the appropriate choices for you.

To inquire about APIs or their revisions, use these:

## inquire api proxies in an organization

GET :mgmtserver/v1/o/ORGANIZATION/apis
Authorization: :edge-auth

## inquire revisions of a named api proxy

GET :mgmtserver/v1/o/ORGANIZATION/apis/API_PROXY_NAME/revisions
Authorization: :edge-auth 

You can put the curl command directly into a parameterized bash script. If you don't want to do the export using bash+curl, you can use any alternative scripting tool or language.

I will leave the "unzip and commit to git" as an exercise for you.

Adding to Dino's answer, I once wrote a nodejs script to download all proxies [latest revision] from Edge

https://github.com/mukundha/apigee-download-apiproxies

@Mukundha Madhavan I tried using the script. However, I noticed that the script executes successfully and creates the "data" folder. But the downloaded API proxies are all empty zip files.

Any assistance to debug this is appreciated.

@Gregory_Bonk , Welcome to Apigee Community 🙂 Great Question, I am sure once implemented this will be super helpful.

Not applicable

in the past I have been very happy with this:

https://github.com/apigeecs/apigee-migrate-tool

dont remember where or how i found it or why i decided to give it a spin.. but it was great the last time I used it.

I thought the same while experimenting with maven just recently. Is there any activity on the maven plugin to cover this?

I found @Diego Zuluaga repo https://github.com/dzuluagaapigee/apigee-ci-jenkins-git-maven-jmeter which looks like an end-to-end solution, but I haven't spent any time with it yet.

I created a bash script once to download all proxies from an org for automated backup, but it didn't push to GitHub. Its pretty rudimentary, certainly not as cool as Grunt or Maven.

@Gregory_Bonk @Diego Zuluaga @Dino OK, so I went ahead and used some old school bash scripting to automate the download of a proxy, unzip and push to Github. Its not rocket science but it works for individual proxies. It supports "silent" or single button mode for a single proxy.

I'll update to prompt for a proxy from the list if not provided and to do an all proxies mode.

In the meantime you can check it out at: https://github.com/kurtkanaskie/api-proxies-via-automation

Interesting! We all have specific needs to address. I have also written some scripts to do similar... See https://github.com/DinoChiesa/EdgeTools

I see, thanks. The apigee-migrate-tool works nicely too. Seems like we are moving toward a built in sync-with-GitHub UI option.