list snapshots
diff --git a/acceptance/openstack/blockstorage_test.go b/acceptance/openstack/blockstorage_test.go
index dab7266..aaabac1 100644
--- a/acceptance/openstack/blockstorage_test.go
+++ b/acceptance/openstack/blockstorage_test.go
@@ -3,11 +3,11 @@
package openstack
import (
- //"fmt"
+ "fmt"
blockstorage "github.com/rackspace/gophercloud/openstack/blockstorage/v1"
"github.com/rackspace/gophercloud/openstack/blockstorage/v1/snapshots"
"github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes"
- "github.com/rackspace/gophercloud/openstack/identity"
+ identity "github.com/rackspace/gophercloud/openstack/identity/v2"
"github.com/rackspace/gophercloud/openstack/utils"
"os"
"strconv"
@@ -202,4 +202,12 @@
time.Sleep(2000 * time.Millisecond)
}
}()
+
+ lss, err := snapshots.List(client, snapshots.ListOpts{
+ Full: true,
+ })
+ if err != nil {
+ t.Error(err)
+ return
+ }
}
diff --git a/openstack/blockstorage/v1/client.go b/openstack/blockstorage/v1/client.go
index 52477ff..f8ed192 100644
--- a/openstack/blockstorage/v1/client.go
+++ b/openstack/blockstorage/v1/client.go
@@ -1,11 +1,11 @@
-package blockstorage
+package v1
import (
"fmt"
- "github.com/rackspace/gophercloud/openstack/identity"
+ identity "github.com/rackspace/gophercloud/openstack/identity/v2"
)
-// Client abstracts the connection information needed to make API requests for OpenStack compute endpoints.
+// Client abstracts the connection information needed to make API requests for OpenStack block storage endpoints.
type Client struct {
endpoint string
authority identity.AuthResults
diff --git a/openstack/blockstorage/v1/snapshots/requests.go b/openstack/blockstorage/v1/snapshots/requests.go
index 1fc3e27..92008c5 100644
--- a/openstack/blockstorage/v1/snapshots/requests.go
+++ b/openstack/blockstorage/v1/snapshots/requests.go
@@ -24,6 +24,27 @@
return ss, err
}
+func List(c *blockstorage.Client, opts ListOpts) ([]Snapshot, error) {
+ var ss []Snapshot
+ var url string
+ h, err := c.GetHeaders()
+ if err != nil {
+ return ss, err
+ }
+ if full := opts.Full; full {
+ url = c.GetSnapshotsURL()
+ } else {
+ url = c.GetSnapshotURL("detail")
+ }
+ _, err = perigee.Request("GET", url, perigee.Options{
+ Results: &struct {
+ Snapshot *[]Snapshot `json:"snapshots"`
+ }{&ss},
+ MoreHeaders: h,
+ })
+ return ss, err
+}
+
func Get(c *blockstorage.Client, opts GetOpts) (Snapshot, error) {
var ss Snapshot
h, err := c.GetHeaders()
diff --git a/openstack/blockstorage/v1/snapshots/snapshots.go b/openstack/blockstorage/v1/snapshots/snapshots.go
index bd5510a..836ba82 100644
--- a/openstack/blockstorage/v1/snapshots/snapshots.go
+++ b/openstack/blockstorage/v1/snapshots/snapshots.go
@@ -12,5 +12,8 @@
}
type CreateOpts map[string]interface{}
+type ListOpts struct {
+ Full bool
+}
type GetOpts map[string]string
type DeleteOpts map[string]string