{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
4

Tutorial: How to download a proxy using the UI and the management API  

  • Export to PDF
Carlos Eberhardt created · Dec 11, 2015 at 04:36 AM · 7.7k Views · edited · Feb 09, 2016 at 07:37 PM

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! **

  1. First, list all the proxies defined in our org:
    <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>
    	
  2. The result is just a json array, so in order to loop through that in bash we need the items in a clean list. For that we turn to jq. (I’m never above jumping outside core tools if it makes life easier.)
    <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"
    	
  3. Closer, but we still have quotes we don’t need. Sed can take care of that…
    <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.

  4. But if we want to grab the latest revision of each proxy we’ll also need to retrieve that for each one. Given a specific proxy, here’s how we can find the revisions:
    <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"
      ]
    }
    	
  5. Turning to jq again we can get the max revision for a specific proxy:
    <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
    	
thub.nodes.view.add-new-comment
proxy4mv4dtutorialvideo
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Article

Contributors

avatar image avatar image avatar image

Follow this article

10 People are following this .

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Navigation

Tutorial: How to download a proxy using the UI and the management API

Related Articles

How to enforce API Product Quotas - An Example

Tutorial : Create an API Proxy in Apigee Edge

Tutorial: How to use Target Servers in your API Proxies

Tutorial: OAuth 2.0 using Password Grant

Apigee Edge - 4MV4D - Quota Policy - Message Weight - S02E05

Apigee 4MV4D - Programming of APIs - Series - The Apigee Edge - S01E02

Tutorial: How to protect your API proxy's target backend against severe traffic spikes and denial of service attacks

Apigee Edge - 4MV4D - Quota Policy - Calendar Type - S02E06

Apigee 4MV4D - Programming of APIs - Series - API Proxy - S01E03

Tutorial: How to create routing rules

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges