Koo Command Line Interface
Koo Command Line Interface
- Function Overview
- What's New
- Service Overview
- Getting Started
-
User Guide
- Configuration Management
- HTTP Proxy
- Commonly Used Commands
-
Options
- Option Overview
- Printing Help Information
- Printing Debugging Information
- Generating API Input Parameter Skeleton in JSON Format
- Checking Command
- Specifying Region
- Calling APIs with AK/SK in Non-configuration Mode
- Specifying Account ID
- Specifying Profile
- Specifying Authentication Mode
- Specifying Output Format
- Passing API Parameters with JSON File
- Specifying Request Timeouts
- Specifying Retry Count
- Skipping HTTPS Request Certificate Verification
- Specifying a Domain Name
- Polling Results
- Obtaining CLI Examples on API Explorer
- Using KooCLI in Non-configuration Mode
- Online Experience
- Obtaining Authentication Information
-
FAQs
- Overview
- Authentication
- Profiles
- Metadata Cache
- Logs
- Network Connections
- Cloud Services
- Cloud Service APIs
- Regions
-
Parameters
- What Are KooCLI System Parameters?
- Why Am I Seeing a Message Indicating an Invalid Parameter?
- Why Are Old and New KooCLI System Parameters (Such as region and cli-region) Available? Which Parameters Are Recommended?
- Why Am I Seeing a Message Indicating a Duplicate Parameter?
- How Do I Use cli-jsonInput?
- When Can I Use cli-jsonInput?
- Why Am I Seeing a Message Indicating an Unsupported Parameter Position or Type?
- How Do I Leave a Body Parameter Empty for Cloud Service APIs?
- Interactive Mode and Autocomplete
-
Output Formats
- What Output Formats Are Supported by KooCLI?
- How Do I Define a JMESPath Expression?
- Which KooCLI System Parameters Are Related to Data Output? Which Ones Are Recommended?
- How Do I Use cli-output, cli-query, and cli-output-num?
- How Do I Use cli-output-rows, cli-output-cols, and cli-output-num? What Are the Precautions?
- How Do I Use cli-json-filter? What Are the Precautions?
- Other
- Videos
- General Reference
On this page
Show all
Help Center/
Koo Command Line Interface/
FAQs/
Parameters/
How Do I Leave a Body Parameter Empty for Cloud Service APIs?
Copied.
How Do I Leave a Body Parameter Empty for Cloud Service APIs?
KooCLI allows you to leave the body parameters of cloud service APIs empty at any level.
- A map parameter can be left empty as {} at the corresponding level.
- An array parameter can be left empty as [] at the corresponding level.
Take the BatchStopServers operation of ECS as an example. There are two parameters in the body: os-stop.servers.[N].id and os-stop.type.
hcloud ECS BatchStopServers --cli-region=ap-southeast-1 --help KooCLI(Koo Command Line Interface) Version 3.2.8 Copyright(C) 2020-2023 www.huaweicloud.com Service: ECS Description: This API is used to stop ECSs in a batch based on the specified ECS ID list. A maximum of 1000 ECSs can be stopped at a time. Method: POST Params: --cli-region required string Region where the API can be called. If no region is specified in the command, cli-region in the current profile is used. --os-stop.servers.[N].id required string body ECS Instance ID. Format: --os-stop.servers.1.id=value1 ... --project_id required string path Specifies the project ID. If no project ID is specified in the command, either the parent project ID of the specified region in the authentication information or cli-project-id in the current profile is used. --os-stop.type optional string body Specifies an ECS stop type. The default value is SOFT. [SOFT|HARD] - SOFT: normal ECS stop (default) - HARD: forcible ECS stop
- No parameters left empty
Pass the values of os-stop.servers.[N].id and os-stop.type, and run --dryrun to view the request body:
hcloud ECS BatchStopServers --cli-region=ap-southeast-1 --os-stop.servers.1.id="test" --os-stop.type="SOFT" --dryrun -------- The execution is eliminated in dry-run mode. Current request: -------- POST https://ecs.ap-southeast-1.myhuaweicloud.com/v1/0a152ab****************262d035e8/cloudservers/action Content-Type: application/json;charset=UTF-8 X-Project-Id: 0a152ab****************262d035e8 X-Sdk-Date: 20221116T121721Z Authorization: **** { "os-stop": { "servers": [ { "id": "test" } ], "type": "SOFT" } }
- Array parameter left empty
Pass --os-stop.servers="[]" for the array parameter os-stop.servers of os-stop.servers.[N].id to leave [N] and the remaining part empty. Then run --dryrun to view the request body:
hcloud ECS BatchStopServers --cli-region=ap-southeast-1 --os-stop.servers="[]" --os-stop.type="SOFT" --dryrun -------- The execution is eliminated in dry-run mode. Current request: -------- POST https://ecs.ap-southeast-1.myhuaweicloud.com/v1/0a152ab****************262d035e8/cloudservers/action X-Project-Id: 0a152ab****************262d035e8 X-Sdk-Date: 20221116T122841Z Authorization: **** Content-Type: application/json;charset=UTF-8 { "os-stop": { "servers": [], "type": "SOFT" } }
- Map parameter left empty
Pass --os-stop="{}" for the common parent os-stop of os-stop.servers.[N].id and os-stop.type to leave the map parameter empty. Then run --dryrun to view the request body:
hcloud ECS BatchStopServers --cli-region=ap-southeast-1 --os-stop="{}" --dryrun -------- The execution is eliminated in dry-run mode. Current request: -------- POST https://ecs.ap-southeast-1.myhuaweicloud.com/v1/0a152ab****************262d035e8/cloudservers/action Content-Type: application/json;charset=UTF-8 X-Project-Id: 0a152ab****************262d035e8 X-Sdk-Date: 20221117T013616Z Authorization: **** { "os-stop": {} }
KooCLI checks the parameter values during command execution. It displays an error message if an empty value does not match the parameter type. For example, if the empty value [] for an array parameter is assigned to the map parameter os-stop, the following error message is displayed:
[USE_ERROR] The value of map parameter os-stop is invalid.
Parent topic: Parameters
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot