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.
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.
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.
For any further questions, feel free to contact us through the chatbot.
Chatbot