创建运维模板
接口描述
您可以在模板中指定执行所需参数(参考请求示例1),也可以通过全局参数的形式在创建执行的时候再指定(参考请求实例2)
请求参数
名称 |
类型 |
描述 |
是否必须 |
参数位置 |
Template |
Template |
运维模板 |
是 |
RequestBody参数 |
响应参数
名称 |
类型 |
描述 |
id |
String |
模板ID,全局唯一 |
请求示例 1
req := &model.Template{
Name: "test_go_sdk",
Description: "des",
Tags: nil,
Operators: []*model.Operator{
{
Name: "start_bcc",
Description: "启动BCC实例",
Operator: "BCE::BCC::StartInstance",
Properties: map[string]interface{}{
"instances": []map[string]string{
{
"instanceId": "i-xxxxxx",
"name": "instance-xxxxx",
},
},
},
},
},
Properties: []*model.Property{
{
Name: "test_param",
Type: "string",
Required: false,
},
},
Linear: true,
}
result, err := oosClient.CreateTemplate(req)
响应示例 1
{
"success": true,
"msg": "",
"code": 200,
"result": {
"id": "tpl-******DK"
}
}
请求示例 2
req := &model.Template{
Name: "test_go_sdk_2",
Description: "des",
Tags: nil,
Operators: []*model.Operator{
{
Name: "start_bcc",
Description: "启动BCC实例",
Operator: "BCE::BCC::StartInstance",
Properties: map[string]interface{}{
"instances": []map[string]string{
{
"Ref":"test_param",
},
},
},
},
},
Properties: []*model.Property{
{
Name: "test_param",
Type: "bccInstance",
Required: true,
DefaultValue: map[string]interface{}{
"instanceId": "i-xxxxx",
},
},
},
Linear: true,
}
result, err := oosClient.CreateTemplate(req)
响应示例 2
{
"success": true,
"msg": "",
"code": 200,
"result": {
"id": "tpl-******"
}
}
校验运维模板
请求参数
名称 |
类型 |
描述 |
是否必须 |
参数位置 |
Template |
Template |
运维模板 |
是 |
RequestBody参数 |
请求示例
req := &model.Template{
Name: "test_go_sdk",
Description: "des",
Tags: nil,
Operators: []*model.Operator{
{
Name: "start_bcc",
Description: "启动BCC实例",
Operator: "BCE::BCC::StartInstance",
Properties: map[string]interface{}{
"instances": []map[string]string{
{
"instanceId": "i-xxxxxx",
"name": "instance-xxxxx",
},
},
},
},
},
Properties: []*model.Property{
{
Name: "test_param",
Type: "string",
Required: false,
},
},
Linear: true,
}
result, err := oosClient.CheckTemplate(req)
响应示例
成功响应示例
无
失败响应示例
[Code: InvalidRequest; Message: template is invalid: op name is required; RequestId: eb******]
更新运维模板
请求参数
名称 |
类型 |
描述 |
是否必须 |
参数位置 |
Template |
Template |
运维模板 |
是 |
RequestBody参数 |
请求示例
req := &model.Template{
ID: "tpl-26ENudO2",
Name: "test_go_sdk_2",
Description: "des",
Tags: nil,
Operators: []*model.Operator{
{
Name: "start_bcc",
Description: "启动BCC实例",
Operator: "BCE::BCC::StartInstance",
Properties: map[string]interface{}{
"instances": []map[string]string{
{
"Ref": "test_param",
},
{
"instanceId": "i-lQwXU07Z",
"name": "instance-3nd0wnlr",
},
},
},
},
},
Properties: []*model.Property{
{
Name: "test_param",
Type: "bccInstance",
Required: true,
DefaultValue: map[string]interface{}{
"instanceId": "i-lQwXU07Z",
},
},
},
Linear: true,
}
result, err := oosClient.UpdateTemplate(req)
删除运维模板
请求参数
名称 |
类型 |
描述 |
是否必须 |
参数位置 |
id |
String |
运维模板ID |
是 |
Query参数 |
请求示例
result, err := oosClient.DeleteTemplate("tpl-6UUp6jpj")
查看运维模板
请求参数
名称 |
类型 |
描述 |
是否必须 |
参数位置 |
name |
String |
运维模板名称 |
是 |
Query参数 |
templateType |
String |
运维模板类型:GLOBAL-全局模板;INDIVIDUAL-个人模板 |
是 |
Query参数 |
请求示例
result, err := oosClient.GetTemplateDetail("test_go_sdk", string(model.TemplateTypeIndividual))
响应示例
{
"success": true,
"msg": "",
"code": 200,
"result": {
"id": "tpl-******",
"name": "test_go_sdk",
"description": "",
"linear": true,
"operators": [
{
"name": "start_bcc",
"description": "",
"operator": "BCE::BCC::StopInstance",
"retries": 0,
"retryInterval": 60000,
"timeout": 3600000,
"parallelismControl": {
"ratio": 0.0,
"count": 0
},
"allowedFailureControl": {
"ratio": 0.0,
"count": 0
},
"manually": false,
"scheduleDelayMilli": 0,
"pauseOnFailure": false,
"properties": {
"instances": [
{
"instanceId": "i-******"
}
]
},
"initContext": {}
}
]
}
}
}
查看运维模板列表
请求参数
名称 |
类型 |
描述 |
是否必须 |
参数位置 |
sort |
String |
排序字段,默认为创建时间 |
否 |
RequestBody参数 |
ascending |
boolean |
是否升序,默认false |
否 |
RequestBody参数 |
pageNo |
int |
页数,从1开始计数 |
是 |
RequestBody参数 |
pageSize |
int |
每页展示数量,最大值:100 |
是 |
RequestBody参数 |
请求示例
req := &model.GetTemplateListRequest{
BasePageRequest: model.BasePageRequest{
Ascending: false,
PageNo: 1,
PageSize: 100,
},
}
result, err := oosClient.GetTemplateList(req)
响应示例
{
"success": true,
"msg": "",
"result": {
"templates": [
{
"id": "tpl-******",
"name": "test_go_sdk",
"type": "INDIVIDUAL",
"description": "",
"linear": true,
"operators": [
{
"name": "start_bcc",
"description": "",
"operator": "BCE::BCC::StopInstance",
"retries": 0,
"retryInterval": 60000,
"timeout": 3600000,
"parallelismControl": {
"ratio": 0.0,
"count": 0
},
"allowedFailureControl": {
"ratio": 0.0,
"count": 0
},
"manually": false,
"scheduleDelayMilli": 0,
"pauseOnFailure": false,
"properties": {
"instances": [
{
"instanceId": "i-******Pi"
}
]
},
"initContext": {}
}
]
}
],
"orderBy": "createTime",
"order": "desc",
"pageNo": 1,
"pageSize": 10,
"totalCount": 126
}
}