diff --git a/bce/config.go b/bce/config.go index b7475d10..5bf491ff 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.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" diff --git a/doc/ENIC.md b/doc/ENIC.md index 7b4f1ac1..0531cc1b 100644 --- a/doc/ENIC.md +++ b/doc/ENIC.md @@ -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") +``` # 错误处理 diff --git a/doc/RDS.md b/doc/RDS.md index bf9d1306..d0c8ada7 100644 --- a/doc/RDS.md +++ b/doc/RDS.md @@ -844,7 +844,8 @@ fmt.Printf("update parameter success\n") > > - 在修改配置参数时需要通过获取参数列表接口获取最新的Etag。 -# 其它 + +# 备份管理 ## 获取备份列表 @@ -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") +``` + + +# 其它 + ## 获取可用区列表 使用以下代码可以获取可用区列表。 diff --git a/services/rds/model.go b/services/rds/model.go index d44e0ade..f8723e17 100644 --- a/services/rds/model.go +++ b/services/rds/model.go @@ -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 @@ -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 { diff --git a/services/rds/rds.go b/services/rds/rds.go index 22dee6d0..4cf1393b 100644 --- a/services/rds/rds.go +++ b/services/rds/rds.go @@ -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: @@ -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: