Skip to content

Commit

Permalink
Add features in bcc, blb and bos
Browse files Browse the repository at this point in the history
  • Loading branch information
duanliguo committed May 14, 2024
1 parent 1d2f95b commit d689b56
Show file tree
Hide file tree
Showing 21 changed files with 448 additions and 882 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.179"
SDK_VERSION = "0.9.180"
URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path
DEFAULT_DOMAIN = "baidubce.com"
DEFAULT_PROTOCOL = "http"
Expand Down
23 changes: 23 additions & 0 deletions doc/BCC.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,8 @@ createInstanceArgs := &CreateInstanceArgs{
RequestToken string "requestToken"
// 设置要绑定的资源组id
ResGroupId string "resGroupId"
// 设置竞价实例eip释放时自动释放 默认false不启用,true启用
IsEipAutoRelatedDelete bool &IsEipAutoRelatedDelete
}
if res, err := bccClient.CreateBidInstance(createInstanceBySpecArgs); err != nil {
fmt.Println("create instance failed: ", err)
Expand Down Expand Up @@ -1420,6 +1422,27 @@ if err := bccClient.ModifyDeletionProtection(instanceId, args); err != nil {
}
```

> **提示:**
> - 只有付抢占实例允许设定关联eip释放策略
> - true表示当抢占实例自动释放时,eip随之释放,false表示当抢占实例自动释放时,eip解绑,不随实例释放。默认设置为false
### 设置eip随抢占实例自动释放
使用以下代码可以为BCC抢占实例设置关联eip自动释放,实例当前设置可查询实例详情IsEipAutoRelatedDelete,默认false解绑,true关联释放:

```go
args := &api.RelatedDeletePolicy {
IsEipAutoRelatedDelete: true,
}
// 设置你要操作的instanceId
instanceId := "your-choose-instance-id"

if err := bccClient.ModifyRelatedDeletePolicy(instanceId, args); err != nil {
fmt.Println("ModifyRelatedDeletePolicy failed: ", err)
} else {
fmt.Println("ModifyRelatedDeletePolicy success.")
}
```

> **提示:**
> - 后付费和预付费均可开启释放保护
> - 已开启释放保护的实例将无法通过控制台或API释放,只有在关闭的情况下才能被手动释放。定时释放,欠费释放以及实例过期释放不受释放保护属性的影响
Expand Down
10 changes: 7 additions & 3 deletions doc/DDCv2.md
Original file line number Diff line number Diff line change
Expand Up @@ -983,8 +983,10 @@ fmt.Printf("update instance name success\n")
// import ddcrds "github.com/baidubce/bce-sdk-go/services/ddc/v2"

args := &ddcrds.SwitchArgs{
// 立即切换
// 该字段已废弃,请使用waitSwitch。立即切换
IsSwitchNow: true,
// 执行时机控制。0:立即变配;1:维护时间内执行;2:用户控制执行时机
WaitSwitch: 0,
}
result, err := client.SwitchInstance(instanceId, args)
if err != nil {
Expand Down Expand Up @@ -1141,8 +1143,10 @@ args := &ddcrds.ResizeRdsArgs{
NodeAmount: 2,
// 是否进行直接支付,默认true,设置为直接支付的变配订单会直接扣款,不需要再走支付逻辑,可选
IsDirectPay: false,
// 是否立即变配 RDS只支持立即变配
IsResizeNow: true,
// 该字段已废弃,请使用WaitSwitch。是否立即变配 RDS只支持立即变配
//IsResizeNow: true,
// 变配时间窗口控制。0:立即变配;1:维护时间内变配;2:用户控制执行时机
WaitSwitch: 0,
}
orderIdResponse, err = client.ResizeRds(instanceId, args)
if err != nil {
Expand Down
68 changes: 38 additions & 30 deletions services/appblb/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,27 @@ type DescribeRsMountResult struct {
}

type CreateLoadBalancerArgs struct {
ClientToken string `json:"-"`
Name string `json:"name,omitempty"`
Description string `json:"desc,omitempty"`
SubnetId string `json:"subnetId"`
VpcId string `json:"vpcId"`
ClusterProperty string `json:"clusterProperty"`
Type string `json:"type,omitempty"`
Address string `json:"address,omitempty"`
Eip string `json:"eip,omitempty"`
ResourceGroupId string `json:"resourceGroupId,omitempty"`
AutoRenewLength int `json:"autoRenewLength,omitempty"`
AutoRenewTimeUnit string `json:"autoRenewTimeUnit,omitempty"`
PerformanceLevel string `json:"performanceLevel,omitempty"`
Billing *Billing `json:"billing,omitempty"`
Tags []model.TagModel `json:"tags,omitempty"`
AllowDelete *bool `json:"allowDelete,omitempty"`
AllocateIpv6 *bool `json:"allocateIpv6,omitempty"`
ClientToken string `json:"-"`
Name string `json:"name,omitempty"`
Description string `json:"desc,omitempty"`
SubnetId string `json:"subnetId"`
VpcId string `json:"vpcId"`
ClusterProperty string `json:"clusterProperty"`
Type string `json:"type,omitempty"`
Address string `json:"address,omitempty"`
Eip string `json:"eip,omitempty"`
ResourceGroupId string `json:"resourceGroupId,omitempty"`
AutoRenewLength int `json:"autoRenewLength,omitempty"`
AutoRenewTimeUnit string `json:"autoRenewTimeUnit,omitempty"`
PerformanceLevel string `json:"performanceLevel,omitempty"`
Billing *Billing `json:"billing,omitempty"`
Tags []model.TagModel `json:"tags,omitempty"`
AllowDelete *bool `json:"allowDelete,omitempty"`
AllocateIpv6 *bool `json:"allocateIpv6,omitempty"`
Layer4ClusterExclusive *bool `json:"layer4ClusterExclusive,omitempty"`
Layer7ClusterExclusive *bool `json:"layer7ClusterExclusive,omitempty"`
Layer4ClusterId string `json:"layer4ClusterId,omitempty"`
Layer7ClusterId string `json:"layer7ClusterId,omitempty"`
}

type Billing struct {
Expand Down Expand Up @@ -252,19 +256,21 @@ type DescribeLoadBalancersArgs struct {
}

type AppBLBModel struct {
BlbId string `json:"blbId"`
Name string `json:"name"`
Description string `json:"desc"`
Address string `json:"address"`
Status BLBStatus `json:"status"`
VpcId string `json:"vpcId"`
SubnetId string `json:"subnetId"`
PublicIp string `json:"publicIp"`
Layer4ClusterId string `json:"layer4ClusterId"`
Layer7ClusterId string `json:"layer7ClusterId"`
Tags []model.TagModel `json:"tags"`
EipRouteType string `json:"eipRouteType"`
AllowDelete bool `json:"allowDelete"`
BlbId string `json:"blbId"`
Name string `json:"name"`
Description string `json:"desc"`
Address string `json:"address"`
Status BLBStatus `json:"status"`
VpcId string `json:"vpcId"`
SubnetId string `json:"subnetId"`
PublicIp string `json:"publicIp"`
Layer4ClusterId string `json:"layer4ClusterId"`
Layer7ClusterId string `json:"layer7ClusterId"`
Tags []model.TagModel `json:"tags"`
EipRouteType string `json:"eipRouteType"`
AllowDelete bool `json:"allowDelete"`
Layer4ClusterExclusive bool `json:"layer4ClusterExclusive"`
Layer7ClusterExclusive bool `json:"layer7ClusterExclusive"`
}

type DescribeLoadBalancersResult struct {
Expand Down Expand Up @@ -311,6 +317,8 @@ type DescribeLoadBalancerDetailResult struct {
PaymentTiming string `json:"paymentTiming"`
PerformanceLevel string `json:"performanceLevel"`
ExpireTime string `json:"expireTime"`
AllowDelete bool `json:"allowDelete"`
VpcId string `json:"vpcId"`
}

type CreateAppTCPListenerArgs struct {
Expand Down
28 changes: 28 additions & 0 deletions services/bcc/api/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,34 @@ func ModifyDeletionProtection(cli bce.Client, instanceId string, reqBody *bce.Bo
return nil
}

// ModifyRelatedDeletePolicy - Modify RelatedDeletePolicy of specified instance
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - instanceId: id of the instance
// - reqBody: the request body to set an instance
// RETURNS:
// - error: nil if success otherwise the specific error
func ModifyRelatedDeletePolicy(cli bce.Client, instanceId string, reqBody *bce.Body) error {
// Build the request
req := &bce.BceRequest{}
req.SetUri(getInstanceRelatedDeletePolicy(instanceId))
req.SetMethod(http.PUT)
req.SetBody(reqBody)

// Send request and get response
resp := &bce.BceResponse{}
if err := cli.SendRequest(req, resp); err != nil {
return err
}
if resp.IsFail() {
return resp.ServiceError()
}

defer func() { resp.Body().Close() }()
return nil
}

// ModifyInstanceAttribute - modify attribute of a specified instance
//
// PARAMS:
Expand Down
Loading

0 comments on commit d689b56

Please sign in to comment.