Skip to content

Configure a Custom Gateway Agent

WSO2 API Manager is capable of deploying APIs to external third party API Gateways. Essentially, if the API Provider wants to deploy their APIs a third party gateway that is not supported OOTB by WSO2 API-M, you need to use a custom Gateway Agent. To configure a custom Gateway Agent, you need to do the following:

  • Write a custom Gateway Agent
  • Deploy the custom Gateway Agent in API Manager
  • Register the relevant API Gateway in the Admin Portal by providing the required details.
  • Create and deploy API in the third party API Gateway from API-M Publisher Portal.

Refer to the instructions below to do the configurations.

Step 1 - Create a Gateway Agent bundle

You need to write a custom Gateway Agent bundle as explained below.

Tip

The following is a out-of-the-box agent that you can use as references.

  1. Create a Maven project.

    Let's download the sample project from here.

    However, when manually creating a Maven project, you will need to follow the following steps.

    1. Define a class that implements the GatewayAgentConfiguration interface that is responsible for managing the configurations related to the Gateway Instance.

    2. Define a class that extends the GatewayDeployer interface which is responsible for creating external gateway artifacts and deploying the API.

  2. Implement GatewayAgentConfiguration.

    In the sample project, this has been implemented in the org.wso2.customgw.client.CustomGatewayConfiguration.java class.

    The following are the methods that the GatewayAgentConfiguration interface uses to carry out various related operations.

    Method Description
    getImplementation

    Provides the fully qualified class name of the implementation that corresponds to the GatewayDeployer interface.

    getConnectionConfigurations

    Provides the list of configurations that need to appear in the Admin Portal in order to connect with the Management API of the third party Gateway.

    getGatewayFeatureCatalog

    Provides the list of portal features supported by the third party gateway. Portal UIs will be rendered based on the availability of features. Please refer Universal Gateway Feature Catalog to see how to do this configuration.

    getType

    Type of gateway agent. For example, AWS.

    getDefaultHostnameTemplate

    Provides the base URL of the Gateway instance

  3. Implement GatewayDeployer.

    In the sample project, this has been implemented in the org.wso2.customgw.client.CustomGatewayDeployer.java class.

    The following are the methods that the GatewayDeployer interface uses to carry out various related operations.

    Method Description
    init

    Loads Gateway Agent configurations and create client objects to communicate with the external gateway's management API.

    getType

    Type of gateway agent. For example, AWS.

    deploy

    Deploy API in custom gateway.

    undeploy

    Deploy a previously deployed API in custom gateway.

    validateApi

    Performs initial validations before deploying API.

    getAPIExecutionURL

    Provides the execution URL of the API deployed in custom gateway. Gateway URL displayed on the devportal tryout will be generated using this method's output.

    transformAPI

    Transforms API before deploying to gateway.

  4. Build the project.

    Navigate to the <PROJECT_HOME> directory and execute the following command.

    mvn clean install

    This will create a custom Gateway Agent JAR.

Step 2 - Deploy the bundle in the WSO2 API-M Server

  1. Stop the API-M server if it is already running.

  2. Copy the JAR file that is generated in the custom.gw.manager component target directory, and add it in to the <API-M Server>/repository/components/dropins/ directory.

  3. Start the Server

Step 3 - Configure the Gateway using the Admin Portal

  1. Sign in to the Admin Portal using the following URL: https://<hostname>:9443/admin

  2. Add a new Gateway.

    1. Click Gateways and then click Add Gateway Environment.

      Add new Gateway Environment

Step 4 - Create and Deploy API

  1. Sign in to the Publisher Portal using the following URL: https://<hostname>:9443/publisher

  2. Create a new API. Select the custom gateway from the gateway list.

Create API

  1. Navigate to deployments tab, select the custom gateway environment registered in step 3 and deploy API to custom gateway.

Deploy API