com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Migrating the APIs to a Different Environment

When you migrate the API Manager from one server environment to another, you must move all created APIs, so that you do not have to create them again in the new environment. The sections below explain how to do this: 

Deploying the API import/export tool

  1. Download WSO2 API Manager 1.9.0 from http://wso2.com/products/api-manager/.

  2. Download the latest WSO2 API import/export tool from here.

    Note that the import/export tool attached is specific to this version of API Manager.

  3. Copy the downloaded api-import-export-<version>.war file to <APIM_HOME>/repository/deployment/server/webapps.

  4. Start the API Manager. If the server is already started, the file will be automatically deployed as hot deployment is enabled.

Exporting an API

After successfully deploying the import/export tool, you can export an existing API as a .zip archive. Issue the following cURL command using the command line:

 

curl -H "Authorization:Basic <base64-encoded-credentials-separated-by-a-colon>" 
-X GET "https://<APIM_HOST:Port>/api-import-export-<version>/export-api?name=<API-name>&version=<API-version>
&provider=<API-provider>" -k > <exportedApiName>.zip

Here's an example:

curl -H "Authorization:Basic AbCdEfG" -X GET 
"https://10.100.7.40:9443/api-import-export-<version>/export-api?name=WeatherAPI&version=1.0.0&provider=admin" 
-k > myExportedAPI.zip

Importing an API

You can use the archive created in the previous section to import APIs to an API Manager instance.

  1. Make sure the API Manager is started and the import/export tool is deployed. 
  2. Run the following cURL command:

    curl -H "Authorization:Basic <base64-encoded-username-and-password-separated-by-a-colon>" 
    -F file=@"full/path/to/the/zip/file" -k -X POST "https://<APIManagerHost:Port>/api-import-export-<version>/import-api"

    Here's an example:

    curl -H "Authorization:Basic AbCdEfG" -F file=@"/Desktop/MyAPIFolder/myExportedAPI.zip" -k -X POST "https://10.100.7.40:9443/api-import-export-<version>/import-api"

    You must add a parameter named preserveProvider to the cURL command and set its value to false if the API is impo rted to a different domain than its exported one. This parameter sets the provider of the imported API to the user who is issuing the cURL command. Here's an example:

    curl -H "Authorization:Basic AbCdEfG" -F file=@"/Desktop/MyAPIFolder/myExportedAPI.zip" -k -X POST "https://10.100.7.40:9443/api-import-export-<version>/import-api?preserveProvider=false"

Understanding the API import/export tool

The API import/export tool uses a RESTful API, protected by basic authentication. Only users with admin privileges are allowed to access it in the initial phase. 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 export functionality

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/FileDescription

Meta Information

  • api.json: contains all the basic information required for an API to be imported in another environment

  • swagger.json: contains the API swagger definition

Documents

  • docs.json: contains the summary of all the documents available for the API

  • Add the uploaded files for API documentation also

ImageThumbnail image of the API
WSDLWSDL file of the API
SequencesThe sequences available for the API

 

Given below is the RESTful API for export functionality. It is secured using Basic Authentication.

 

ParameterDescription

URI

https://<host name>:9443/api-import-export-<version>/export-api

Query parameters

name=<api_name>&version=<api_version>&provider=<provider_name>

HTTP method

GET

Examples

curl -H "Authorization:Basic YWRtaW46YWRtaW4=" -X GET "https://10.100.7.39:9443/api-import-export-<version>/export-api?
              name=test&version=1.0.0&provider=admin"

It gives a data stream as the output. To download it as a zipped archive, use the following command:

curl -H "Authorization:Basic YWRtaW46YWRtaW4=" -X GET "https://10.100.7.39:9443/api-import-export-<version>/export-api?name=test
              &version=1.0.0&provider=admin"  -k > exportedApi.zip

To verify the output status of the API call:

curl -v -H "Authorization:Basic YWRtaW46YWRtaW4=" -X GET "https://10.100.7.39:9443/api-import-export-<version>/export-api?name=test&version=1.0.0&provider=admin"  -k > exportedApi.zip

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 will not added to the new environment. However, if an exported sequence is not available in the imported environment, it will be added.
  • The importer can decide whether to keep the original provider’s name or replace it. Set the preserveProvider parameter to true to keep it. If you set it to false, the original provider will be replaced by the user who is sending the cURL command. 
  • 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 preserveProvider parameter must always be false.
Given below is the RESTful API for import functionality.
ParameterDescription

URI

https://10.100.7.40:9443/api-import-export-<version>/import-api

Query parameters

preserveProvider=<true|false>

HTTP method

POST

Example

Imports the API with the original provider preserved: curl -H "Authorization:Basic YWRtaW46YWRtaW4=" -F file=@"full/path/to/the/zip/file" -k -X POST "https://10.100.7.40:9443/api-import-export-<version>/import-api"

Imports the API with the provider set to the current user: curl -H "Authorization:Basic YWRtaW46YWRtaW4=" -F file=@"full/path/to/the/zip/file" -k -X POST "https://10.100.7.40:9443/api-import-export-<version>/import-api?preserveProvider=false"


com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.