Skip to content

Commit

Permalink
Add features in bbc, eip and cce
Browse files Browse the repository at this point in the history
  • Loading branch information
duanliguo committed Jun 24, 2024
1 parent 01b34c0 commit f063385
Show file tree
Hide file tree
Showing 26 changed files with 1,066 additions and 236 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.183"
SDK_VERSION = "0.9.184"
URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path
DEFAULT_DOMAIN = "baidubce.com"
DEFAULT_PROTOCOL = "http"
Expand Down
55 changes: 55 additions & 0 deletions doc/BCC.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ createInstanceBySpecArgs := &api.CreateInstanceBySpecArgsV2{
RequestToken string "requestToken"
// 设置要绑定的资源组id
ResGroupId string "resGroupId"
// 指定的EHC高性能集群id
EhcClusterId string "ehcClusterId"
}
result, err := client.CreateInstanceBySpecV2(args)
if err != nil {
Expand Down Expand Up @@ -3566,6 +3568,58 @@ if res, err := bccClient.GetStockWithSpec(args); err != nil {
} else {
fmt.Println("GetStockWithSpec success: ", res)
```
### 创建EHC高性能集群
创建一个EHC高性能集群
```go
args := &api.CreateEhcClusterArg{
Name: "test-ehcCluster",
ZoneName: "cn-bj-a",
Description: "test description",
}
result, _ := BCC_CLIENT.CreateEhcCluster(args)
fmt.Println(result)
```
### 查询EHC高性能集群列表
查询EHC高性能集群列表
```go
args := &api.DescribeEhcClusterListArg{
EhcClusterIdList: []string{
"ehc-bk4hM1N3",
}, NameList: []string{
"test-modify",
},
ZoneName: "cn-bj-a",
SortKey: "name",
SortDir: "asc",
}
```
### 修改EHC高性能集群
修改EHC高性能集群信息
```go
descriptions := ""
args := &api.ModifyEhcClusterArg{
EhcClusterId: "ehc-bk4hM1N3",
Name: "test-modify",
Description: &descriptions,
}
err := BCC_CLIENT.ModifyEhcCluster(args)
fmt.Println(err)
```
### 删除EHC高性能集群
删除无实例EHC高性能集群
```go
args := &api.DeleteEhcClusterArg{
EhcClusterIdList: []string{
"ehc-tBmphmZE",
},
}
err := BCC_CLIENT.DeleteEhcCluster(args)
fmt.Println(err)
```
### 对预留实例券发起转移
对预留实例券发起转移(仅支持0预付的预留实例券)
```go
Expand Down Expand Up @@ -3612,6 +3666,7 @@ ExpectEqual(t.Errorf, err, nil)
args := &api.AcceptTransferReservedInstanceRequest{
// 预留实例券转移记录id
TransferRecordId: "t-uNwDdZO9",
EhcClusterId: "ehc-bk4hM1N3",
}
err := BCC_CLIENT.AcceptTransferReservedInstanceOrder(args)
ExpectEqual(t.Errorf, err, nil)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bcc
package reserved

import (
"github.com/baidubce/bce-sdk-go/model"
Expand Down
47 changes: 47 additions & 0 deletions examples/bcc/reserved/example_create_reserved_instance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package reserved

import (
"fmt"
"github.com/baidubce/bce-sdk-go/services/bcc/api"

"github.com/baidubce/bce-sdk-go/services/bcc"
)

func CreateReservedInstance() {

// 初始化AK/SK/Endpoint
ak, sk, endpoint := "ak", "sk", "bcc.bj.baidubce.com"
// 创建BCC Client
client, _ := bcc.NewClient(ak, sk, endpoint)

args := &api.CreateReservedInstanceArgs{
ClientToken: "myClientToken",
ReservedInstanceName: "myReservedInstance",
Scope: "AZ",
ZoneName: "cn-bj-a",
Spec: "bcc.g5.c2m8",
OfferingType: "FullyPrepay",
InstanceCount: 1,
ReservedInstanceCount: 1,
ReservedInstanceTime: 365,
ReservedInstanceTimeUnit: "month",
AutoRenewTimeUnit: "month",
AutoRenewTime: 1,
AutoRenew: true,
Tags: []api.Tag{
{
TagKey: "Env",
TagValue: "Production",
},
},
EhcClusterId: "ehcCluster123",
TicketId: "ticket456",
}

result, err := client.CreateReservedInstance(args)
if err != nil {
panic(err)
}

fmt.Println(result)
}
31 changes: 31 additions & 0 deletions examples/bcc/reserved/example_modify_reserved_instances.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package reserved

import (
"fmt"
"github.com/baidubce/bce-sdk-go/services/bcc"
"github.com/baidubce/bce-sdk-go/services/bcc/api"
)

func ModifyReservedInstances() {

// 初始化AK/SK/Endpoint
ak, sk, endpoint := "ak", "sk", "bcc.bj.baidubce.com"
// 创建BCC Client
client, _ := bcc.NewClient(ak, sk, endpoint)

args := &api.ModifyReservedInstancesArgs{
ReservedInstances: []api.ModifyReservedInstance{
{
ReservedInstanceId: "r-UBVQFB5b",
ReservedInstanceName: "update-reserved-instance",
},
},
}

result, err := client.ModifyReservedInstances(args)
if err != nil {
panic(err)
}

fmt.Println(result)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bcc
package reserved

import (
"github.com/baidubce/bce-sdk-go/model"
Expand Down
32 changes: 32 additions & 0 deletions examples/eip/example_eip_refund_eip.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2017 Baidu, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

package eipexamples

import (
"fmt"
)

func RefundEip() {
Init()

// 预付费eip退订
eip := "x.x.x.x"
err := eipClient.RefundEip(eip, "")
if err != nil {
panic(err)
}

fmt.Println("Refund prepay EIP successfully")
}
32 changes: 32 additions & 0 deletions examples/eip/example_eipgroup_refund_eipgroup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2017 Baidu, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

package eipexamples

import (
"fmt"
)

func RefundEipGroup() {
Init()

// 待退订的预付费的eipgroup的id
id := "eg-xxxxxxxx"
err := eipClient.RefundEipGroup(id, "")
if err != nil {
panic(err)
}

fmt.Println("Refund prepay EipGroup successfully")
}
1 change: 1 addition & 0 deletions examples/endpoint/example_create_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func CreateEndpoint() {
Billing: &endpoint.Billing{
PaymentTiming: "Postpaid",
},
Bandwidth: 10,
Tags: []model.TagModel{
{
TagKey: "tagKey",
Expand Down
Loading

0 comments on commit f063385

Please sign in to comment.