From 3cf85865d29da8381f6b0a091b01ea48a6a8000d Mon Sep 17 00:00:00 2001 From: duanliguo Date: Thu, 10 Oct 2024 11:12:05 +0800 Subject: [PATCH] Updates features in bcc --- bce/config.go | 2 +- services/bcc/api/model.go | 18 ++++++++++------- services/bcc/client_test.go | 39 +++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/bce/config.go b/bce/config.go index f4871a3c..1c879d5b 100644 --- a/bce/config.go +++ b/bce/config.go @@ -26,7 +26,7 @@ import ( // Constants and default values for the package bce const ( - SDK_VERSION = "0.9.192" + SDK_VERSION = "0.9.133" URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path DEFAULT_DOMAIN = "baidubce.com" DEFAULT_PROTOCOL = "http" diff --git a/services/bcc/api/model.go b/services/bcc/api/model.go index 233fd4e5..a07ef059 100644 --- a/services/bcc/api/model.go +++ b/services/bcc/api/model.go @@ -1942,8 +1942,10 @@ type RebuildBatchInstanceArgsV2 struct { } type ChangeToPrepaidRequest struct { - Duration int `json:"duration"` - RelationCds bool `json:"relationCds"` + Duration int `json:"duration"` + RelationCds bool `json:"relationCds"` + AutoRenew bool `json:"autoRenew"` + AutoRenewPeriod int `json:"autoRenewPeriod"` } type ChangeToPrepaidResponse struct { @@ -2368,11 +2370,13 @@ type BatchChangeInstanceToPrepayArgs struct { } type PrepayConfig struct { - InstanceId string `json:"instanceId"` - Duration int `json:"duration"` - RelationCds bool `json:"relationCds"` - CdsList []string `json:"cdsList"` - AutoPay bool `json:"autoPay"` + InstanceId string `json:"instanceId"` + Duration int `json:"duration"` + RelationCds bool `json:"relationCds"` + CdsList []string `json:"cdsList"` + AutoPay bool `json:"autoPay"` + AutoRenew bool `json:"autoRenew"` + AutoRenewPeriod int `json:"autoRenewPeriod"` } type BatchChangeInstanceToPostpayArgs struct { diff --git a/services/bcc/client_test.go b/services/bcc/client_test.go index 46670203..9c4cd6fa 100644 --- a/services/bcc/client_test.go +++ b/services/bcc/client_test.go @@ -2130,3 +2130,42 @@ func TestEhcClusterDelete(t *testing.T) { err := BCC_CLIENT.DeleteEhcCluster(args) fmt.Println(err) } + +func TestChangeToPrepaidWithAutoRenew(t *testing.T) { + args := &api.ChangeToPrepaidRequest{ + Duration: 1, + RelationCds: true, + AutoRenew: true, + AutoRenewPeriod: 12, + } + _, err := BCC_CLIENT.ChangeToPrepaid("i-Dzmlx7Fz", args) + ExpectEqual(t.Errorf, err, nil) +} + +func TestBatchChangeInstanceToPrepayWithAutoRenew(t *testing.T) { + batchChangeInstanceToPrepayArgs := &api.BatchChangeInstanceToPrepayArgs{ + Config: []api.PrepayConfig{ + { + InstanceId: "i-kfnD7UQ7", + Duration: 1, + AutoRenew: true, + AutoRenewPeriod: 9, + CdsList: []string{ + "all", + }, + }, + { + InstanceId: "i-Dzmlx7Fz", + Duration: 1, + AutoRenew: true, + AutoRenewPeriod: 24, + CdsList: []string{ + "all", + }, + }, + }, + } + result, err := BCC_CLIENT.BatchChangeInstanceToPrepay(batchChangeInstanceToPrepayArgs) + ExpectEqual(t.Errorf, err, nil) + fmt.Println(result) +} \ No newline at end of file