Adding content caching and adding missing tests
diff --git a/rackspace/lb/v1/lbs/requests.go b/rackspace/lb/v1/lbs/requests.go
index 81e7fdc..2d80062 100644
--- a/rackspace/lb/v1/lbs/requests.go
+++ b/rackspace/lb/v1/lbs/requests.go
@@ -421,7 +421,7 @@
func toConnLoggingMap(state bool) map[string]map[string]bool {
return map[string]map[string]bool{
- "connectionLogging": map[string]bool{"enabled": false},
+ "connectionLogging": map[string]bool{"enabled": state},
}
}
@@ -430,7 +430,7 @@
reqBody := toConnLoggingMap(true)
var res gophercloud.ErrResult
- _, res.Err = perigee.Request("GET", loggingURL(client, id), perigee.Options{
+ _, res.Err = perigee.Request("PUT", loggingURL(client, id), perigee.Options{
MoreHeaders: client.AuthenticatedHeaders(),
ReqBody: &reqBody,
OkCodes: []int{200},
@@ -444,7 +444,7 @@
reqBody := toConnLoggingMap(false)
var res gophercloud.ErrResult
- _, res.Err = perigee.Request("GET", loggingURL(client, id), perigee.Options{
+ _, res.Err = perigee.Request("PUT", loggingURL(client, id), perigee.Options{
MoreHeaders: client.AuthenticatedHeaders(),
ReqBody: &reqBody,
OkCodes: []int{200},
@@ -508,3 +508,57 @@
return res
}
+
+func IsContentCached(client *gophercloud.ServiceClient, id int) (bool, error) {
+ var body interface{}
+
+ _, err := perigee.Request("GET", cacheURL(client, id), perigee.Options{
+ MoreHeaders: client.AuthenticatedHeaders(),
+ Results: &body,
+ OkCodes: []int{200},
+ })
+ if err != nil {
+ return false, err
+ }
+
+ var resp struct {
+ CC struct {
+ Enabled bool `mapstructure:"enabled"`
+ } `mapstructure:"contentCaching"`
+ }
+
+ err = mapstructure.Decode(body, &resp)
+ return resp.CC.Enabled, err
+}
+
+func toCachingMap(state bool) map[string]map[string]bool {
+ return map[string]map[string]bool{
+ "contentCaching": map[string]bool{"enabled": state},
+ }
+}
+
+func EnableCaching(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
+ reqBody := toCachingMap(true)
+ var res gophercloud.ErrResult
+
+ _, res.Err = perigee.Request("PUT", cacheURL(client, id), perigee.Options{
+ MoreHeaders: client.AuthenticatedHeaders(),
+ ReqBody: &reqBody,
+ OkCodes: []int{200},
+ })
+
+ return res
+}
+
+func DisableCaching(client *gophercloud.ServiceClient, id int) gophercloud.ErrResult {
+ reqBody := toCachingMap(false)
+ var res gophercloud.ErrResult
+
+ _, res.Err = perigee.Request("PUT", cacheURL(client, id), perigee.Options{
+ MoreHeaders: client.AuthenticatedHeaders(),
+ ReqBody: &reqBody,
+ OkCodes: []int{200},
+ })
+
+ return res
+}