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
40 changes: 34 additions & 6 deletions openstack/rds/v3/instances/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,40 @@ func Restart(client *golangsdk.ServiceClient, opts RestartRdsInstanceBuilder, in
return
}
fmt.Println("restart Rds instance body = ", b)
_, r.Err = client.Post(restartURL(client, instanceId), b, &r.Body, &golangsdk.RequestOpts{
_, r.Err = client.Post(updateURL(client, instanceId, "action"), b, &r.Body, &golangsdk.RequestOpts{
OkCodes: []int{202},
})
return
}

type RenameRdsInstanceOpts struct {
Name string `json:"name" required:"true"`
}

type RenameRdsInstanceBuilder interface {
ToRenameRdsInstanceMap() (map[string]interface{}, error)
}

func (opts RenameRdsInstanceOpts) ToRenameRdsInstanceMap() (map[string]interface{}, error) {
b, err := golangsdk.BuildRequestBody(&opts, "")
if err != nil {
return nil, err
}
return b, nil
}

func Rename(client *golangsdk.ServiceClient, opts RenameRdsInstanceBuilder, instanceId string) (r golangsdk.Result) {
b, err := opts.ToRenameRdsInstanceMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Put(updateURL(client, instanceId, "name"), b, nil, &golangsdk.RequestOpts{
OkCodes: []int{200, 202},
})
return
}

type ListRdsInstanceOpts struct {
Id string `q:"id"`
Name string `q:"name"`
Expand Down Expand Up @@ -242,7 +270,7 @@ func SingleToHa(client *golangsdk.ServiceClient, opts SingleToRdsHaBuilder, inst
r.Err = err
return
}
_, r.Err = client.Post(singletohaURL(client, instanceId), b, &r.Body, &golangsdk.RequestOpts{
_, r.Err = client.Post(updateURL(client, instanceId, "action"), b, &r.Body, &golangsdk.RequestOpts{
OkCodes: []int{202},
})

Expand Down Expand Up @@ -275,7 +303,7 @@ func Resize(client *golangsdk.ServiceClient, opts ResizeFlavorBuilder, instanceI
r.Err = err
return
}
_, r.Err = client.Post(resizeURL(client, instanceId), b, &r.Body, &golangsdk.RequestOpts{
_, r.Err = client.Post(updateURL(client, instanceId, "action"), b, &r.Body, &golangsdk.RequestOpts{
OkCodes: []int{202},
})

Expand Down Expand Up @@ -308,7 +336,7 @@ func EnlargeVolume(client *golangsdk.ServiceClient, opts EnlargeVolumeBuilder, i
r.Err = err
return
}
_, r.Err = client.Post(enlargeURL(client, instanceId), b, &r.Body, &golangsdk.RequestOpts{
_, r.Err = client.Post(updateURL(client, instanceId, "action"), b, &r.Body, &golangsdk.RequestOpts{
OkCodes: []int{202},
})

Expand Down Expand Up @@ -336,7 +364,7 @@ func (opts DbErrorlogOpts) DbErrorlogQuery() (string, error) {
}

func ListErrorLog(client *golangsdk.ServiceClient, opts DbErrorlogBuilder, instanceID string) pagination.Pager {
url := listerrorlogURL(client, instanceID)
url := updateURL(client, instanceID, "errorlog")
if opts != nil {
query, err := opts.DbErrorlogQuery()

Expand Down Expand Up @@ -376,7 +404,7 @@ func (opts DbSlowLogOpts) ToDbSlowLogListQuery() (string, error) {
}

func ListSlowLog(client *golangsdk.ServiceClient, opts DbSlowLogBuilder, instanceID string) pagination.Pager {
url := listslowlogURL(client, instanceID)
url := updateURL(client, instanceID, "slowlog")
if opts != nil {
query, err := opts.ToDbSlowLogListQuery()

Expand Down
24 changes: 2 additions & 22 deletions openstack/rds/v3/instances/urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,6 @@ func listURL(c *golangsdk.ServiceClient) string {
return c.ServiceURL("instances")
}

func restartURL(c *golangsdk.ServiceClient, instancesId string) string {
return c.ServiceURL("instances", instancesId, "action")
}

func singletohaURL(c *golangsdk.ServiceClient, instancesId string) string {
return c.ServiceURL("instances", instancesId, "action")
}

func resizeURL(c *golangsdk.ServiceClient, instancesId string) string {
return c.ServiceURL("instances", instancesId, "action")
}

func enlargeURL(c *golangsdk.ServiceClient, instancesId string) string {
return c.ServiceURL("instances", instancesId, "action")
}

func listerrorlogURL(c *golangsdk.ServiceClient, instanceID string) string {
return c.ServiceURL("instances", instanceID, "errorlog")
}

func listslowlogURL(c *golangsdk.ServiceClient, instanceID string) string {
return c.ServiceURL("instances", instanceID, "slowlog")
func updateURL(c *golangsdk.ServiceClient, instancesId string, updata string) string {
return c.ServiceURL("instances", instancesId, updata)
}