Try WSO2 Cloud for Free
Sign in

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

Running the CLI tool

Table of Content Zone
locationtop
  1. Go to https://wso2.com/api-management/previous-releases/ and select the WSO2 API Manager version as Version 2.6.0.
  2. Go to the Tooling section and click on a required operating system (i.e., MacOS, Linux, Windows) under CLI to download . This downloads the appropriate CLI tool.
  3. Once the download completes, extract the tool to a preferred location and cd into it.

  4. Navigate to the working directory where the executable of the CLI tool resides.

  5. Execute the following command to start the CLI tool.

    Code Block
    ./apimcli
  6. 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 the environment

You can add an environment by running the following CLI command.

Note

In API cloud importing and exporting of APIs and Applications take place between tenants as opposed to environments. Therefore, you need to only add one environment in the CLI tool. This environment will be used between tenants to call the endpoints of the API cloud.

Code Block
apimcli add-env
  1. Make sure 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 : As we only need one environment when working with the API cloud, name the environment as follows: wso2apicloud
        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 wso2apicloud \
                          --registration https://gateway.api.cloud.wso2.com/client-registration/register \
                          --apim https://gateway.api.cloud.wso2.com/pulisher \
                          --token https://gateway.api.cloud.wso2.com/token \
                          --import-export https://gateway.api.cloud.wso2.com/api-import-export \
                          --admin https://gateway.api.cloud.wso2.com/api/am/admin/ \
                          --api_list https://gateway.api.cloud.wso2.com/api/am/publisher/apis \
                          --app_list https://gateway.api.cloud.wso2.com/api/am/store/applications
    Localtab
    idMac OS
    titleMac OS
    Code Block
    titleExample 1
    apimcli add-env -n wso2apicloud --registration https://gateway.api.cloud.wso2.com/client-registration/register --apim https://gateway.api.cloud.wso2.com/pulisher --token https://gateway.api.cloud.wso2.com/token --import-export https://gateway.api.cloud.wso2.com/api-import-export --admin https://gateway.api.cloud.wso2.com/api/am/admin/ --api_list https://gateway.api.cloud.wso2.com/api/am/publisher/apis --app_list https://gateway.api.cloud.wso2.com/api/am/store/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 'wso2apicloud'
    Info
    titleTroubleshooting

    Why do I get the following error?

    Code Block
    [ERROR]: parsing /Users/<user-profile-name>/.wso2apimcli/env_keys_all.yaml
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1343b82]

    You get the above error if you have worked with two CLI tools. Carry out the following steps if you get the above error:

    1. View the env_keys_all.yaml file and check if there are any NULL values.

    2. Delete the env_keys_all.yaml file.

    3. Execute the command that you initially executed.
      For example if you got this error when trying to add an environment, then follow the steps mentioned under Adding an environment to reattempt to add the environment.

List environments

  1. Make sure 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              
    +--------------+---------------------------------------------+-----------------------------------------------------------------+-----------------------------------------+
    | wso2apicloud | https://gateway.api.cloud.wso2.com/pulisher | https://gateway.api.cloud.wso2.com/client-registration/register | https://gateway.api.cloud.wso2.com/token 
    +--------------+---------------------------------------------+-----------------------------------------------------------------+-----------------------------------------+

...