查询执行历史记录详情
查询某一命令执行记录或文件上传记录详情
请求参数
参数名称 |
类型 |
是否必选 |
描述 |
id |
String |
是 |
执行ID |
pageNo |
int |
否 |
返回子执行记录页码,默认值1 |
pageSize |
int |
否 |
返回子执行记录页大小,默认值10,最大值100 |
childRunState |
String |
否 |
根据子执行状态过滤子执行记录。枚举值:FAILED(执行失败),RUNNING(执行中),SUCCESS(执行完成) |
响应参数
参数名称 |
类型 |
描述 |
requestId |
String |
执行详情 |
code |
String |
响应状态,成功为success |
result |
ActionRun |
执行详情 |
请求示例
from baidubce.auth.bce_credentials import BceCredentials
from baidubce.bce_client_configuration import BceClientConfiguration
from baidubce.services.ca import ca_client, ca_model
if __name__ == '__main__':
HOST = b'http://ca.bj.baidubce.com'
AK = b''
SK = b''
config = BceClientConfiguration(credentials=BceCredentials(AK, SK),
endpoint=HOST)
ca_client = CaClient(config)
user_id = ''
id = 'r-raUPWwr933Liqe54'
response = ca_client.get_action_run(id, user_id)
print(response)
响应示例
{
"requestId": "8b051243-0760-4776-b8b5-024309******",
"code": "success",
"result": {
"id": "r-N0UrpENajU******",
"state": "SUCCESS",
"action": {
"type": "COMMAND",
"name": "auto_run_1711100283",
"description": "",
"timeoutSecond": 300,
"command": {
"type": "SHELL",
"content": "echo 'hello world'",
"scope": "INDIVIDUAL",
"enableParameter": false,
"workDir": "/",
"execParams": {
"name": "value"
},
"user": "root"
},
"createdTimestamp": 1711100284000,
"updatedTimestamp": 1711100316000
},
"createdTimestamp": 1711100286000,
"finishedTimestamp": 1711100286000,
"children": [
{
"id": "d-vVnBql******",
"state": "SUCCESS",
"target": {
"instanceId": "i-mfIg****",
"instanceType": "BCC",
},
"createdTimestamp": 1711100286503,
"finishedTimestamp": 1711100286576,
"output": {
"exitCode": 0,
"stderr": "",
"stdout": "hello world\n",
"isTruncated": false
}
}
],
"totalCount": 1
}
}
查询执行记录列表
查询命令执行记录或文件上传记录列表
请求参数
参数名称 |
类型 |
是否必选 |
描述 |
action |
RunFilter |
是 |
执行记录过滤器 |
pageNo |
int |
是 |
页码 |
pageSize |
int |
是 |
页大小 |
ascending |
bool |
否 |
是否根据执行开始时间升序排列,默认为false |
state |
string |
否 |
根据执行状态过滤。枚举值:FAILED(执行失败),RUNNING(执行中),SUCCESS(执行完成) |
runId |
string |
否 |
根据执行ID过滤 |
startTime |
long |
否 |
时间筛选,Unix时间戳(毫秒)。执行开始时间 >= endTime,Unix时间戳(毫秒) |
endTime |
long |
否 |
时间筛选,Unix时间戳(毫秒)。执行开始时间 <= endTime,Unix时间戳(毫秒) |
RunFilter
参数名称 |
类型 |
是否必选 |
参数位置 |
描述 |
type |
string |
是 |
RequestBody参数 |
执行记录类型。枚举值:COMMAND(命令执行记录),FILE_UPLOAD(文件上传记录) |
id |
string |
否 |
RequestBody参数 |
通过命令ID筛选,仅对命令执行记录有效 |
name |
string |
否 |
RequestBody参数 |
通过命令名称筛选,仅对命令执行记录有效 |
fileUpload |
FileUploadFilter |
否 |
RequestBody参数 |
筛选命令上传记录 |
FileUploadFilter
参数名称 |
类型 |
是否必选 |
参数位置 |
描述 |
filename |
string |
是 |
RequestBody参数 |
通过上传文件名称筛选 |
响应头域
除公共头域外,无其它特殊头域。
响应参数
参数名称 |
类型 |
描述 |
requestId |
String |
执行详情 |
code |
String |
响应状态,成功为success |
result |
List<ActionRun> |
执行详情 |
请求示例
from baidubce.auth.bce_credentials import BceCredentials
from baidubce.bce_client_configuration import BceClientConfiguration
from baidubce.services.ca import ca_client, ca_model
if __name__ == '__main__':
HOST = b'http://ca.bj.baidubce.com'
AK = b''
SK = b''
config = BceClientConfiguration(credentials=BceCredentials(AK, SK),
endpoint=HOST)
ca_client = CaClient(config)
action = ca_model.Action(
"", "", "COMMAND"
)
ascending = False
page_no = 1
page_size = 10
sort = "createTime"
user_id = ""
response = ca_client.action_run_list(action, page_no, page_size, sort, ascending, user_id)
self.assertEqual(type(response), baidubce.bce_response.BceResponse)
print(response)
响应示例
{
"requestId": "f5c8cbf2-b66b-4894-b98d-dae6cb******",
"code": "success",
"result": {
"pageNo": 1,
"pageSize": 10,
"totalCount": 2,
"data": [
{
"id": "r-QWR6CCMVj0******",
"state": "SUCCESS",
"action": {
"type": "COMMAND",
"timeoutSecond": 60,
"command": {
"type": "SHELL",
"content": "ls",
"scope": "INDIVIDUAL",
"enableParameter": false,
"workDir": "/home",
"user": "root"
}
},
"createdTimestamp": 1710837417000,
"finishedTimestamp": 1710837419000,
"statistics": {
"totalTargetCount": 1,
"failedTargetCount": 0
}
},
{
"id": "r-vufYpbTTyd******",
"state": "SUCCESS",
"action": {
"id": "c-5iEoMgGqXL******",
"type": "COMMAND",
"name": "auto_test_1709896691",
"description": "",
"timeoutSecond": 300,
"command": {
"type": "SHELL",
"content": "echo 'hello world'",
"scope": "INDIVIDUAL",
"enableParameter": false,
"workDir": "/",
"user": "root"
}
},
"createdTimestamp": 1709896693000,
"finishedTimestamp": 1709896697000,
"statistics": {
"totalTargetCount": 1,
"failedTargetCount": 0
}
}
]
}
}
附录
ActionRun
参数名称 |
类型 |
描述 |
id |
String |
执行ID |
action |
Action |
所执行动作详情 |
state |
String |
执行状态。枚举值:FAILED(执行失败),RUNNING(执行中),SUCCESS(执行完成),PARTIAL_FAILED(部分失败) |
createdTimestamp |
long |
执行开始时间。unix时间戳,单位:毫秒 |
finishedTimestamp |
long |
执行结束时间,仅执行结束时返回。unix时间戳,单位:毫秒。 |
statistics |
Statistics |
子执行执行情况,仅查询执行记录列表时返回 |
ChildRun
参数名称 |
类型 |
描述 |
id |
String |
子执行ID |
state |
String |
执行状态。枚举值:FAILED(执行失败),RUNNING(执行中),SUCCESS(执行完成) |
createdTimestamp |
long |
子执行开始时间。unix时间戳,单位:毫秒 |
finishedTimestamp |
long |
子执行结束时间,仅执行结束时返回。unix时间戳,单位:毫秒。 |
failReason |
String |
子执行失败原因 |
output |
Output |
命令输出结果 |
Target |
Target |
子执行对应的实例信息 |
Output
参数名称 |
类型 |
描述 |
exitCode |
int |
退出码 |
stdout |
String |
标准输出 |
stderr |
String |
标准错误 |
isTruncated |
bool |
标准输出或标准错误是否由于过长(超过4KB)而被截断 |
Statistics
参数名称 |
类型 |
描述 |
totalTargetCount |
int |
执行的实例总数 |
failedTargetCount |
int |
已失败的执行实例总数 |