Converting Rackspace services to new HTTP methods
diff --git a/rackspace/lb/v1/lbs/requests.go b/rackspace/lb/v1/lbs/requests.go
index 49a46f6..46f5f02 100644
--- a/rackspace/lb/v1/lbs/requests.go
+++ b/rackspace/lb/v1/lbs/requests.go
@@ -227,12 +227,7 @@
return res
}
- _, res.Err = c.Request("POST", rootURL(c), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- JSONResponse: &res.Body,
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res
}
@@ -243,9 +238,8 @@
func Get(c *gophercloud.ServiceClient, id int) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", resourceURL(c, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
+ _, res.Err = c.Get(resourceURL(c, id), &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
@@ -269,21 +263,14 @@
url := rootURL(c)
url += gophercloud.IDSliceToQueryString("id", ids)
- _, res.Err = c.Request("DELETE", url, gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Delete(url, nil)
return res
}
// Delete removes a single load balancer.
func Delete(c *gophercloud.ServiceClient, id int) DeleteResult {
var res DeleteResult
-
- _, res.Err = c.Request("DELETE", resourceURL(c, id), gophercloud.RequestOpts{
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Delete(resourceURL(c, id), nil)
return res
}
@@ -363,11 +350,7 @@
return res
}
- _, res.Err = c.Request("PUT", resourceURL(c, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = c.Put(resourceURL(c, id), reqBody, nil, nil)
return res
}
@@ -394,10 +377,7 @@
func IsLoggingEnabled(client *gophercloud.ServiceClient, id int) (bool, error) {
var body interface{}
- _, err := client.Request("GET", loggingURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &body,
- OkCodes: []int{200},
- })
+ _, err := client.Get(loggingURL(client, id), &body, nil)
if err != nil {
return false, err
}
@@ -420,39 +400,22 @@
// EnableLogging will enable connection logging for a specified load balancer.
func EnableLogging(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- reqBody := toConnLoggingMap(true)
var res gophercloud.ErrResult
-
- _, res.Err = client.Request("PUT", loggingURL(client, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Put(loggingURL(client, id), toConnLoggingMap(true), nil, nil)
return res
}
// DisableLogging will disable connection logging for a specified load balancer.
func DisableLogging(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- reqBody := toConnLoggingMap(false)
var res gophercloud.ErrResult
-
- _, res.Err = client.Request("PUT", loggingURL(client, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Put(loggingURL(client, id), toConnLoggingMap(false), nil, nil)
return res
}
// GetErrorPage will retrieve the current error page for the load balancer.
func GetErrorPage(client *gophercloud.ServiceClient, id int) ErrorPageResult {
var res ErrorPageResult
-
- _, res.Err = client.Request("GET", errorPageURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
+ _, res.Err = client.Get(errorPageURL(client, id), &res.Body, nil)
return res
}
@@ -464,10 +427,8 @@
type stringMap map[string]string
reqBody := map[string]stringMap{"errorpage": stringMap{"content": html}}
- _, res.Err = client.Request("PUT", errorPageURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- JSONBody: &reqBody,
- OkCodes: []int{200},
+ _, res.Err = client.Put(errorPageURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
})
return res
@@ -476,23 +437,16 @@
// DeleteErrorPage will delete the current error page for the load balancer.
func DeleteErrorPage(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
var res gophercloud.ErrResult
-
- _, res.Err = client.Request("DELETE", errorPageURL(client, id), gophercloud.RequestOpts{
+ _, res.Err = client.Delete(errorPageURL(client, id), &gophercloud.RequestOpts{
OkCodes: []int{200},
})
-
return res
}
// GetStats will retrieve detailed stats related to the load balancer's usage.
func GetStats(client *gophercloud.ServiceClient, id int) StatsResult {
var res StatsResult
-
- _, res.Err = client.Request("GET", statsURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- OkCodes: []int{200},
- })
-
+ _, res.Err = client.Get(statsURL(client, id), &res.Body, nil)
return res
}
@@ -507,10 +461,7 @@
func IsContentCached(client *gophercloud.ServiceClient, id int) (bool, error) {
var body interface{}
- _, err := client.Request("GET", cacheURL(client, id), gophercloud.RequestOpts{
- JSONResponse: &body,
- OkCodes: []int{200},
- })
+ _, err := client.Get(cacheURL(client, id), &body, nil)
if err != nil {
return false, err
}
@@ -533,26 +484,14 @@
// EnableCaching will enable content-caching for the specified load balancer.
func EnableCaching(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- reqBody := toCachingMap(true)
var res gophercloud.ErrResult
-
- _, res.Err = client.Request("PUT", cacheURL(client, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Put(cacheURL(client, id), toCachingMap(true), nil, nil)
return res
}
// DisableCaching will disable content-caching for the specified load balancer.
func DisableCaching(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
- reqBody := toCachingMap(false)
var res gophercloud.ErrResult
-
- _, res.Err = client.Request("PUT", cacheURL(client, id), gophercloud.RequestOpts{
- JSONBody: &reqBody,
- OkCodes: []int{202},
- })
-
+ _, res.Err = client.Put(cacheURL(client, id), toCachingMap(false), nil, nil)
return res
}