Try WSO2 Cloud for Free
Sign in

All docs This doc
||
Skip to end of metadata
Go to start of metadata

Any user with admin privileges can migrate the APIs from WSO2 API Cloud to another environment without having to recreate the APIs. 

In this tutorial, you create a API in WSO2 API cloud, migrate an API from WSO2 API Cloud, set up an instance of WSO2 API Manager (WSO2 APIM) in your local environment, and then migrate that API from WSO2 API Cloud to the local setup.

Let's get started!

  1. Log in to WSO2 Cloud by going to https://cloud.wso2.com, clicking the  Sign In link, selecting WSO2 API Cloud, and entering your credentials.
  2. Create and publish an API with the following details. If you do not know how to create and publish an API, see Create and Publish an API.

    Tab NameParametersValues
    Design TabNamePhoneTest

    Context

    /phonetest


    Version1.0.0

    VisibilityPublic

    API Definition

    Click Next without entering anything and the system will prompt you to add a wildcard resource (/*). Click Yes.

    Implement Tab -> Managed APIProduction Endpointhttp://ws.cdyne.com/phoneverify/phoneverify.asmx
    Manage TabTier Availability

    Gold

    You cannot import a tier to an environment if it is not supported there, although it is supported in the source environment.
    For example, if you may have a tier (e.g., Gold-Updated tier) that is supported in WSO2 API Cloud, but not in your local WSO2 API Manager setup. Therefore, in the latter mentioned scenario you cannot import the tier from WSO2 API Cloud to your local machine. 

  3. You need to construct and then copy your username which would be <email_address>@<tenant_domain>.
  4. Use command line (if you are on mac/linux  environment) or an online Base64 encoder such as  https://www.base64encode.org/, to create a Base64-encoded string of your WSO2 API Cloud's  credentials, using the following format.
    <username>:<password> 

    If you are on mac/linux environment you can use following command.
    echo -n <username>:<password> | base64

    Example: echo -n admin@gmail.com@mytenant:mypassword | base64

  5. Install cURL in your local machine if it is not already installed.

  6. Execute the following command to export your API from your tenant account in the WSO2 API Cloud as a ZIP file. 

    curl -H "Authorization:Basic <base64-encoded-credentials-from_previous_step>"
    -X GET "https://gateway.api.cloud.wso2.com/api-import-export/export-api?name=<API_Name>&version=<API-Version>
    &provider=<API_provider>" -k > <ZIP_File_Name>.zip
    
     
    According to our example, the command is:
    curl -H "Authorization:Basic <base64-encoded-credentials-from_previous_step>=" -X GET "https://gateway.api.cloud.wso2.com/api-import-export/export-api?name=PhoneTest&version=1.0.0&provider=admin@gmail.com@mytenant" -k > myExportedAPI.zip

    You have exported an API to a ZIP file. Let's import that to your local WSO2 API Manager environment.

  7. Setup an instance of WSO2 API Manager in your local environment.

    1. Go to http://wso2.com/products/api-manager/ and download WSO2 API Manager 2.0.0 by clicking the DOWNLOAD button in the upper right-hand corner.

      To migrate APIs, your local environment must have the same API Manager version that the API Cloud runs on. 

    2. Extract the ZIP file to a suitable location in your machine. Let's call this location <APIM_HOME>.
    3. To export the API that you will later create in the WSO2 API Cloud, you need the API Import/Export tool provided by WSO2. Download this WAR file and copy it to the  <APIM_HOME>/repository/deployment/server/webapps  folder. It deploys the API Import/Export tool in your API Manager server.
    4. Start the WSO2 API Manager by executing one of the following commands:
      • On Windows:  <APIM_HOME>\bin\wso2server.bat --run
      • On Linux/Solaris/Mac OS:  sh <APIM_HOME>/bin/wso2server.sh

  8. Using an online Base64 encoder such as https://www.base64encode.org/, create a Base64-encoded string of your credentials of the WSO2 API Manager in the following format. 
    <username>:<password>
    In this example, it is admin:admin 

    Only users with admin privileges can migrate APIs between environments using the API Import/Export tool.

  9. Navigate to a suitable location using the command-line or terminal and execute the following cURL command to import your API to your WSO2 API Manager local environment. 

    curl -H "Authorization:Basic <base64-encoded-credentials-from_previous_step>" -F file=@"<full_path_of_zip_file>" -k -X POST "https://<APIM_HOST:Port>/api-import-export-2.1.0-v2/import-api?preserveProvider=false"
     
    For example:
    curl -H "Authorization:Basic <base64-encoded-credentials-from_previous_step>" -F file=@"/Users/Admin15/Downloads/myExportedAPI.zip" -k -X POST "https://localhost:9443/api-import-export-2.1.0-v2/import-api?preserveProvider=false"

    Tip: Make sure the name and context of the API that you are importing (e.g., PhoneTest and /phonetest) do not duplicate that of an existing API in the local WSO2 API Manager environment.

  10. Log in to your local setup of WSO2 API manager and note that the API that you imported now appears in the API Publisher. 

    Note that the API in the local API Manager instance is in the CREATED state although it was in the PUBLISHED state in the WSO2 API Cloud. This is done to enable you to modify the API before publishing it.

In this tutorial, you created an API via WSO2 API Cloud and exported that to your WSO2 API Manager environment without having to recreate the API from scratch.

  • No labels