remove mapstructure from blockstorage,cdn,compute,db pkgs
diff --git a/openstack/blockstorage/v1/snapshots/requests.go b/openstack/blockstorage/v1/snapshots/requests.go
index 5e9f55c..b3b3cff 100644
--- a/openstack/blockstorage/v1/snapshots/requests.go
+++ b/openstack/blockstorage/v1/snapshots/requests.go
@@ -124,7 +124,7 @@
}
createPage := func(r pagination.PageResult) pagination.Page {
- return ListResult{pagination.SinglePageBase(r)}
+ return SnapshotPage{pagination.SinglePageBase(r)}
}
return pagination.NewPager(client, url, createPage)
}
diff --git a/openstack/blockstorage/v1/snapshots/results.go b/openstack/blockstorage/v1/snapshots/results.go
index 71d1489..f0f8864 100644
--- a/openstack/blockstorage/v1/snapshots/results.go
+++ b/openstack/blockstorage/v1/snapshots/results.go
@@ -3,50 +3,48 @@
import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
-
- "github.com/mitchellh/mapstructure"
)
// Snapshot contains all the information associated with an OpenStack Snapshot.
type Snapshot struct {
// Currect status of the Snapshot.
- Status string `mapstructure:"status"`
+ Status string `json:"status"`
// Display name.
- Name string `mapstructure:"display_name"`
+ Name string `json:"display_name"`
// Instances onto which the Snapshot is attached.
- Attachments []string `mapstructure:"attachments"`
+ Attachments []string `json:"attachments"`
// Logical group.
- AvailabilityZone string `mapstructure:"availability_zone"`
+ AvailabilityZone string `json:"availability_zone"`
// Is the Snapshot bootable?
- Bootable string `mapstructure:"bootable"`
+ Bootable string `json:"bootable"`
// Date created.
- CreatedAt string `mapstructure:"created_at"`
+ CreatedAt gophercloud.JSONRFC3339Milli `json:"created_at"`
// Display description.
- Description string `mapstructure:"display_discription"`
+ Description string `json:"display_discription"`
// See VolumeType object for more information.
- VolumeType string `mapstructure:"volume_type"`
+ VolumeType string `json:"volume_type"`
// ID of the Snapshot from which this Snapshot was created.
- SnapshotID string `mapstructure:"snapshot_id"`
+ SnapshotID string `json:"snapshot_id"`
// ID of the Volume from which this Snapshot was created.
- VolumeID string `mapstructure:"volume_id"`
+ VolumeID string `json:"volume_id"`
// User-defined key-value pairs.
- Metadata map[string]string `mapstructure:"metadata"`
+ Metadata map[string]string `json:"metadata"`
// Unique identifier.
- ID string `mapstructure:"id"`
+ ID string `json:"id"`
// Size of the Snapshot, in GB.
- Size int `mapstructure:"size"`
+ Size int `json:"size"`
}
// CreateResult contains the response body and error from a Create request.
@@ -64,28 +62,25 @@
gophercloud.ErrResult
}
-// ListResult is a pagination.Pager that is returned from a call to the List function.
-type ListResult struct {
+// SnapshotPage is a pagination.Pager that is returned from a call to the List function.
+type SnapshotPage struct {
pagination.SinglePageBase
}
-// IsEmpty returns true if a ListResult contains no Snapshots.
-func (r ListResult) IsEmpty() (bool, error) {
+// IsEmpty returns true if a SnapshotPage contains no Snapshots.
+func (r SnapshotPage) IsEmpty() (bool, error) {
volumes, err := ExtractSnapshots(r)
- if err != nil {
- return true, err
- }
- return len(volumes) == 0, nil
+ return len(volumes) == 0, err
}
// ExtractSnapshots extracts and returns Snapshots. It is used while iterating over a snapshots.List call.
func ExtractSnapshots(page pagination.Page) ([]Snapshot, error) {
- var response struct {
+ r := page.(SnapshotPage)
+ var s struct {
Snapshots []Snapshot `json:"snapshots"`
}
-
- err := mapstructure.Decode(page.(ListResult).Body, &response)
- return response.Snapshots, err
+ err := r.ExtractInto(&s)
+ return s.Snapshots, err
}
// UpdateMetadataResult contains the response body and error from an UpdateMetadata request.
@@ -109,15 +104,9 @@
// Extract will get the Snapshot object out of the commonResult object.
func (r commonResult) Extract() (*Snapshot, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var res struct {
+ var s struct {
Snapshot *Snapshot `json:"snapshot"`
}
-
- err := mapstructure.Decode(r.Body, &res)
-
- return res.Snapshot, err
+ err := r.ExtractInto(&s)
+ return s.Snapshot, err
}