Using KooCLI
Huawei Cloud Koo Command Line Interface (KooCLI), previously named "HCloud CLI", is designed to manage Huawei Cloud service APIs released on API Explorer. With KooCLI, you can call the open APIs of FunctionGraph in API Explorer to manage and use your FunctionGraph resources. For detailed information about KooCLI, see What Is KooCLI?
Installing KooCLI
Before using KooCLI, you need to install it. KooCLI supports three operating systems: Windows, Linux, and macOS. Install the corresponding version of the tool based on the operating system of your host.
Initializing KooCLI Configuration
When KooCLI is used to call APIs, the caller's identity information needs to be obtained for authentication. By configuring KooCLI initialization, you can store permanent AK/SK information in the configuration file. In this way, you do not need to frequently enter this information when calling APIs.
Skip this step if you intend to pass authentication parameters directly in commands. For details, see Using KooCLI in Non-configuration Mode.
The following uses Windows as an example to describe how to initialize KooCLI configuration. The operations on Linux and macOS are similar. Before the initialization, obtain the AK/SK information. For details, see Access Keys.
- Open the CLI.
- Run the following commands to initialize the configuration:
hcloud configure init
- Enter the parameter values as prompted.
Access Key ID [required]: // Mandatory. Enter the AK. Secret Access Key [required]: // Mandatory. Enter the SK. The system will anonymize the input. Secret Access Key (again): // Mandatory. Enter the SK again. The system will anonymize the input. Region: // Optional. Enter a region.
The message "Initialization successful" is then displayed.
Generating and Executing a CLI Command
KooCLI supports two methods for generating commands:
- Use API Explorer to quickly generate and obtain the CLI command for calling an API. This method is recommended as it is more convenient.
- Use CLI commands to query the operation commands and related parameters of APIs, and then manually combine the CLI commands to call the APIs. For details, see Step 4: View and Run Cloud Service Operation Commands.
The following uses the FunctionGraph API for querying tenant quotas as an example to describe how to generate a CLI command in API Explorer and then run the CLI command to call the API.
- On the API Explorer page of FunctionGraph, select the API for which you want to generate a CLI command.
- On the parameter configuration page in the middle, set the parameters required for calling the API.
- In the pane on the right, click the CLI Example tab and view the generated CLI command. The following is an example of the CLI command for calling the API for querying tenant quotas:
hcloud FunctionGraph ListQuotas --cli-region="af-south-1" --Content-Type="application/json"
- Copy the generated CLI command and paste it into the CLI for execution.
The following is an example of the CLI command output for calling the API for querying tenant quotas:
{ "quotas" : { "resources" : [ { "quota" : 60, "used" : 3, "type" : "fgs_func_scale_down_timeout" }, { "quota" : 100, "used" : 22, "type" : "fgs_func_occurs" }, { "quota" : 100, "used" : 22, "type" : "fgs_func_pat_idle_time" }, { "quota" : 100, "used" : 22, "type" : "fgs_func_num" }, { "quota" : 10240, "used" : 22, "type" : "fgs_func_code_size", "unit" : "MB" }, { "quota" : 512, "used" : 22, "type" : "fgs_workflow_num" } ] } }
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot