Refactor to use new client.Request
diff --git a/rackspace/db/v1/backups/requests.go b/rackspace/db/v1/backups/requests.go
index 7bc14ff..9bcc25a 100644
--- a/rackspace/db/v1/backups/requests.go
+++ b/rackspace/db/v1/backups/requests.go
@@ -3,7 +3,6 @@
import (
"errors"
- "github.com/racker/perigee"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
)
@@ -49,11 +48,10 @@
return res
}
- _, res.Err = perigee.Request("POST", baseURL(client), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: &reqBody,
- Results: &res.Body,
- OkCodes: []int{202},
+ _, res.Err = client.Request("POST", baseURL(client), gophercloud.RequestOpts{
+ JSONBody: &reqBody,
+ JSONResponse: &res.Body,
+ OkCodes: []int{202},
})
return res
@@ -96,10 +94,9 @@
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = perigee.Request("GET", resourceURL(client, id), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- Results: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = client.Request("GET", resourceURL(client, id), gophercloud.RequestOpts{
+ JSONResponse: &res.Body,
+ OkCodes: []int{200},
})
return res
@@ -108,9 +105,8 @@
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = perigee.Request("DELETE", resourceURL(client, id), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- OkCodes: []int{202},
+ _, res.Err = client.Request("DELETE", resourceURL(client, id), gophercloud.RequestOpts{
+ OkCodes: []int{202},
})
return res
diff --git a/rackspace/db/v1/backups/requests_test.go b/rackspace/db/v1/backups/requests_test.go
index 60fe064..e5d8f7c 100644
--- a/rackspace/db/v1/backups/requests_test.go
+++ b/rackspace/db/v1/backups/requests_test.go
@@ -4,6 +4,7 @@
"testing"
"github.com/rackspace/gophercloud/pagination"
+ "github.com/rackspace/gophercloud/rackspace/db/v1/datastores"
th "github.com/rackspace/gophercloud/testhelper"
fake "github.com/rackspace/gophercloud/testhelper/client"
)
@@ -36,7 +37,7 @@
Size: 100,
Status: "NEW",
Updated: "2014-02-13T21:47:16",
- Datastore: datastores.Datastore{
+ Datastore: datastores.DatastorePartial{
Version: "5.1",
Type: "MySQL",
VersionID: "20000000-0000-0000-0000-000000000002",
@@ -71,7 +72,7 @@
Size: 0.141026,
Status: "COMPLETED",
Updated: "2014-06-18T21:24:39",
- Datastore: datastores.Datastore{
+ Datastore: datastores.DatastorePartial{
Version: "5.1",
Type: "MySQL",
VersionID: "20000000-0000-0000-0000-000000000002",
@@ -109,7 +110,7 @@
Size: 100,
Status: "NEW",
Updated: "2014-02-13T21:47:16",
- Datastore: datastores.Datastore{
+ Datastore: datastores.DatastorePartial{
Version: "5.1",
Type: "MySQL",
VersionID: "20000000-0000-0000-0000-000000000002",
diff --git a/rackspace/db/v1/backups/results.go b/rackspace/db/v1/backups/results.go
index 475a41d..402fc86 100644
--- a/rackspace/db/v1/backups/results.go
+++ b/rackspace/db/v1/backups/results.go
@@ -18,7 +18,7 @@
Status string
Created string
Updated string
- Datastore datastores.Datastore
+ Datastore datastores.DatastorePartial
}
type CreateResult struct {
diff --git a/rackspace/db/v1/datastores/results.go b/rackspace/db/v1/datastores/results.go
index fbfb2cf..31fd838 100644
--- a/rackspace/db/v1/datastores/results.go
+++ b/rackspace/db/v1/datastores/results.go
@@ -20,6 +20,12 @@
Versions []Version
}
+type DatastorePartial struct {
+ Version string
+ Type string
+ VersionID string `json:"version_id" mapstructure:"version_id"`
+}
+
type GetResult struct {
gophercloud.Result
}
diff --git a/rackspace/db/v1/instances/delegate_test.go b/rackspace/db/v1/instances/delegate_test.go
index 3ba7a5e..d43b1e1 100644
--- a/rackspace/db/v1/instances/delegate_test.go
+++ b/rackspace/db/v1/instances/delegate_test.go
@@ -7,6 +7,7 @@
osDBs "github.com/rackspace/gophercloud/openstack/db/v1/databases"
os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
osUsers "github.com/rackspace/gophercloud/openstack/db/v1/users"
+ "github.com/rackspace/gophercloud/rackspace/db/v1/datastores"
th "github.com/rackspace/gophercloud/testhelper"
fake "github.com/rackspace/gophercloud/testhelper/client"
)
@@ -16,7 +17,7 @@
var expectedInstance = &Instance{
Created: "2014-02-13T21:47:13",
Updated: "2014-02-13T21:47:13",
- Datastore: Datastore{Type: "mysql", Version: "5.6"},
+ Datastore: datastores.DatastorePartial{Type: "mysql", Version: "5.6"},
Flavor: os.Flavor{
ID: "1",
Links: []gophercloud.Link{
diff --git a/rackspace/db/v1/instances/requests.go b/rackspace/db/v1/instances/requests.go
index 66bc872..cfebd5d 100644
--- a/rackspace/db/v1/instances/requests.go
+++ b/rackspace/db/v1/instances/requests.go
@@ -1,7 +1,6 @@
package instances
import (
- "github.com/racker/perigee"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
"github.com/rackspace/gophercloud/rackspace/db/v1/backups"
@@ -10,10 +9,9 @@
func GetDefaultConfig(client *gophercloud.ServiceClient, id string) ConfigResult {
var res ConfigResult
- _, res.Err = perigee.Request("GET", configURL(client, id), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- Results: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = client.Request("GET", configURL(client, id), gophercloud.RequestOpts{
+ JSONResponse: &res.Body,
+ OkCodes: []int{200},
})
return res
@@ -26,10 +24,9 @@
var res UpdateResult
- _, res.Err = perigee.Request("PUT", resourceURL(client, instanceID), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: map[string]map[string]string{"instance": reqBody},
- OkCodes: []int{202},
+ _, res.Err = client.Request("PUT", resourceURL(client, instanceID), gophercloud.RequestOpts{
+ JSONBody: map[string]map[string]string{"instance": reqBody},
+ OkCodes: []int{202},
})
return res
@@ -45,10 +42,9 @@
func DetachReplica(client *gophercloud.ServiceClient, replicaID string) DetachResult {
var res DetachResult
- _, res.Err = perigee.Request("PATCH", resourceURL(client, replicaID), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: map[string]interface{}{"instance": map[string]string{"replica_of": "", "slave_of": ""}},
- OkCodes: []int{202},
+ _, res.Err = client.Request("PATCH", resourceURL(client, replicaID), gophercloud.RequestOpts{
+ JSONBody: map[string]interface{}{"instance": map[string]string{"replica_of": "", "slave_of": ""}},
+ OkCodes: []int{202},
})
return res
diff --git a/rackspace/db/v1/instances/requests_test.go b/rackspace/db/v1/instances/requests_test.go
index 2cafa22..35afe01 100644
--- a/rackspace/db/v1/instances/requests_test.go
+++ b/rackspace/db/v1/instances/requests_test.go
@@ -7,6 +7,7 @@
os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
"github.com/rackspace/gophercloud/pagination"
"github.com/rackspace/gophercloud/rackspace/db/v1/backups"
+ "github.com/rackspace/gophercloud/rackspace/db/v1/datastores"
th "github.com/rackspace/gophercloud/testhelper"
fake "github.com/rackspace/gophercloud/testhelper/client"
)
@@ -23,7 +24,7 @@
ID: "8367c312-7c40-4a66-aab1-5767478914fc",
Volume: os.Volume{Size: 1},
Flavor: os.Flavor{ID: "9"},
- Datastore: Datastore{Version: "5.6", Type: "mysql"},
+ Datastore: datastores.DatastorePartial{Version: "5.6", Type: "mysql"},
ReplicaOf: &Instance{
ID: "6bdca2fc-418e-40bd-a595-62abda61862d",
},
@@ -121,7 +122,7 @@
Size: 0.141026,
Status: "COMPLETED",
Updated: "2014-06-18T21:24:39",
- Datastore: backups.Datastore{Version: "5.1", Type: "MySQL", VersionID: "20000000-0000-0000-0000-000000000002"},
+ Datastore: datastores.DatastorePartial{Version: "5.1", Type: "MySQL", VersionID: "20000000-0000-0000-0000-000000000002"},
},
}
@@ -181,7 +182,7 @@
IP: []string{"10.0.0.3"},
Volume: os.Volume{Size: 1},
Flavor: os.Flavor{ID: "9"},
- Datastore: Datastore{Version: "5.6", Type: "mysql"},
+ Datastore: datastores.DatastorePartial{Version: "5.6", Type: "mysql"},
ReplicaOf: &Instance{
ID: "8b499b45-52d6-402d-b398-f9d8f279c69a",
},
@@ -226,7 +227,7 @@
Size: 1,
},
Flavor: os.Flavor{ID: "9"},
- Datastore: Datastore{
+ Datastore: datastores.DatastorePartial{
Version: "5.6",
Type: "mysql",
},
diff --git a/rackspace/db/v1/instances/results.go b/rackspace/db/v1/instances/results.go
index e0c5aa5..2ce302b 100644
--- a/rackspace/db/v1/instances/results.go
+++ b/rackspace/db/v1/instances/results.go
@@ -17,7 +17,7 @@
Updated string //time.Time
// Indicates how the instance stores data.
- Datastore datastores.Datastore
+ Datastore datastores.DatastorePartial
// Indicates the hardware flavor the instance uses.
Flavor os.Flavor
diff --git a/rackspace/db/v1/users/requests.go b/rackspace/db/v1/users/requests.go
index 18303e9..f526cf9 100644
--- a/rackspace/db/v1/users/requests.go
+++ b/rackspace/db/v1/users/requests.go
@@ -1,7 +1,6 @@
package users
import (
- "github.com/racker/perigee"
"github.com/rackspace/gophercloud"
db "github.com/rackspace/gophercloud/openstack/db/v1/databases"
os "github.com/rackspace/gophercloud/openstack/db/v1/users"
@@ -17,10 +16,9 @@
return res
}
- _, res.Err = perigee.Request("PUT", baseURL(client, instanceID), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: &reqBody,
- OkCodes: []int{202},
+ _, res.Err = client.Request("PUT", baseURL(client, instanceID), gophercloud.RequestOpts{
+ JSONBody: &reqBody,
+ OkCodes: []int{202},
})
return res
@@ -36,10 +34,9 @@
}
reqBody = map[string]interface{}{"user": reqBody}
- _, res.Err = perigee.Request("PUT", userURL(client, instanceID, userName), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: &reqBody,
- OkCodes: []int{202},
+ _, res.Err = client.Request("PUT", userURL(client, instanceID, userName), gophercloud.RequestOpts{
+ JSONBody: &reqBody,
+ OkCodes: []int{202},
})
return res
@@ -48,10 +45,9 @@
func Get(client *gophercloud.ServiceClient, instanceID, userName string) GetResult {
var res GetResult
- _, res.Err = perigee.Request("GET", userURL(client, instanceID, userName), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- Results: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = client.Request("GET", userURL(client, instanceID, userName), gophercloud.RequestOpts{
+ JSONResponse: &res.Body,
+ OkCodes: []int{200},
})
return res
@@ -74,10 +70,9 @@
return res
}
- _, res.Err = perigee.Request("PUT", dbsURL(client, instanceID, userName), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: &reqBody,
- OkCodes: []int{202},
+ _, res.Err = client.Request("PUT", dbsURL(client, instanceID, userName), gophercloud.RequestOpts{
+ JSONBody: &reqBody,
+ OkCodes: []int{202},
})
return res
@@ -86,9 +81,8 @@
func RevokeAccess(client *gophercloud.ServiceClient, instanceID, userName, dbName string) RevokeAccessResult {
var res RevokeAccessResult
- _, res.Err = perigee.Request("DELETE", dbURL(client, instanceID, userName, dbName), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- OkCodes: []int{202},
+ _, res.Err = client.Request("DELETE", dbURL(client, instanceID, userName, dbName), gophercloud.RequestOpts{
+ OkCodes: []int{202},
})
return res