Rename Droplets.ListKernels() and co. to Droplets.Kernels()
so that the naming convention is consistent with the Images service where "ListFoo()" means "list images of type foo" rather than "list foos of the image".
This commit is contained in:
parent
df0702b9e2
commit
2a6cda7911
20
droplets.go
20
droplets.go
|
@ -15,11 +15,11 @@ type DropletsService interface {
|
|||
Get(int) (*DropletRoot, *Response, error)
|
||||
Create(*DropletCreateRequest) (*DropletRoot, *Response, error)
|
||||
Delete(int) (*Response, error)
|
||||
ListKernels(int, *ListOptions) ([]Kernel, *Response, error)
|
||||
ListSnapshots(int, *ListOptions) ([]Image, *Response, error)
|
||||
ListBackups(int, *ListOptions) ([]Image, *Response, error)
|
||||
ListActions(int, *ListOptions) ([]Action, *Response, error)
|
||||
ListNeighbors(int) ([]Droplet, *Response, error)
|
||||
Kernels(int, *ListOptions) ([]Kernel, *Response, error)
|
||||
Snapshots(int, *ListOptions) ([]Image, *Response, error)
|
||||
Backups(int, *ListOptions) ([]Image, *Response, error)
|
||||
Actions(int, *ListOptions) ([]Action, *Response, error)
|
||||
Neighbors(int) ([]Droplet, *Response, error)
|
||||
dropletActionStatus(string) (string, error)
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ func (s *DropletsServiceOp) Delete(dropletID int) (*Response, error) {
|
|||
}
|
||||
|
||||
// List droplet available kernels
|
||||
func (s *DropletsServiceOp) ListKernels(dropletID int, opt *ListOptions) ([]Kernel, *Response, error) {
|
||||
func (s *DropletsServiceOp) Kernels(dropletID int, opt *ListOptions) ([]Kernel, *Response, error) {
|
||||
path := fmt.Sprintf("%s/%d/kernels", dropletBasePath, dropletID)
|
||||
path, err := addOptions(path, opt)
|
||||
if err != nil {
|
||||
|
@ -264,7 +264,7 @@ func (s *DropletsServiceOp) ListKernels(dropletID int, opt *ListOptions) ([]Kern
|
|||
}
|
||||
|
||||
// List droplet actions
|
||||
func (s *DropletsServiceOp) ListActions(dropletID int, opt *ListOptions) ([]Action, *Response, error) {
|
||||
func (s *DropletsServiceOp) Actions(dropletID int, opt *ListOptions) ([]Action, *Response, error) {
|
||||
path := fmt.Sprintf("%s/%d/actions", dropletBasePath, dropletID)
|
||||
path, err := addOptions(path, opt)
|
||||
if err != nil {
|
||||
|
@ -289,7 +289,7 @@ func (s *DropletsServiceOp) ListActions(dropletID int, opt *ListOptions) ([]Acti
|
|||
}
|
||||
|
||||
// List droplet backups
|
||||
func (s *DropletsServiceOp) ListBackups(dropletID int, opt *ListOptions) ([]Image, *Response, error) {
|
||||
func (s *DropletsServiceOp) Backups(dropletID int, opt *ListOptions) ([]Image, *Response, error) {
|
||||
path := fmt.Sprintf("%s/%d/backups", dropletBasePath, dropletID)
|
||||
path, err := addOptions(path, opt)
|
||||
if err != nil {
|
||||
|
@ -314,7 +314,7 @@ func (s *DropletsServiceOp) ListBackups(dropletID int, opt *ListOptions) ([]Imag
|
|||
}
|
||||
|
||||
// List droplet snapshots
|
||||
func (s *DropletsServiceOp) ListSnapshots(dropletID int, opt *ListOptions) ([]Image, *Response, error) {
|
||||
func (s *DropletsServiceOp) Snapshots(dropletID int, opt *ListOptions) ([]Image, *Response, error) {
|
||||
path := fmt.Sprintf("%s/%d/snapshots", dropletBasePath, dropletID)
|
||||
path, err := addOptions(path, opt)
|
||||
if err != nil {
|
||||
|
@ -339,7 +339,7 @@ func (s *DropletsServiceOp) ListSnapshots(dropletID int, opt *ListOptions) ([]Im
|
|||
}
|
||||
|
||||
// List droplet neighbors
|
||||
func (s *DropletsServiceOp) ListNeighbors(dropletID int) ([]Droplet, *Response, error) {
|
||||
func (s *DropletsServiceOp) Neighbors(dropletID int) ([]Droplet, *Response, error) {
|
||||
path := fmt.Sprintf("%s/%d/neighbors", dropletBasePath, dropletID)
|
||||
|
||||
req, err := s.client.NewRequest("GET", path, nil)
|
||||
|
|
|
@ -178,7 +178,7 @@ func TestDroplets_Destroy(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestDroplets_ListKernels(t *testing.T) {
|
||||
func TestDroplets_Kernels(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
|
@ -188,18 +188,18 @@ func TestDroplets_ListKernels(t *testing.T) {
|
|||
})
|
||||
|
||||
opt := &ListOptions{Page: 2}
|
||||
kernels, _, err := client.Droplets.ListKernels(12345, opt)
|
||||
kernels, _, err := client.Droplets.Kernels(12345, opt)
|
||||
if err != nil {
|
||||
t.Errorf("Droplets.ListKernels returned error: %v", err)
|
||||
t.Errorf("Droplets.Kernels returned error: %v", err)
|
||||
}
|
||||
|
||||
expected := []Kernel{{ID: 1}, {ID: 2}}
|
||||
if !reflect.DeepEqual(kernels, expected) {
|
||||
t.Errorf("Droplets.ListKernels returned %+v, expected %+v", kernels, expected)
|
||||
t.Errorf("Droplets.Kernels returned %+v, expected %+v", kernels, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDroplets_ListSnapshots(t *testing.T) {
|
||||
func TestDroplets_Snapshots(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
|
@ -209,18 +209,18 @@ func TestDroplets_ListSnapshots(t *testing.T) {
|
|||
})
|
||||
|
||||
opt := &ListOptions{Page: 2}
|
||||
snapshots, _, err := client.Droplets.ListSnapshots(12345, opt)
|
||||
snapshots, _, err := client.Droplets.Snapshots(12345, opt)
|
||||
if err != nil {
|
||||
t.Errorf("Droplets.ListSnapshots returned error: %v", err)
|
||||
t.Errorf("Droplets.Snapshots returned error: %v", err)
|
||||
}
|
||||
|
||||
expected := []Image{{ID: 1}, {ID: 2}}
|
||||
if !reflect.DeepEqual(snapshots, expected) {
|
||||
t.Errorf("Droplets.ListSnapshots returned %+v, expected %+v", snapshots, expected)
|
||||
t.Errorf("Droplets.Snapshots returned %+v, expected %+v", snapshots, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDroplets_ListBackups(t *testing.T) {
|
||||
func TestDroplets_Backups(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
|
@ -230,18 +230,18 @@ func TestDroplets_ListBackups(t *testing.T) {
|
|||
})
|
||||
|
||||
opt := &ListOptions{Page: 2}
|
||||
backups, _, err := client.Droplets.ListBackups(12345, opt)
|
||||
backups, _, err := client.Droplets.Backups(12345, opt)
|
||||
if err != nil {
|
||||
t.Errorf("Droplets.ListBackups returned error: %v", err)
|
||||
t.Errorf("Droplets.Backups returned error: %v", err)
|
||||
}
|
||||
|
||||
expected := []Image{{ID: 1}, {ID: 2}}
|
||||
if !reflect.DeepEqual(backups, expected) {
|
||||
t.Errorf("Droplets.ListBackups returned %+v, expected %+v", backups, expected)
|
||||
t.Errorf("Droplets.Backups returned %+v, expected %+v", backups, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDroplets_ListActions(t *testing.T) {
|
||||
func TestDroplets_Actions(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
|
@ -251,18 +251,18 @@ func TestDroplets_ListActions(t *testing.T) {
|
|||
})
|
||||
|
||||
opt := &ListOptions{Page: 2}
|
||||
actions, _, err := client.Droplets.ListActions(12345, opt)
|
||||
actions, _, err := client.Droplets.Actions(12345, opt)
|
||||
if err != nil {
|
||||
t.Errorf("Droplets.ListActions returned error: %v", err)
|
||||
t.Errorf("Droplets.Actions returned error: %v", err)
|
||||
}
|
||||
|
||||
expected := []Action{{ID: 1}, {ID: 2}}
|
||||
if !reflect.DeepEqual(actions, expected) {
|
||||
t.Errorf("Droplets.ListActions returned %+v, expected %+v", actions, expected)
|
||||
t.Errorf("Droplets.Actions returned %+v, expected %+v", actions, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDroplets_ListNeighbors(t *testing.T) {
|
||||
func TestDroplets_Neighbors(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
|
@ -271,14 +271,14 @@ func TestDroplets_ListNeighbors(t *testing.T) {
|
|||
fmt.Fprint(w, `{"droplets": [{"id":1},{"id":2}]}`)
|
||||
})
|
||||
|
||||
neighbors, _, err := client.Droplets.ListNeighbors(12345)
|
||||
neighbors, _, err := client.Droplets.Neighbors(12345)
|
||||
if err != nil {
|
||||
t.Errorf("Droplets.ListNeighbors returned error: %v", err)
|
||||
t.Errorf("Droplets.Neighbors returned error: %v", err)
|
||||
}
|
||||
|
||||
expected := []Droplet{{ID: 1}, {ID: 2}}
|
||||
if !reflect.DeepEqual(neighbors, expected) {
|
||||
t.Errorf("Droplets.ListNeighbors returned %+v, expected %+v", neighbors, expected)
|
||||
t.Errorf("Droplets.Neighbors returned %+v, expected %+v", neighbors, expected)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue