1 step 'Extraction'
diff --git a/openstack/blockstorage/v1/snapshots/results.go b/openstack/blockstorage/v1/snapshots/results.go
index 440b3f8..d8178c1 100644
--- a/openstack/blockstorage/v1/snapshots/results.go
+++ b/openstack/blockstorage/v1/snapshots/results.go
@@ -1,5 +1,11 @@
package snapshots
+import (
+ "fmt"
+
+ "github.com/mitchellh/mapstructure"
+)
+
type Snapshot struct {
CreatedAt string
Description string
@@ -11,4 +17,23 @@
VolumeID string
}
-type GetResult map[string]interface{}
+type GetResult struct {
+ err error
+ r map[string]interface{}
+}
+
+func (gr GetResult) ExtractSnapshot() (*Snapshot, error) {
+ if gr.err != nil {
+ return nil, gr.err
+ }
+
+ var response struct {
+ Snapshot *Snapshot `json:"snapshot"`
+ }
+
+ err := mapstructure.Decode(gr.r, &response)
+ if err != nil {
+ return nil, fmt.Errorf("snapshots: Error decoding snapshot.GetResult: %v", err)
+ }
+ return response.Snapshot, nil
+}