Using KooCLI
Huawei Cloud Koo Command Line Interface (KooCLI), previously called "HCloud CLI", is designed to manage Huawei Cloud service APIs released on API Explorer. You can use this tool to call the APIs of VPN in API Explorer to manage and use your VPN resources. For details about KooCLI, see What Is KooCLI?.
Installing KooCLI
Before you begin, you need to install KooCLI. KooCLI is compatible with Windows, Linux, and macOS. Install the tool of the corresponding version based on the OS used by your machine.
Initializing KooCLI
When KooCLI is used to call APIs, you need to obtain the caller's identity information for authentication. If you initialize KooCLI, your permanent AK/SK is stored in the configuration file, so you do not need to enter the credentials each time you call an API.
Skip this step if you prefer passing authentication parameters directly in commands rather than using a configuration file. For details, see Using KooCLI in Non-configuration Mode.
The following uses Windows as an example to describe how to initialize KooCLI. The steps on Linux and macOS are similar. Before the initialization, obtain the AK and SK. For details, see Creating Access Keys.
- Open the CLI.
- Run the following command 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 CLI Commands
KooCLI supports two command generation methods:
- 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 API operations and related parameters, and then manually assemble the CLI commands to call APIs. For details, see Viewing and Running Cloud Service Operation Commands.
The following uses the VPN API for creating a VPN gateway as an example to describe how to generate a CLI command in API Explorer and execute it to call the API.
- In API Explorer, select the Virtual Private Network service, and choose from the API list on the left.
- In the parameter configuration area in the middle, set the parameters required to call the API.
- In the pane on the right, click the CLI Example tab and view the generated CLI command.
The following is a CLI command example for calling the API to create a VPN gateway.
hcloud VPN CreateVgw --cli-region="cn-north-4" --name="testuser" --enabled=true
- Copy the generated CLI command and paste it into the CLI for execution.
The following is an example of the CLI command output for creating a VPN gateway.
{ "vpn_gateway": { "id": "80d07cb6-7198-493e-8b9f-xxxxxxxxxxxx", "name": "vpngw-test", "attachment_type": "vpc", "ip_version": "ipv4", "vpc_id": "d061c021-b5ef-4b3e-8a53-xxxxxxxxxxxx", "local_subnets": [ "123.123.123.123/32" ], "local_subnets_v6": [], "connect_subnet": "4b1b84ac-693d-408e-9b67-xxxxxxxxxxxx", "network_type": "public", "access_vpc_id": "d061c021-b5ef-4b3e-8a53-xxxxxxxxxxx", "access_subnet_id": "4b1b84ac-693d-408e-9b67-xxxxxxxxxx", "bgp_asn": 64512, "flavor": "Professional1", "connection_number": 200, "used_connection_number": 0, "used_connection_group": 0, "enterprise_project_id": "0", "ha_mode": "active-active", "tags": [] }, "request_id": "798697adf179fb8e79c5cadda027xxxx" }
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