Complete Flavors sub-API.
diff --git a/openstack/compute/flavors/flavors.go b/openstack/compute/flavors/flavors.go
index 81996a5..146bcc4 100644
--- a/openstack/compute/flavors/flavors.go
+++ b/openstack/compute/flavors/flavors.go
@@ -35,6 +35,7 @@
return v, nil
}
+// GetFlavors provides access to the list of flavors returned by the List function.
func GetFlavors(lr ListResults) ([]Flavor, error) {
fa, ok := lr["flavors"]
if !ok {
@@ -60,3 +61,23 @@
}
return flavors, nil
}
+
+// GetFlavor provides access to the individual flavor returned by the Get function.
+func GetFlavor(gr GetResults) (*Flavor, error) {
+ f, ok := gr["flavor"]
+ if !ok {
+ return nil, ErrNotImplemented
+ }
+
+ flav := new(Flavor)
+ cfg := &mapstructure.DecoderConfig{
+ DecodeHook: defaulter,
+ Result: flav,
+ }
+ decoder, err := mapstructure.NewDecoder(cfg)
+ if err != nil {
+ return flav, err
+ }
+ err = decoder.Decode(f)
+ return flav, err
+}