Skip to content

Latest commit

 

History

History
210 lines (126 loc) · 8.1 KB

README.md

File metadata and controls

210 lines (126 loc) · 8.1 KB

Apigee Edge sample API proxies

Audience

You are an Apigee Edge API proxy developer, or you would like to learn about developing APIs that run on Apigee Edge. At a minimum, we assume you're familiar with Apigee Edge and how to create simple API proxies. To learn more, we recommend this getting-started tutorial.

These samples were built to work with Apigee EDGE. The current version of Apigee is known as Apigee X. Most of these samples will work with Apigee X, but the deployment scripts will not, and the instructions for administrative actions (eg, sign up for an account at apigee.com) will not work either. In those cases, you will need to substitute the appropriate actions relating to Apigee X!

Bear with us, please!

Intro

This repository contains a collection of sample API proxies that you can deploy and run on Apigee Edge.

alt text

The samples provide a jump-start for developers who wish to design and create Apigee Edge API proxies. Each proxy sample includes a deploy.sh and invoke.sh script. These scripts let you easily deploy and run the proxies.

In addition, you'll find:

  • API proxy schemas that you can reference
  • Tools for deploying proxies to Apigee Edge
  • Cookbook samples, which illustrate specific use cases

Before you begin

  1. If you don't have one, you'll need to obtain an Apigee account. Sign up for a free trial account.

  2. You also need to have Python on your system, to use the deployment tool.

  3. Download this project from GitHub to your system.

Using the sample proxies

Most developers begin by identifying an interesting sample based on a specific use case or need. You'll find the samples in the ./api-platform-samples/sample-proxies folder. The Apigee doc site also has a handy samples overview page.

For example, if you're interested in doing XML to JSON transformations, check out api-platform-samples/sample-proxies/xmltojson.

Setting up

Set up your deployment environment.

  1. Open the file ./api-platform-samples/setup/setenv.sh in a text editor.|

  2. Edit the file with your Apigee Edge account settings and save it. For example:

    org=myorg
    [email protected]
    url="https://api.enterprise.apigee.com"
    env=test
    api_domain="apigee.net"
    

Deploying a sample proxy

We make it easy:

  1. Be sure you've updated ./api-platform-samples/setup/setenv.sh as explained previously.

  2. cd to one of the sample proxy folders in ./api-platform-samples/sample-proxies.

  3. Be sure you can execute the deploy.sh script. For example:

    chmod 744 deploy.sh

  4. Execute the deploy script.

    ./deploy.sh

Note: If you already have the proxy deployed, the script will undeploy it first, then redeploy a new revision.

Output like this means a successful deployment:

    Imported new proxy version 3
    Undeploying revision 2 in same environment and path:
    Environment: test
      Revision: 3 BasePath = /
      State: error
    If 'State: deployed', then your API Proxy is ready to be invoked.
    Run 'invoke.sh'

Invoking a sample proxy

We make this easy too! Each sample API proxy directory contains a script, invoke.sh, that issues a sample HTTP request to the API. Deploy the proxy and follow these steps:

  1. Be sure you've updated ./api-platform-samples/setup/setenv.sh as explained previously.

  2. cd to one of the sample proxy folders in ./api-platform-samples/sample-proxies.

  3. Be sure you can execute the invoke.sh script. For example:

    chmod 744 invoke.sh

  4. Open the invoke.sh file and take a look at the code. Basically, the invoke scripts make curl requests to Apigee Edge. In some cases, invoke.sh performs other setup tasks, such as creating products, developer apps, and other entities on Edge.

    Tip: Always open invoke.sh and look through it before executing it -- this will give you valuable insight into how the API proxy is called and any setup steps that are performed.

  5. Execute the invoke.sh script.

    ./invoke.sh

Modifying a sample proxy

Feel free to modify and build upon the sample proxies. You can make changes in the Edge management UI or by editing the proxy XML files locally and redeploying. Whichever approach is comfortable for you.

Tip: If you use Sublime for local development, check out the Sweetlime project on GitHub. Sweetlime is a Sublime plugin for developing API proxies for Apigee Edge.

Simply redeploy the proxies for changes to take effect.

Bulk deployment

You can deploy all of the samples to your organization at once using a simple setup script provided in this distribution.

  1. Update the file /setup/setenv.sh with settings for your Apigee account.

  2. Run deploy_all.sh

    Note: This step deploys all API products, developers, and apps needed for samples that use OAuth.

What else is here?

In addition to the sample proxies, this project includes the following:

/learn-edge

The Learn Edge series is a hands-on learning experience for beginning Edge developers. Each example is designed to be quick and easy to do, teaches a core Apigee Edge concept or technique, and follows three basic steps:

  1. Deploy it.
  2. Run it.
  3. Trace it.

The best way to learn Apigee Edge is by doing!

/schemas

XML schemas that you can use as a reference when working with policies, API proxy configuration, API products, apps, and developers.

/setup

Simple scripts to help you deploy the sample API proxies and profiles that they rely on, including API products, developers, and apps.

Set you Apigee API Platform account settings in setenv.sh (Register for a free Apigee account)

To deploy a single sample, run deploy.sh proxyName, where proxyName is the name of the directory under /sample-proxies that contains the proxy you want to deploy.

To deploy all samples and API products, run deploy_all.sh

/tools

  • deploy.py: Uploads an API proxy to an organization on the Apigee Edge API Services platform and then deploys it to the environment specified.

  • proxy_gen.sh: A simple script that interacts with the API Services platform to locally generate an API proxy scaffold.

  • /org-snapshot: A configurable tool that retrieves organization settings from the API Services platform by using management server API calls.

Ask questions on the Apigee Community

alt text

Apigee Edge documentation

The Apigee Edge docs are here.


Copyright © 2018 Apigee Corporation, 2024 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.