forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 10
/
results.go
37 lines (28 loc) · 850 Bytes
/
results.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package volumetypes
import (
"github.com/mitchellh/mapstructure"
os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumetypes"
"github.com/rackspace/gophercloud/pagination"
)
type VolumeType os.VolumeType
type GetResult struct {
os.GetResult
}
// Extract will get the Volume Type struct out of the response.
func (r GetResult) Extract() (*VolumeType, error) {
if r.Err != nil {
return nil, r.Err
}
var res struct {
VolumeType *VolumeType `json:"volume_type" mapstructure:"volume_type"`
}
err := mapstructure.Decode(r.Body, &res)
return res.VolumeType, err
}
func ExtractVolumeTypes(page pagination.Page) ([]VolumeType, error) {
var response struct {
VolumeTypes []VolumeType `mapstructure:"volume_types"`
}
err := mapstructure.Decode(page.(os.ListResult).Body, &response)
return response.VolumeTypes, err
}