Help Center/ Koo Command Line Interface/ FAQs/ Cloud Service APIs/ How Do I Specify a Cloud Service API and Its Version?
Updated on 2023-02-27 GMT+08:00

How Do I Specify a Cloud Service API and Its Version?

Background

During a cloud service API call, KooCLI verifies the validity of your input parameters. If the service has multiple versions, some or all APIs of the service also have multiple versions. The parameters and application scenarios of an API may vary with versions. The CLI needs to obtain the version information of an API that belongs to a service with multiple versions.

Querying and Specifying the Version of a Cloud Service API

  • Querying version information

    Run hcloud <service> --help to view the operation list of the cloud service. If an operation appears multiple times in the Available Operations list and different version numbers are concatenated with a slash (/), specify a version when calling the API. For details, see Specifying a version. For other operations that appear only once in the operation list, their version numbers do not need to be concatenated. KooCLI calls their only version.

  • Specifying a version
    • Manually specifying a version

      When calling an API that belongs to a service with multiple versions, use a slash (/) to manually add the version number after operation of the original API. For example, if operation is showLogs in the original command and showLogs/v1 and showLogs/v2 exist in the Available Operations list, you can set operation to showLogs/v1 or showLogs/v2.

    • Using the default version

      When calling an API that belongs to a service with multiple versions, if you do not specify a version in the command, KooCLI obtains all available versions of the API and sorts them in alphabetical order. The last version of the API in the list is called by default. (Generally, this version is the latest version of the API.)

Extended Question and Solution

  • Question

    When you call an API that belongs to a service with multiple versions by using the API's default version, if the metadata files cached locally are modified, KooCLI may not be able to correctly parse the API version based on the cache files. In this case, the following error message is displayed:

    [USE_ERROR] The API has multiple versions. Specify one.

  • Solution

    Run hcloud meta clear to clear the cache files, and try again.