任务执行(Execution)接口
更新时间:2024-08-16
创建任务执行
接口描述
可以通过如下两种方式创建任务执行:
- 引用一个已存在的模板(参考请求示例1)
- 在创建执行时动态创建一个模板(参考请求示例2)
请求参数
名称 | 类型 | 描述 | 是否必须 | 参数位置 |
---|---|---|---|---|
execution | Execution | 任务执行 | 是 | RequestBody参数 |
请求示例1
req := &model.Execution{
Description: "创建执行测试1",
Template: &model.Template{
Name: "test"
Ref: "tpl-n******",
Linear: true,
},
}
result, err := oosClient.CreateExecution(req)
请求示例2
req := &model.Execution{
Description: "创建执行测试2",
Template: &model.Template{
Name: "test_template_02",
Operators: []*model.Operator{
{
Name: "stop_bcc",
Description: "停止BCC实例",
Operator: "BCE::BCC::StopInstance",
Retries: 3,
RetryInterval: 60000,
Timeout: 3600000,
ParallelismControl: &model.RateControl{
Ratio: 0,
Count: 1,
},
Properties: map[string]interface{}{
"instances": []map[string]string{
{
"instanceId": "i-jOS24U0l",
"name": "instance-3nd0wnlr",
},
},
},
},
},
Linear: true,
},
}
result, err := oosClient.CreateExecution(req)
响应示例
{
"success":true,
"msg":"",
"code":200,
"result":{
// 任务执行ID
"id":"d-C******"
}
}
查看任务执行
请求参数
名称 | 类型 | 描述 | 是否必须 | 参数位置 |
---|---|---|---|---|
id | String | 任务执行ID | 否 | Query参数 |
请求示例
result, err := oosClient.GetExecutionDetail("d-*********")
响应示例
{
"success": true,
"msg": "",
"code": 200,
"result": {
"id": "d-*********",
"template": {
"name": "test_oos_template",
"type": "INDIVIDUAL",
"tags": [],
"linear": true,
"links": [],
"operators": [
{
"name": "stop_bcc",
"operator": "BCE::BCC::StopInstance",
"retries": 0,
"retryInterval": 60000,
"timeout": 3600000,
"manually": false,
"scheduleDelayMilli": 0,
"pauseOnFailure": false,
"properties": {
"instanceId": {
"Ref": "instanceId"
},
"instances": [
{
"instanceId": "i-******kK"
}
]
},
"initContext": {}
}
],
"properties": []
},
"createdTimestamp": 1713941313268,
"updatedTimestamp": 1713941326534,
"finishedTimestamp": 1713941326534,
"state": "SUCCESS",
"properties": {},
"tasks": [
{
"id": "t-*****************",
"revision": 79917077,
"createdTimestamp": 1713941313269,
"updatedTimestamp": 1713941326532,
"finishedTimestamp": 1713941326532,
"state": "SUCCESS",
"operator": {
"name": "stop_bcc",
"operator": "BCE::BCC::StopInstance",
"retries": 0,
"retryInterval": 60000,
"timeout": 3600000,
"manually": false,
"scheduleDelayMilli": 0,
"pauseOnFailure": false,
"properties": {},
"initContext": {
"instanceId": {
"Ref": "instanceId"
},
"instances": [
{
"instanceId": "i-******kK"
}
]
}
},
"initContext": {
"instanceId": {
"Ref": "instanceId"
},
"instances": [
{
"instanceId": "i-******kK"
}
]
},
"context": {},
"outputContext": {
"instances": [
{
"instanceId": "i-******kK"
}
]
},
"tries": 0,
"children": []
}
],
"tags": [],
"trigger": "MANUAL"
}
}