创建自定义命令。
详细操作说明请参考帮助文档:创建命令
该接口用于创建自定义命令。
POST
https://assistant.jdcloud-api.com/v1/regions/{regionId}/createCommand
名称 | 类型 | 是否必需 | 默认值 | 描述 |
---|---|---|---|---|
regionId | String | True | 地域ID。 |
名称 | 类型 | 是否必需 | 示例值 | 描述 |
---|---|---|---|---|
commandName | String | True | 云助手测试 | 命令名称。长度为1~128个字符,只允许中文、数字、大小写字母、英文下划线(_)、连字符(-)及点(.)。 |
commandType | String | False | shell | 命令类型,可选值:shell 和powershell ,默认shell |
commandContent | String | True | {{key}} | 以base64编码的命令内容,编码后长度须小于16KB 。命令内容支持使用自定义参数形式,具体通过指定参数EnableParameter=true 启用自定义参数功能:自定义参数用{{}}包含的方式定义,在{{}}内参数名前后的空格以及换行符会被忽略。 自定义参数个数不能超过20个。 单个参数长度不超过64字节 |
timeout | Integer | False | 400 | 超时时间,超时后云助手将强制终止命令进程,命令将执行失败。取值范围:[10, 86400]。默认60s。 |
username | String | False | root | 用户名,执行该命令时的用户身份。对于Linux实例,默认为root ; 对于 Windows 实例,默认为administrator 。长度不超过256个字符。 |
workdir | String | False | /root | 命令执行路径。对于Linux实例,默认为/root ,对于 Windows 实例,默认为C:\Windows\System32 。长度不超过256个字符。 |
commandDescription | String | False | 命令描述。长度不超过256个字符。 | |
enableParameter | Boolean | False | False | 命令是否启用参数,true :启用,false :不启用。默认为False 。 |
名称 | 类型 | 描述 |
---|---|---|
result | Result | 响应结果。 |
requestId | String | 请求ID。 |
名称 | 类型 | 描述 |
---|---|---|
commandId | String | 命令Id。 |
POST
/v1/regions/cn-north-1/createCommand
{
"commandName": "云助手测试",
"commandContent": "aG9zdG5hbWU="
}
{
"requestId": "0d1531eb5016b64d801a9e24bac779e8",
"result": {
"commandId": "c-5016b64d801a9e24"
}
}
HTTP状态码 | 错误码 | 描述 | 错误解析 |
---|---|---|---|
200 | OK | ||
400 | OUT_OF_RANGE | The parameter 'CommandName' exceeds the upper range 128 | 命令名称长度超过128个字符数的上限 |
400 | INVALID_ARGUMENT | The parameter 'CommandName' field is missing | 命令名称不可为空 |
400 | INVALID_ARGUMENT | The parameter 'CommandType' should be one of: shell powershell | 命令类型需为shell 或powershell |
400 | INVALID_ARGUMENT | The parameter 'CommandName' field is missing | 命令名称不可为空。 |
400 | INVALID_ARGUMENT | The parameter 'CommandContent' should be encoded in base64 | 命令内容需要经过base64编码。 |
400 | OUT_OF_RANGE | The parameter 'timeout' exceeds the upper range 86400 | 超时时间时长超过86400上限 |
400 | OUT_OF_RANGE | The parameter 'timeout' exceeds the lower range 10 | 超时时间时长超过10下限 |
400 | OUT_OF_RANGE | The parameter 'uername' exceeds the upper range 256 | 用户名超过256个字符数的上限 |
400 | OUT_OF_RANGE | The parameter 'workdir' exceeds the upper range 256 | 命令执行路径超过256个字符数的上限 |
400 | OUT_OF_RANGE | The parameter 'commandDescription' exceeds the upper range 256 | 命令描述超过256个字符数的上限 |
429 | QUOTA_EXCEEDED | Command quota limit exceeded | 命令配额不足 |
500 | INTERNAL | Internal server error | 系统内部错误,请稍后重试。如果多次尝试失败,请提交工单。 |
500 | UNKNOWN | Unknown server error | 服务暂时不可用,请稍后重试。如果多次尝试失败,请提交工单 |
我们的产品专家为您找到最合适的产品/解决⽅案
1v1线上咨询获取售前专业咨询
专业产品顾问,随时随地沟通