Migrating the APIs to a Different Environment
If you maintain multiple environments of the same API Manager version and you want to move all created APIs from one environment to another (such as moving from a development environment to a QA environment or from a QA environment to a production environment), you can migrate the APIs to the new environment by following the steps below:
Understanding the API import/export tool
The API import/export tool uses a RESTful API, protected by basic authentication.
Only the following types of users are allowed to access the API import/export tool.
A user with the admin role.
A user with a role that has the API-M Admin, Login, and API Create permissions.
To allow access to the import/export feature only for a particular tenant, log in to WSO2 API Manager's Management Console and add the downloaded archive file as a web application to the server.
The 'admin' role is the default role which is specified in the Realm configuration in <API-M_HOME>/repository/conf/user-mgt.xml. It will be changed if you have changed the value of the <AdminRole> parameter as shown below.
<Realm>
<Configuration>
<AddAdmin>true</AddAdmin>
<AdminRole>admin</AdminRole>
.....
</Configuration>
</Realm>The export functionality
The API export functionality retrieves the information required for the requested API from the registry and databases and generates a ZIP file, which the exporter can download. This exported ZIP file has the following structure:
The structure of the ZIP file is explained below:
Sub directory/File | Description |
|---|---|
Meta Information |
|
Documents |
|
Image | Thumbnail image of the API |
WSDL | WSDL file of the API |
Sequences | The sequences available for the API |
Given below is the RESTful API for the export functionality. It is secured using Basic Authentication.
Parameter | Description |
|---|---|
URI |
|
Query parameters |
|
HTTP method | GET |
Examples |
It gives a data stream as the output. To download it as a zipped archive, use the following command:
To verify the output status of the API call:
|
The import functionality
The import functionality uploads the exported ZIP file of the API to the target environment. It creates a new API with all the registry and database resources exported from the source environment. Note the following:
The lifecycle status of an imported API will always be CREATED even when the original API in the source environment has a different state. This is to enable the importer to modify the API before publishing it.
Tiers and sequences are provider-specific. If an exported tier is not already available in the imported environment, that tier is not added to the new environment. However, if an exported sequence is not available in the imported environment, it is added.
The importer can decide whether to keep the original provider’s name or replace it. Set the
preserveProviderparameter to true to keep it. If you set it to false, the original provider is replaced by the user who is sending the cURL command.Once the APIs are imported, in order to make a particular version of an API the default in a group of different versions, select the
Make this the Default Versioncheckbox before publishing the API.Cross-tenant imports are not allowed by preserving the original provider. For example, if an API is exported from tenant A and imported to tenant B, the valve of the
preserveProviderparameter must always be false.
Given below is the RESTful API for the import functionality.
Parameter | Description |
|---|---|
URI |
|
Query parameters |
|
HTTP method | POST |
Example | Imports the API with the original provider preserved: Imports the API with the provider set to the current user: |