Skip to content

Commit

Permalink
rds add backup api & update ENIC doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yangxin16 committed Nov 22, 2021
1 parent 56fadf2 commit a84cea9
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 2 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.96"
SDK_VERSION = "0.9.97"
URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path
DEFAULT_DOMAIN = "baidubce.com"
DEFAULT_PROTOCOL = "http"
Expand Down
14 changes: 14 additions & 0 deletions doc/ENIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,21 @@ if err != nil {
}
fmt.Println("eenic update security group success")
```
## ENIC查询配额

```go
args := &client.EniQuoteArgs{
EniId: "eniId",
ClientToken: getClientToken(),
InstanceId: "instanceId"
}
err := client.GetEniQuota(args)
if err != nil {
fmt.Printf("enic get quota info error: %+v\n", err)
return
}
fmt.Println("enic get quota info success")
```


# 错误处理
Expand Down
38 changes: 37 additions & 1 deletion doc/RDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,8 @@ fmt.Printf("update parameter success\n")
>
> - 在修改配置参数时需要通过获取参数列表接口获取最新的Etag。
# 其它

# 备份管理

## 获取备份列表

Expand All @@ -865,6 +866,41 @@ fmt.Printf("get backup list success\n")
>
> - 请求参数 marker 和 maxKeys 不是必须的。
## 获取备份详情

使用以下代码可以获取一个实例备份的详情信息。
```go
// import "github.com/baidubce/bce-sdk-go/services/rds"
_, err := client.GetBackupDetail(instanceId, backupId)
if err != nil {
fmt.Printf("get backup detail error: %+v\n", err)
return
}
fmt.Printf("get backup detail success\n")
```

## 更新备份策略

使用以下代码可以更新一个实例的备份策略。
```go
// import "github.com/baidubce/bce-sdk-go/services/rds"
args := &rds.ModifyBackupPolicyArgs{
BackupDays: "1,3",
BackupTime: "10:00:00Z",
Persistent: true,
ExpireInDays: 20,
}
err := client.ModifyBackupPolicy(instanceId, args)
if err != nil {
fmt.Printf("modify backup policy error: %+v\n", err)
return
}
fmt.Printf("modify backup policy success\n")
```


# 其它

## 获取可用区列表

使用以下代码可以获取可用区列表。
Expand Down
9 changes: 9 additions & 0 deletions services/rds/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ type ModifyPublicAccessArgs struct {
PublicAccess bool `json:"publicAccess"`
}

type ModifyBackupPolicyArgs struct {
BackupDays string `json:"backupDays"`
BackupTime string `json:"backupTime"`
Persistent bool `json:"persistent"`
ExpireInDays int `json:"expireInDays"`
}

type GetBackupListArgs struct {
Marker string
MaxKeys int
Expand All @@ -227,6 +234,8 @@ type Snapshot struct {
SnapshotStatus string `json:"backupStatus"`
SnapshotStartTime string `json:"backupStartTime"`
SnapshotEndTime string `json:"backupEndTime"`
DownloadUrl string `json:"downloadUrl"`
DownloadExpires string `json:"downloadExpires"`
}

type GetBackupListResult struct {
Expand Down
39 changes: 39 additions & 0 deletions services/rds/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,25 @@ func (c *Client) ModifyPublicAccess(instanceId string, args *ModifyPublicAccessA
Do()
}

// ModifyBackupPolicy - modify backup policy
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - instanceId: id of the instance
// - args: the arguments to modify public access
// RETURNS:
// - error: nil if success otherwise the specific error
func (c *Client) ModifyBackupPolicy(instanceId string, args *ModifyBackupPolicyArgs) error {

return bce.NewRequestBuilder(c).
WithMethod(http.PUT).
WithURL(getRdsUriWithInstanceId(instanceId)).
WithQueryParam("modifyBackupPolicy", "").
WithHeader(http.CONTENT_TYPE, bce.DEFAULT_CONTENT_TYPE).
WithBody(args).
Do()
}

// GetBackupList - get backup list of the instance
//
// PARAMS:
Expand Down Expand Up @@ -417,6 +436,26 @@ func (c *Client) GetBackupList(instanceId string, args *GetBackupListArgs) (*Get
return result, err
}

// GetBackupDetail - get backup detail of the instance's backup
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - instanceId: id of the instance
// - backupId: id of the backup
// RETURNS:
// - *Snapshot: result of the backup detail
// - error: nil if success otherwise the specific error
func (c *Client) GetBackupDetail(instanceId string, backupId string) (*Snapshot, error) {
result := &Snapshot{}
err := bce.NewRequestBuilder(c).
WithMethod(http.GET).
WithURL(getRdsUriWithInstanceId(instanceId) + "/backup/" + backupId).
WithResult(result).
Do()

return result, err
}

// GetZoneList - list all zone
//
// PARAMS:
Expand Down

0 comments on commit a84cea9

Please sign in to comment.