This documentation is for WSO2 API Manager 2.6.0. View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Content Zone
maxLevel4
minLevel4
locationtop
Multiexcerpt
MultiExcerptNameCLI_tool

Running the CLI tool

Table of Content Zone
locationtop
Step 1 - Deploy the API import/export tool
Multiexcerpt
hiddentrue
MultiExcerptNamenote1

NOTE TO WRITERS:

Do not attach the api-import-export-2.6.0.war file to this page . Instead, attach it to (1) and add that link here.

(1) https://docs.wso2.com/display/attachments/API+Manager+2.6.0

Multiexcerpt
MultiExcerptNameDownloadInstructions
  1. Download the latest version of WSO2 API Manager from http://wso2.com/products/api-manager/.

  2. Start WSO2 API Manager.
  3. Download the latest WSO2 API import/export tool (api-import-export-2.6.0-v17.war) from  here.

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

    • Make sure to delete all previous versions of the web app (e.g., api-import-export-2.6.0-v17.war), both the compressed and the extracted files, before copying over the new web app.

    • This version of the API Import and Export web application is compatible with the WSO2 WUM updates from July 8, 2019, onwards. For more information on updating WSO2 API Manager, see Updating WSO2 API Manager.
    • The previous version of the web application which is compatible with WUM updates that are prior to the above-mentioned date can be download from here.
    • Note that API update support in the targeted environment is available only with the api-import-export-2.6.0-v14.war version onwards.
  4. Copy the downloaded api-import-export-2.6.0-v17.war file to the <API-M_HOME>/repository/deployment/server/webapps folder.
    The file is automatically deployed as hot deployment is enabled.


Step 2 - Optionally, set the proxy environment variables for CLI

You can set proxy related HTTP_PROXY, HTTPS_PROXY, http_proxy, and https_proxy standard environment variables, with or without basic authentication as shown below to send the requests initiated from CLI via a proxy server. After one of the following environment variables is set in your environment where CLI is used, all the requests will go through the proxy server specified.

Localtab Group
Localtab
idformat
titleFormat
Localtab Group
Localtab
idFormatwithoutBA
titleWithout Basic Authentication
Code Block
export HTTP_PROXY="http://<host-name>:<port>"
export HTTPS_PROXY="https://<host-name>:<port>"
export http_proxy="http://<host-name>:<port>"
export https_proxy="https://<host-name>:<port>"
Localtab
idFormatwithBA
titleWith Basic Authentication
Code Block
export HTTP_PROXY="http://<username>:<password>@<host-name>:<port>"
export HTTPS_PROXY="https://<username>:<password>@<host-name>:<port>"
export http_proxy="http://<username>:<password>@<host-name>:<port>"
export https_proxy="https://<username>:<password>@<host-name>:<port>"
Localtab
idexample
titleExample
Localtab Group
Localtab
idExamplewithoutBA
titleWithout Basic Authentication
Code Block
export HTTP_PROXY="http://localhost:3128"
export HTTPS_PROXY="https://localhost:3128"
export http_proxy="http://localhost:3128"
export https_proxy="https://localhost:3128"
Localtab
idExamplewithBA
titleWith Basic Authentication
Code Block
export HTTP_PROXY="http://testuser:[email protected]:3128"
export HTTPS_PROXY="https://testuser:[email protected]:3128"
export http_proxy="http://testuser:[email protected]:3128"
export https_proxy="https://testuser:[email protected]:3128"


In conjunction with the above proxy configurations, calls from the CLI to particular hosts that need to bypass proxies can be configured via either the NO_PROXY, or no_proxy environment variables.

Localtab Group
Localtab
idno-proxy-format
titleFormat
Localtab Group
Localtab
idnoproxy-format-template
titleNo Proxy
Code Block
export NO_PROXY="https://<host-name>:<port>"
export no_proxy="https://<host-name>:<port>"
Localtab
activetrue
idno-proxy-example
titleExample
Localtab Group
Localtab
activetrue
idno-proxy-example-value
titleNo Proxy
Code Block
export NO_PROXY="https://localhost:3128"
export no_proxy="https://localhost:3128"




Step 3 - Run the CLI tool
  1. Download API Controller based on your preferred platform (i.e., Mac, Windows, Linux).

  2. Extract the downloaded archive containing the CLI Tool to a preferred location and navigate to it from the terminal (using cd ).
  3. Navigate to the working directory where the executable CLI Tool resides.
  4. Execute the following command to start the CLI tool.

    Code Block
    ./apimcli
  5. Add the location of the extracted folder to your system's $PATH variable to be able to access the executable from anywhere.

    Note

    For further instructions execute the following command.

    Code Block
    apimcli --help
Global flags for CLI tool

The following are some global flags that you can use with the CLI tool.

Code Block
      --verbose
           Enable verbose logs (Provides more information on execution)
      --insecure, -k
          Allow connections to SSL sites without certs
      --help, -h
          Display information and example usage of a command


Adding an environment

You can add environments by either manually editing the $HOME/.wso2apimcli/main_config.yaml file or by running the following CLI command.

Code Block
apimcli add-env

