initial paging implementation and create volume rewrite
diff --git a/openstack/blockstorage/v1/volumes/volumes.go b/openstack/blockstorage/v1/volumes/volumes.go
index 8120863..230543c 100644
--- a/openstack/blockstorage/v1/volumes/volumes.go
+++ b/openstack/blockstorage/v1/volumes/volumes.go
@@ -1,20 +1,48 @@
package volumes
+import (
+ "github.com/rackspace/gophercloud/pagination"
+
+ "github.com/mitchellh/mapstructure"
+)
+
type Volume struct {
- Status string
- Display_name string
- Attachments []string
- Availability_zone string
- Bootable bool
- Created_at string
- Display_description string
- Volume_type string
- Snapshot_id string
- Source_volid string
- Metadata map[string]string
- Id string
- Size int
+ Status string
+ Name string
+ Attachments []string
+ AvailabilityZone string
+ Bootable bool
+ CreatedAt string
+ Description string
+ VolumeType string
+ SnapshotID string
+ SourceVolID string
+ Metadata map[string]string
+ Id string
+ Size int
}
+
+type VolumePage struct {
+ pagination.LinkedPageBase
+}
+
+func (p VolumPage) IsEmpty() (bool, error) {
+ volumes, err := ExtractVolumes(p)
+ if err != nil {
+ return true, err
+ }
+ return len(volumes) == 0, nil
+}
+
+func ExtractVolumes(page pagination.page) ([]Volume, error) {
+ var response struct {
+ Volumes []Volume `json:"volumes"`
+ }
+
+ err := mapstructure.Decode(page.(VolumePage).Body, &response)
+ return response.Volumes, err
+}
+
type CreateOpts map[string]interface{}
type ListOpts map[string]bool
type GetOpts map[string]string