Compute v2: Extended Availability Zone Status (#282)
* Compute v2: Extended Availability Zone Status API
* Compute v2: Extended Availability Zone Status unit tests
* Compute v2: Extended Availability Zone Status acceptance tests
diff --git a/openstack/compute/v2/servers/results.go b/openstack/compute/v2/servers/results.go
index c121a6b..1ae1e91 100644
--- a/openstack/compute/v2/servers/results.go
+++ b/openstack/compute/v2/servers/results.go
@@ -19,11 +19,17 @@
// Extract interprets any serverResult as a Server, if possible.
func (r serverResult) Extract() (*Server, error) {
- var s struct {
- Server *Server `json:"server"`
- }
+ var s Server
err := r.ExtractInto(&s)
- return s.Server, err
+ return &s, err
+}
+
+func (r serverResult) ExtractInto(v interface{}) error {
+ return r.Result.ExtractIntoStructPtr(v, "server")
+}
+
+func ExtractServersInto(r pagination.Page, v interface{}) error {
+ return r.(ServerPage).Result.ExtractIntoSlicePtr(v, "servers")
}
// CreateResult temporarily contains the response from a Create call.
@@ -221,11 +227,9 @@
// ExtractServers interprets the results of a single page from a List() call, producing a slice of Server entities.
func ExtractServers(r pagination.Page) ([]Server, error) {
- var s struct {
- Servers []Server `json:"servers"`
- }
- err := (r.(ServerPage)).ExtractInto(&s)
- return s.Servers, err
+ var s []Server
+ err := ExtractServersInto(r, &s)
+ return s, err
}
// MetadataResult contains the result of a call for (potentially) multiple key-value pairs.