Skip to content

Commit

Permalink
Updates features in bcc
Browse files Browse the repository at this point in the history
  • Loading branch information
duanliguo committed Oct 10, 2024
1 parent 3460ff3 commit 3cf8586
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bce/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 11 additions & 7 deletions services/bcc/api/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
39 changes: 39 additions & 0 deletions services/bcc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 3cf8586

Please sign in to comment.