Adding support for replicas
diff --git a/rackspace/db/v1/instances/results.go b/rackspace/db/v1/instances/results.go
index d2eff6b..760e5a7 100644
--- a/rackspace/db/v1/instances/results.go
+++ b/rackspace/db/v1/instances/results.go
@@ -4,6 +4,7 @@
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
+ "github.com/rackspace/gophercloud/pagination"
)
type Datastore struct {
@@ -47,6 +48,12 @@
// Information about the attached volume of the instance.
Volume os.Volume
+
+ IP []string
+
+ ReplicaOf *Instance `mapstructure:"replica_of" json:"replica_of"`
+
+ Replicas []Instance
}
func commonExtract(err error, body interface{}) (*Instance, error) {
@@ -85,6 +92,10 @@
gophercloud.Result
}
+type DetachResult struct {
+ gophercloud.ErrResult
+}
+
// Extract will extract the configuration information (in the form of a map)
// about a particular instance.
func (r ConfigResult) Extract() (map[string]string, error) {
@@ -106,3 +117,14 @@
type UpdateResult struct {
gophercloud.ErrResult
}
+
+func ExtractInstances(page pagination.Page) ([]Instance, error) {
+ casted := page.(os.InstancePage).Body
+
+ var response struct {
+ Instances []Instance `mapstructure:"instances"`
+ }
+
+ err := mapstructure.Decode(casted, &response)
+ return response.Instances, err
+}