预留实例券
更新时间:2024-05-14
绑定标签
使用以下代码给指定预留实例券绑定标签
import (
"github.com/baidubce/bce-sdk-go/model"
"github.com/baidubce/bce-sdk-go/services/bbc"
)
func main() {
// 初始化AK/SK/Endpoint
ak, sk, endpoint := "ak", "sk", "bbc.bj.baidubce.com"
// 创建BBC Client
client, _ := bbc.NewClient(ak, sk, endpoint)
args := &bbc.ReservedTagsRequest{
// 标签列表
ChangeTags: []model.TagModel{
{
TagKey: "TagKey-go",
TagValue: "TagValue",
},
},
// 预留实例券列表,最多支持100个
ReservedInstanceIds: []string{
"r-oFpMXKhv", "r-HrztSVk0",
},
}
err := client.BindReservedInstanceToTags(args)
if err != nil {
panic(err)
}
}
解绑标签
使用以下代码从指定预留实例券中解绑标签
import (
"github.com/baidubce/bce-sdk-go/model"
"github.com/baidubce/bce-sdk-go/services/bbc"
)
func UnbindReservedTagsDemo() {
// 初始化AK/SK/Endpoint
ak, sk, endpoint := "ak", "sk", "bbc.bj.baidubce.com"
// 创建BBC Client
client, _ := bbc.NewClient(ak, sk, endpoint)
args := &bbc.ReservedTagsRequest{
// 标签列表
ChangeTags: []model.TagModel{
{
TagKey: "TagKey-go",
TagValue: "TagValue",
},
},
// 预留实例券列表,最多支持100个
ReservedInstanceIds: []string{
"r-oFpMXKhv", "r-HrztSVk0",
},
}
err := client.UnbindReservedInstanceFromTags(args)
if err != nil {
panic(err)
}
}