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.
-
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.
-
Define a class that implements the
GatewayAgentConfiguration
interface that is responsible for managing the configurations related to the Gateway Instance. -
Define a class that extends the
GatewayDeployer
interface which is responsible for creating external gateway artifacts and deploying the API.
-
-
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
-
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.
-
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¶
-
Stop the API-M server if it is already running.
-
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. -
Start the Server
Step 3 - Configure the Gateway using the Admin Portal¶
-
Sign in to the Admin Portal using the following URL:
https://<hostname>:9443/admin
-
Add a new Gateway.
Step 4 - Create and Deploy API¶
-
Sign in to the Publisher Portal using the following URL:
https://<hostname>:9443/publisher
-
Create a new API. Select the custom gateway from the gateway list.
- Navigate to deployments tab, select the custom gateway environment registered in step 3 and deploy API to custom gateway.