执行命令
更新时间:2026-07-28
描述
执行已创建的我的命令或公共命令。
OpenAPI Explorer
去调试
您可以在 OpenAPI Explorer 中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer 可以自动生成 SDK 代码示例。
请求结构
Plain Text
1POST /v{version}/ca/actionRun?locale={locale}
2Host: ca.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "action": {
7 "ref": ref
8 },
9 "parameters": parameters,
10 "targetSelectorType": targetSelectorType,
11 "targets": [
12 {
13 "instanceType": instanceType,
14 "instanceId": instanceId,
15 "instanceName": instanceName,
16 "internalIp": internalIp,
17 "externalIp": externalIp,
18 "bandwidth": bandwidth
19 }
20 ],
21 "targetSelector": {
22 "instanceType": instanceType,
23 "tags": [
24 {
25 "tagKey": tagKey,
26 "tagValue": tagValue
27 }
28 ],
29 "importInstances": {
30 "keywordType": keywordType,
31 "instances": [instances]
32 }
33 }
34}
请求头域
除公共头域外,无其它特殊头域。
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| version | String | 是 | URL参数 | API版本号,当前取值为1 |
| locale | String | 否 | Query参数 | 语言,默认 zh-cn |
| action | ActionRef | 是 | RequestBody参数 | 所要执行的命令,仅需填写id |
| parameters | Map<String,String> | 否 | RequestBody参数 | 执行命令时的参数值,仅在命令有参数时需要 |
| targetSelectorType | TargetSelectorType | 否 | RequestBody参数 | 实例选择器类型,仅在执行动作为执行或保存并执行时需要。默认值为INSTANCES_LIST。可选值:INSTANCES_LIST(实例列表),ALL_INSTANCES(全部实例),TAG_INSTANCES(实例标签选择),INSTANCES_IMPORT(实例列表导入) |
| targets | List<Target> | 否 | RequestBody参数 | 实例ID列表,仅在targetSelectorType为INSTANCES_LIST时需要 |
| targetSelector | TargetSelector | 否 | RequestBody参数 | 实例选择器 |
返回头域
除公共头域,无其它特殊头域。
返回参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| requestId | String | 请求id |
| code | String | 响应状态,成功为success |
| message | String | 错误信息 |
| success | Boolean | 请求是否处理成功 |
| result | Object | 命令执行结果 |
请求示例
Plain Text
1POST /v1/ca/actionRun?locale={locale}
2Host: ca.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "action" : {
7 "ref" : "c-WgEtWtD3sV******"
8 },
9 "parameters" : {
10 "param1" : "pwd"
11 },
12 "targetSelectorType" : "INSTANCES_LIST",
13 "targets" : [ {
14 "instanceType" : "BCC",
15 "instanceId" : "i-EVLpS***"
16 } ]
17}
返回示例
Plain Text
1200 Success
2
3{
4 "requestId" : "87c25fbd-21c9-4082-904a-0d8c85******",
5 "code" : "success",
6 "result" : {
7 "runId" : "r-2InH1HsWXU******",
8 "actionId" : "c-WgEtWtD3sV******"
9 }
10}
评价此篇文章
