@@ -15,7 +15,7 @@ const (
15
15
// endpoints of the Digital Ocean API.
16
16
// See: https://developers.digitalocean.com/documentation/v2#storage
17
17
type StorageService interface {
18
- ListVolumes (* ListOptions ) ([]Volume , * Response , error )
18
+ ListVolumes (* ListVolumeParams ) ([]Volume , * Response , error )
19
19
GetVolume (string ) (* Volume , * Response , error )
20
20
CreateVolume (* VolumeCreateRequest ) (* Volume , * Response , error )
21
21
DeleteVolume (string ) (* Response , error )
@@ -31,6 +31,13 @@ type StorageServiceOp struct {
31
31
client * Client
32
32
}
33
33
34
+ // ListVolumeParams stores the options you can set for a ListVolumeCall
35
+ type ListVolumeParams struct {
36
+ Region string `json:"region"`
37
+ Name string `json:"name"`
38
+ ListOptions * ListOptions `json:"list_options,omitempty"`
39
+ }
40
+
34
41
var _ StorageService = & StorageServiceOp {}
35
42
36
43
// Volume represents a Digital Ocean block store volume.
@@ -68,10 +75,20 @@ type VolumeCreateRequest struct {
68
75
}
69
76
70
77
// ListVolumes lists all storage volumes.
71
- func (svc * StorageServiceOp ) ListVolumes (opt * ListOptions ) ([]Volume , * Response , error ) {
72
- path , err := addOptions (storageAllocPath , opt )
73
- if err != nil {
74
- return nil , nil , err
78
+ func (svc * StorageServiceOp ) ListVolumes (params * ListVolumeParams ) ([]Volume , * Response , error ) {
79
+ path := storageAllocPath
80
+ if params != nil {
81
+ if params .Region != "" && params .Name != "" {
82
+ path = fmt .Sprintf ("%s?name=%s®ion=%s" , path , params .Name , params .Region )
83
+ }
84
+
85
+ if params .ListOptions != nil {
86
+ var err error
87
+ path , err = addOptions (path , params .ListOptions )
88
+ if err != nil {
89
+ return nil , nil , err
90
+ }
91
+ }
75
92
}
76
93
77
94
req , err := svc .client .NewRequest ("GET" , path , nil )
0 commit comments