The directory structure for the configuration files ( $HOME/.wso2apimcli ) will be created upon execution of the apimcli command.

  1. Make sure that WSO2 API Manager is started and that the CLI import/export tool is running. 
  2. Run the following CLI command to add an environment.

    Localtab Group
    Localtab
    activetrue
    idFormat-AddEvn
    titleCommand Format
    Localtab Group
    Localtab
    activetrue
    idLinuxFormatAddEnv
    titleLinux Format
    Code Block
    apimcli add-env -n <environment-name> \
                            --registration <registration-endpoint> \
                            --apim <API-Manager-endpoint> \
                            --token <token-endpoint> \
                            --import-export <endpoint-for-environment> \
                            --admin <admin-REST-API-endpoint> \
                            --api_list <API-listing-REST-API-endpoint> \
                            --app_list <application-listing-REST-API-endpoint>
    Localtab
    idMacFormatAddEnv
    titleMac Format
    Code Block
    apimcli add-env -n <environment-name> --registration <registration-endpoint> --apim <API-Manager-endpoint> --token <token-endpoint> --import-export <endpoint-for-environment> --admin <admin-REST-API-endpoint> --api_list <API-listing-REST-API-endpoint> --app_list <application-listing-REST-API-endpoint>

    Flags:

    • Required flags:
      • --name, -n
        There are no short flags for the following flags.
      • --registration

      • --apim

      • --token

      • --import-export

      • --admin

      • --api_list

      • --app_list

    Localtab
    idExample-AddEnv
    titleExample
    Localtab Group
    Localtab
    activetrue
    idLinux1
    titleLinux
    Code Block
    titleExample 1
    apimcli add-env -n production \
                          --registration https://localhost:9443/client-registration/v0.14/register \
                          --apim https://localhost:9443 \
                          --token https://localhost:8243/token \
                          --import-export https://localhost:9443/api-import-export-2.6.0-{version} \
                          --admin https://localhost:9443/api/am/admin/v0.14 \
                          --api_list https://localhost:9443/api/am/publisher/v0.14/apis \
                          --app_list https://localhost:9443/api/am/store/v0.14/applications
    Code Block
    titleExample 2
    apimcli add-env -n dev \
                          --registration https://localhost:9444/client-registration/v0.14/register \
                          --apim https://localhost:9444 \
                          --token https://localhost:8244/token \
                          --import-export https://localhost:9444/api-import-export-2.6.0-{version} \
                          --admin https://localhost:9444/api/am/admin/v0.14 \
                          --api_list https://localhost:9444/api/am/publisher/v0.14/apis \
                          --app_list https://localhost:9444/api/am/store/v0.14/applications
    Localtab
    idMac OS
    titleMac OS
    Code Block
    titleExample 1
    apimcli add-env -n production --registration https://localhost:9443/client-registration/v0.14/register --apim https://localhost:9443 --token https://localhost:8243/token --import-export https://localhost:9443/api-import-export-2.6.0-{version} --admin https://localhost:9443/api/am/admin/v0.14 --api_list https://localhost:9443/api/am/publisher/v0.14/apis --app_list https://localhost:9443/api/am/store/v0.14/applications
    Code Block
    titleExample 2
    ./apimcli add-env -n dev --registration https://localhost:9444/client-registration/v0.14/register --apim https://localhost:9444 --token https://localhost:8244/token --import-export https://localhost:9444/api-import-export-2.6.0-{version} --admin https://localhost:9444/api/am/admin/v0.14 --api_list https://localhost:9444/api/am/publisher/v0.14/apis --app_list https://localhost:9444/api/am/store/v0.14/applications
    Localtab
    idReponseAddEnv
    titleResponse
    Localtab Group
    Localtab
    activetrue
    idResponseFormat
    titleResponse Format
    Code Block
    Successfully added environment '<environment-name>'
    Localtab
    idExampleResponse
    titleExample Response
    Code Block
    Successfully added environment 'production'

Removing an environment

  1. Make sure that WSO2 API Manager is started and that the CLI import/export tool is running. 
  2. Run the following CLI command to remove an environment.

    Localtab Group
    Localtab
    activetrue
    idFormat-RemoveEnv
    titleCommand Format
    Code Block
    apimcli remove-env -n <environment-name>            
    Code Block
    apimcli remove-env --name <environment-name>

    Flags:

    • Required flags
      • --name, -n
    Localtab
    idExample-RemoveEnv
    titleExample
    Code Block
    apimcli remove-env -n production
    Localtab
    idResponse-RemoveEnv
    titleResponse
    Localtab Group
    Localtab
    activetrue
    idResFormatRemove
    titleFormat
    Code Block
    Successfully removed environment '<environment-name>'
    Execute 'apimcli add-env --help' to see how to add a new environment
    Localtab
    idResRemoveEx
    titleExample
    Code Block
    Successfully removed environment 'uat'
    Execute 'apimcli add-env --help' to see how to add a new environment

List environments

  1. Make sure that WSO2 API Manager is started and that the CLI import/export tool is running. 
  2. Run the following CLI command to list the environments.
    There are no flags for the following CLI command.

    Localtab Group
    Localtab
    activetrue
    idCommandENVList
    titleCommand
    Code Block
    apimcli list envs
    Localtab
    idResENVList
    titleResponse
    Code Block
    Environments available in file '/Users/kim/.wso2apimcli/main_config.yaml'
    
    +------------+------------------------+-----------------------------------------------------------+------------------------------+
    |    NAME    |   PUBLISHER ENDPOINT   |                   REGISTRATION ENDPOINT                   |        TOKEN ENDPOINT        |
    +------------+------------------------+-----------------------------------------------------------+------------------------------+
    | dev        | https://localhost:9443 | https://localhost:9443/client-registration/v0.14/register | https://localhost:8243/token |
    | production | https://localhost:9444 | https://localhost:9444/client-registration/v0.14/register | https://localhost:8244/token |
    +------------+------------------------+-----------------------------------------------------------+------------------------------+

...