Apigee API Proxy Endpoint Unifier

An Apigee API proxy sits between clients and servers to intercept requests that can be managed and processed per requirements. It can be used to implement multiple API endpoints in a single proxy by defining multiple ProxyEndpoints. This allows you to reuse policies and/or business logic before and after the invocation of a TargetEndpoint.

However, there are also some drawbacks to defining multiple ProxyEndpoints in a single API proxy which are listed below

Multiple ProxyEndpoints in an API proxy can:

  • Make it hard for developers to understand and maintain the API proxy.
  • Obfuscate analytics. By default, analytics data is aggregated at the proxy level. There is no breakdown of metrics by proxy endpoint unless you create custom reports.
  • Make it difficult to troubleshoot problems with API proxies.

When you are implementing a new API proxy or redesigning an existing API proxy, use the following best practices:

  1. Implement one API proxy with a single ProxyEndpoint.
  2. If there are multiple APIs that share common target server and/or require the same logic pre or postinvocation of the target server, consider using shared flows to implement such logic in different API proxies.
  3. If there are multiple APIs that share a common starting base path, but differ in the suffix, use conditional flows in a single ProxyEndpoint.
  4. If there exists an API proxy with multiple ProxyEndpoints and if there are no issues with it, then there is no need to take any action.

Using one ProxyEndpoint per API proxy leads to:

  1. Simpler, easier to maintain proxies
  2. Better information in Analytics, such as proxy performance and target response time, will be reported separately instead of rolled up for all ProxyEndpoints
  3. Faster troubleshooting and issue resolution
NOTE: Apigee X and Hybrid are limited to hosting up to 5 Proxy Endpoints per API Proxy, while Apigee Edge has no such limit.

Solution

The API Proxy Endpoint Unifier is a tool to help you align with the best practice recommendations which are mentioned above. The objective of this tool is to take a proxy bundle and intelligently convert its proxy endpoints into logically grouped conditional flows. This is achieved by analysing the proxy bundle and identifying which proxy endpoints can be grouped together logically. The tool then generates a new proxy bundle with the grouped proxy endpoints converted into conditional flows. This ensures that the new proxy bundle stays within the Proxy Endpoint limit and keeps it aligned to the best practices.

Disclaimer

This is not an officially supported Google product.

Clone Repo

Clone the repo and move to the tool directory 

git clone https://github.com/apigee/devrel.git
cd devrel/tools/proxy-endpoint-unifier/

Prerequisites

  • python3
  • Please install the required Python dependencies
python3 -m pip install -r requirements.txt
 
  • Please fill in input.properties
[common]
input_apis=apis                      # Folder Containing exported & unzipped Proxy Bundles
processed_apis=transformed           # Folder to export transformed Proxies to 
proxy_bundle_directory=zip_bundles   # Folder to export transformed Proxies Bundles (zip)
proxy_endpoint_count=4               # Number of Proxy Endpoints to retain should be between 1 to 5
debug=false                          # Flag to export debug logs

[validate]
enabled=true                         # Flag to enable proxy validation
gcp_project_id=xxx-xxx-xxx           # Apigee Project for proxy validation
  • If enabling validation, please run the following command to authenticate against Apigee APIs:
export APIGEE_ACCESS_TOKEN=$(gcloud auth print-access-token)

Usage

Run the script as below

python3 main.py

Limitations

  • This tool does not currently handle the resources within API proxies.
Contributors
Version history
Last update:
‎08-17-2023 04:51 AM
Updated by: