Skip to content

Commit

Permalink
Merge pull request digitalocean#27 from digitalocean/feature/resize-disk
Browse files Browse the repository at this point in the history
 Add boolean disk option to Resize droplet action.
  • Loading branch information
phillbaker committed Mar 9, 2015
2 parents b75999b + 68fe5fa commit 66c450f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions droplet_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type DropletActionsService interface {
PowerCycle(int) (*Action, *Response, error)
Reboot(int) (*Action, *Response, error)
Restore(int, int) (*Action, *Response, error)
Resize(int, string) (*Action, *Response, error)
Resize(int, string, bool) (*Action, *Response, error)
Rename(int, string) (*Action, *Response, error)
Snapshot(int, string) (*Action, *Response, error)
doAction(int, *ActionRequest) (*Action, *Response, error)
Expand Down Expand Up @@ -73,11 +73,12 @@ func (s *DropletActionsServiceOp) Restore(id, imageID int) (*Action, *Response,
}

// Resize a Droplet
func (s *DropletActionsServiceOp) Resize(id int, sizeSlug string) (*Action, *Response, error) {
func (s *DropletActionsServiceOp) Resize(id int, sizeSlug string, resizeDisk bool) (*Action, *Response, error) {
requestType := "resize"
request := &ActionRequest{
"type": requestType,
"size": sizeSlug,
"disk": resizeDisk,
}
return s.doAction(id, request)
}
Expand Down Expand Up @@ -154,4 +155,4 @@ func (s *DropletActionsServiceOp) get(path string) (*Action, *Response, error) {

func dropletActionPath(dropletID int) string {
return fmt.Sprintf("v2/droplets/%d/actions", dropletID)
}
}
5 changes: 3 additions & 2 deletions droplet_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func TestDropletAction_Resize(t *testing.T) {
request := &ActionRequest{
"type": "resize",
"size": "1024mb",
"disk": true,
}

mux.HandleFunc("/v2/droplets/1/actions", func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -196,7 +197,7 @@ func TestDropletAction_Resize(t *testing.T) {

})

action, _, err := client.DropletActions.Resize(1, "1024mb")
action, _, err := client.DropletActions.Resize(1, "1024mb", true)
if err != nil {
t.Errorf("DropletActions.Resize returned error: %v", err)
}
Expand Down Expand Up @@ -323,4 +324,4 @@ func TestDropletActions_Get(t *testing.T) {
if !reflect.DeepEqual(action, expected) {
t.Errorf("DropletActions.Get returned %+v, expected %+v", action, expected)
}
}
}

0 comments on commit 66c450f

Please sign in to comment.