Refactor to use new client.Request
diff --git a/openstack/db/v1/databases/requests.go b/openstack/db/v1/databases/requests.go
index 300e177..4d10878 100644
--- a/openstack/db/v1/databases/requests.go
+++ b/openstack/db/v1/databases/requests.go
@@ -3,7 +3,6 @@
import (
"fmt"
- "github.com/racker/perigee"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
)
@@ -68,16 +67,12 @@
return res
}
- resp, err := perigee.Request("POST", baseURL(client, instanceID), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: &reqBody,
- Results: &res.Body,
- OkCodes: []int{202},
+ _, res.Err = client.Request("POST", baseURL(client, instanceID), gophercloud.RequestOpts{
+ JSONBody: &reqBody,
+ JSONResponse: &res.Body,
+ OkCodes: []int{202},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}
@@ -92,14 +87,10 @@
func Delete(client *gophercloud.ServiceClient, instanceID, dbName string) DeleteResult {
var res DeleteResult
- resp, err := perigee.Request("DELETE", dbURL(client, instanceID, dbName), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- Results: &res.Body,
- OkCodes: []int{202},
+ _, res.Err = client.Request("DELETE", dbURL(client, instanceID, dbName), gophercloud.RequestOpts{
+ JSONBody: &res.Body,
+ OkCodes: []int{202},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}
diff --git a/openstack/db/v1/flavors/requests.go b/openstack/db/v1/flavors/requests.go
index 3799469..b67a07b 100644
--- a/openstack/db/v1/flavors/requests.go
+++ b/openstack/db/v1/flavors/requests.go
@@ -1,7 +1,6 @@
package flavors
import (
- "github.com/racker/perigee"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
)
@@ -16,9 +15,11 @@
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var gr GetResult
- gr.Err = perigee.Get(getURL(client, id), perigee.Options{
- Results: &gr.Body,
- MoreHeaders: client.AuthenticatedHeaders(),
+
+ _, gr.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
+ JSONResponse: &gr.Body,
+ OkCodes: []int{200},
})
+
return gr
}
diff --git a/openstack/db/v1/instances/requests.go b/openstack/db/v1/instances/requests.go
index 84e4615..fc971fd 100644
--- a/openstack/db/v1/instances/requests.go
+++ b/openstack/db/v1/instances/requests.go
@@ -3,7 +3,6 @@
import (
"fmt"
- "github.com/racker/perigee"
"github.com/rackspace/gophercloud"
db "github.com/rackspace/gophercloud/openstack/db/v1/databases"
"github.com/rackspace/gophercloud/openstack/db/v1/users"
@@ -87,16 +86,12 @@
return res
}
- resp, err := perigee.Request("POST", baseURL(client), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: &reqBody,
- Results: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = client.Request("POST", baseURL(client), gophercloud.RequestOpts{
+ JSONBody: &reqBody,
+ JSONResponse: &res.Body,
+ OkCodes: []int{200},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}
@@ -113,15 +108,11 @@
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- resp, 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},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}
@@ -129,14 +120,10 @@
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- resp, 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},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}
@@ -145,15 +132,11 @@
func EnableRootUser(client *gophercloud.ServiceClient, id string) UserRootResult {
var res UserRootResult
- resp, err := perigee.Request("POST", userRootURL(client, id), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- Results: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = client.Request("POST", userRootURL(client, id), gophercloud.RequestOpts{
+ JSONResponse: &res.Body,
+ OkCodes: []int{200},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}
@@ -163,10 +146,9 @@
func IsRootEnabled(client *gophercloud.ServiceClient, id string) (bool, error) {
var res gophercloud.Result
- _, err := perigee.Request("GET", userRootURL(client, id), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- Results: &res.Body,
- OkCodes: []int{200},
+ _, err := client.Request("GET", userRootURL(client, id), gophercloud.RequestOpts{
+ JSONResponse: &res.Body,
+ OkCodes: []int{200},
})
return res.Body.(map[string]interface{})["rootEnabled"] == true, err
@@ -178,15 +160,11 @@
func RestartService(client *gophercloud.ServiceClient, id string) ActionResult {
var res ActionResult
- resp, err := perigee.Request("POST", actionURL(client, id), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: map[string]bool{"restart": true},
- OkCodes: []int{202},
+ _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
+ JSONBody: map[string]bool{"restart": true},
+ OkCodes: []int{202},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}
@@ -201,15 +179,11 @@
},
}
- resp, err := perigee.Request("POST", actionURL(client, id), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: reqBody,
- OkCodes: []int{202},
+ _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
+ JSONBody: reqBody,
+ OkCodes: []int{202},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}
@@ -225,14 +199,10 @@
},
}
- resp, err := perigee.Request("POST", actionURL(client, id), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: reqBody,
- OkCodes: []int{202},
+ _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
+ JSONBody: reqBody,
+ OkCodes: []int{202},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}
diff --git a/openstack/db/v1/users/requests.go b/openstack/db/v1/users/requests.go
index 529f43f..e596739 100644
--- a/openstack/db/v1/users/requests.go
+++ b/openstack/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"
"github.com/rackspace/gophercloud/pagination"
@@ -77,15 +76,11 @@
return res
}
- resp, err := perigee.Request("POST", baseURL(client, instanceID), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- ReqBody: &reqBody,
- OkCodes: []int{202},
+ _, res.Err = client.Request("POST", baseURL(client, instanceID), gophercloud.RequestOpts{
+ JSONBody: &reqBody,
+ OkCodes: []int{202},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}
@@ -100,13 +95,9 @@
func Delete(client *gophercloud.ServiceClient, instanceID, userName string) DeleteResult {
var res DeleteResult
- resp, err := perigee.Request("DELETE", userURL(client, instanceID, userName), perigee.Options{
- MoreHeaders: client.AuthenticatedHeaders(),
- OkCodes: []int{202},
+ _, res.Err = client.Request("DELETE", userURL(client, instanceID, userName), gophercloud.RequestOpts{
+ OkCodes: []int{202},
})
- res.Header = resp.HttpResponse.Header
- res.Err = err
-
return res
}