Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion openstack/dcs/v1/instances/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type InstanceBackupPolicy struct {
type PeriodicalBackupPlan struct {
// Time at which backup starts.
// "00:00-01:00" indicates that backup starts at 00:00:00.
BeginAt int `json:"begin_at" required:"true"`
BeginAt string `json:"begin_at" required:"true"`

// Interval at which backup is performed.
// Currently, only weekly backup is supported.
Expand Down Expand Up @@ -238,3 +238,40 @@ func UpdatePassword(client *golangsdk.ServiceClient, id string, opts UpdatePassw
})
return
}

//ExtendOptsBuilder is an interface which can build the map paramter of extend function
type ExtendOptsBuilder interface {
ToExtendMap() (map[string]interface{}, error)
}

//ExtendOpts is a struct which represents the parameters of extend function
type ExtendOpts struct {
// New specifications (memory space) of the DCS instance.
// The new specification value to which the DCS instance
// will be scaled up must be greater than the current specification value.
// Unit: GB.
NewCapacity int `json:"new_capacity" required:"true"`

// New order ID.
OrderID string `json:"order_id,omitempty"`
}

// ToExtendMap is used for type convert
func (opts ExtendOpts) ToExtendMap() (map[string]interface{}, error) {
return golangsdk.BuildRequestBody(opts, "")
}

// Extend is extending for a dcs instance
func Extend(client *golangsdk.ServiceClient, id string, opts ExtendOptsBuilder) (r ExtendResult) {

body, err := opts.ToExtendMap()
if err != nil {
r.Err = err
return
}

_, r.Err = client.Post(extendURL(client, id), body, &r.Body, &golangsdk.RequestOpts{
OkCodes: []int{204},
})
return
}
5 changes: 5 additions & 0 deletions openstack/dcs/v1/instances/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,8 @@ func (r UpdatePasswordResult) Extract() (*Password, error) {
err := r.Result.ExtractInto(&s)
return &s, err
}

// ExtendResult is a struct from which can get the result of extend method
type ExtendResult struct {
golangsdk.Result
}
6 changes: 6 additions & 0 deletions openstack/dcs/v1/instances/urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "github.com/huaweicloud/golangsdk"
// endpoint/instances
const resourcePath = "instances"
const passwordPath = "password"
const extendPath = "extend"

// createURL will build the rest query url of creation
func createURL(client *golangsdk.ServiceClient) string {
Expand All @@ -30,3 +31,8 @@ func getURL(client *golangsdk.ServiceClient, id string) string {
func passwordURL(client *golangsdk.ServiceClient, id string) string {
return client.ServiceURL(resourcePath, id, passwordPath)
}

// extendURL will build the extend update function
func extendURL(client *golangsdk.ServiceClient, id string) string {
return client.ServiceURL(resourcePath, id, extendPath)
}