Help Center/ Koo Command Line Interface/ User Guide/ Options/ Generating API Input Parameter Skeleton in JSON Format
Updated on 2024-06-17 GMT+08:00

Generating API Input Parameter Skeleton in JSON Format

The skeleton option is used to generate an API input parameter skeleton in JSON format. Adding --skeleton to a command generates an API input parameter file in JSON format in the current directory. Specify parameter values, and pass them using --cli-jsonInput=${JSON file name} to call the API.

hcloud RDS CreateConfiguration --cli-region="ap-southeast-1" --skeleton
Skeleton generated in JSON format. Path: C:\cli\RDS_CreateConfiguration_cn-20231108093800.json

The JSON file contains the following content:

{
	"header": {
		"X-Language": ""
	},
	"path": {
		"project_id": ""
	},
	"body": {
		"datastore": {
			"type": "",
			"version": ""
		},
		"description": "",
		"name": "",
		"values": {
			"": ""
		}
	}
}
--------------------------------- After the skeleton is filled in, delete this line and the following parameter description: ---------------------------------
{
	"header": {
		"X-Language": {
			"Required": false,
			"ParamType": "string",
			"Usage": "Language",
			"EnumValue": [
				"zh-cn",
				"en-us"
			]
		}
	},
	"path": {
		"project_id": {
			"Required": true,
			"ParamType": "string",
			"Usage": "Project ID"
		}
	},
	"body": {
		"datastore": {
			"type": {
				"Required": true,
				"ParamType": "string",
				"Usage": "DB engine. Its value can be any of the following and is case-insensitive:\n- MySQL\n- PostgreSQL\n- SQLServer\n- MariaDB",
				"EnumValue": [
					"MySQL",
					"PostgreSQL",
					"SQLServer",
					"MariaDB"
				]
			},
			"version": {
				"Required": true,
				"ParamType": "string",
				"Usage": "DB engine version\n \n - MySQL: 5.6 and 5.7 are supported. Example value: 5.7. MySQL 8.0 is available only for users with the required permission. You can contact Huawei Cloud customer service to apply for the permission.\n \n - PostgreSQL: 9.5, 9.6, 10, and 11 are supported. Example value: 9.6.\n \n - Microsoft SQL Server: 2017 Enterprise Edition, 2017 Standard Edition, 2017 Web Edition, 2014 Standard Edition, 2014 Enterprise Edition, 2016 Standard Edition, 2016 Enterprise Edition, 2012 Enterprise Edition, 2012 Standard Edition, 2012 Web Edition, 2008 R2 Enterprise Edition, 2008 R2 Web Edition, 2014 Web Edition, and 2016 Web Edition are supported. Example value: 2014_SE.\n For example, enter 2017_SE for 2017 Standard Edition, 2017_EE for 2017 Enterprise Edition, and 2017_WEB for 2017 Web Edition."
			}
		},
		"description": {
			"Required": false,
			"ParamType": "string",
			"Usage": "Parameter template description. It contains a maximum of 256 characters except the following special characters: >!<\"&'= Its value is left blank by default."
		},
		"name": {
			"Required": true,
			"ParamType": "string",
			"Usage": "Parameter template name. It contains a maximum of 64 characters and can contain only uppercase letters, lowercase letters, digits, hyphens (-), underscores (_), and periods (.)."
		},
		"values": {
			"": {
				"Required": false,
				"ParamType": "string",
				"Usage": "Parameter values defined by users based on the default parameter templates. If this parameter is not specified, no parameter value is to be changed.\n \n - key: parameter name. For example, in \"max_connections\":\"10\", the key is max_connections. If key is left blank, the parameter value is not to be changed. If key is not empty, the parameter value cannot be empty, either.\n - value: parameter value. For example, in \"max_connections\":\"10\", the value is 10."
			}
		}
	}
}
  • The generated JSON file consists of two parts, divided by a line. The upper part is the API parameter skeleton required by cli-jsonInput, and the lower part is the parameter description and value requirements. Specify the parameter values in the skeleton in the upper part by referring to the parameter description.
  • After filling in the JSON file, delete the dividing line and the content in the lower part. Parameters with no value specified must be deleted.

For example, after you specify parameters in the preceding file, the file content is as follows:

{
	"path": {
		"project_id": "0dd8cb****************19b5a84546"
	},
	"body": {
		"datastore": {
			"type": "MySQL",
			"version": "5.7"
		},
		"description": "test create configuration",
		"name": "test-001",
		"values": {
			"max_connections": "10"
		}
	}
}

Put the file in the following command using --cli-jsonInput and run this command to call the API:

hcloud RDS CreateConfiguration --cli-region="ap-southeast-1" --cli-jsonInput="RDS_CreateConfiguration_cn-20231108093800.json" --dryrun
API parameters transferred for the path, query, body, formData, header, and cookies in cli-jsonInput take precedence over command transfers.
-------- The execution is eliminated in dry-run mode. Current request: --------
POST https://rds.ap-southeast-1.myhuaweicloud.com/v3/0dd8cb****************19b5a84546/configurations
Content-Type: application/json
X-Project-Id: 0dd8cb****************19b5a84546
X-Sdk-Date: 20220621T103331Z
Authorization: ****

{
  "datastore": {
    "type": "MySQL",
    "version": "5.7"
  },
  "description": "test create configuration",
  "name": "test-001",
  "values": {
    "max_connections": "10"
  }
}