diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersApi.java index 71924ba0a4..9f93d688ae 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersApi.java @@ -27,6 +27,7 @@ import org.jclouds.location.Zone; import org.jclouds.location.functions.ZoneToEndpoint; import org.jclouds.rackspace.cloudloadbalancers.features.AccessRuleApi; import org.jclouds.rackspace.cloudloadbalancers.features.ConnectionApi; +import org.jclouds.rackspace.cloudloadbalancers.features.ContentCachingApi; import org.jclouds.rackspace.cloudloadbalancers.features.HealthMonitorApi; import org.jclouds.rackspace.cloudloadbalancers.features.LoadBalancerApi; import org.jclouds.rackspace.cloudloadbalancers.features.NodeApi; @@ -106,4 +107,12 @@ public interface CloudLoadBalancersApi { @Path("/loadbalancers/{lbId}") SessionPersistenceApi getSessionPersistenceApiForZoneAndLoadBalancer( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone, @PathParam("lbId") int lbId); + + /** + * Provides synchronous access to Content Caching features. + */ + @Delegate + @Path("/loadbalancers/{lbId}") + ContentCachingApi getContentCachingApiForZoneAndLoadBalancer( + @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone, @PathParam("lbId") int lbId); } diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersAsyncApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersAsyncApi.java index 48bd7f9a44..6a11704833 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersAsyncApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersAsyncApi.java @@ -28,6 +28,7 @@ import org.jclouds.location.Zone; import org.jclouds.location.functions.ZoneToEndpoint; import org.jclouds.rackspace.cloudloadbalancers.features.AccessRuleAsyncApi; import org.jclouds.rackspace.cloudloadbalancers.features.ConnectionAsyncApi; +import org.jclouds.rackspace.cloudloadbalancers.features.ContentCachingAsyncApi; import org.jclouds.rackspace.cloudloadbalancers.features.HealthMonitorAsyncApi; import org.jclouds.rackspace.cloudloadbalancers.features.LoadBalancerAsyncApi; import org.jclouds.rackspace.cloudloadbalancers.features.NodeAsyncApi; @@ -107,4 +108,12 @@ public interface CloudLoadBalancersAsyncApi { @Path("/loadbalancers/{lbId}") SessionPersistenceAsyncApi getSessionPersistenceApiForZoneAndLoadBalancer( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone, @PathParam("lbId") int lbId); + + /** + * Provides asynchronous access to Content Caching features. + */ + @Delegate + @Path("/loadbalancers/{lbId}") + ContentCachingAsyncApi getContentCachingApiForZoneAndLoadBalancer( + @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone, @PathParam("lbId") int lbId); } diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java index e946c2e926..2f283213fc 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java @@ -32,6 +32,8 @@ import org.jclouds.rackspace.cloudloadbalancers.features.AccessRuleApi; import org.jclouds.rackspace.cloudloadbalancers.features.AccessRuleAsyncApi; import org.jclouds.rackspace.cloudloadbalancers.features.ConnectionApi; import org.jclouds.rackspace.cloudloadbalancers.features.ConnectionAsyncApi; +import org.jclouds.rackspace.cloudloadbalancers.features.ContentCachingApi; +import org.jclouds.rackspace.cloudloadbalancers.features.ContentCachingAsyncApi; import org.jclouds.rackspace.cloudloadbalancers.features.HealthMonitorApi; import org.jclouds.rackspace.cloudloadbalancers.features.HealthMonitorAsyncApi; import org.jclouds.rackspace.cloudloadbalancers.features.LoadBalancerAsyncApi; @@ -67,6 +69,7 @@ public class CloudLoadBalancersRestClientModule extends .put(ConnectionApi.class, ConnectionAsyncApi.class) .put(HealthMonitorApi.class, HealthMonitorAsyncApi.class) .put(SessionPersistenceApi.class, SessionPersistenceAsyncApi.class) + .put(ContentCachingApi.class, ContentCachingAsyncApi.class) .build(); public CloudLoadBalancersRestClientModule() { diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/domain/HealthMonitor.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/domain/HealthMonitor.java index 8da0c3287c..d42a94bc90 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/domain/HealthMonitor.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/domain/HealthMonitor.java @@ -143,8 +143,8 @@ public class HealthMonitor { protected ToStringHelper string() { return Objects.toStringHelper(this).omitNullValues().add("type", type).add("delay", delay) .add("timeout", timeout).add("attemptsBeforeDeactivation", attemptsBeforeDeactivation) - .add("bodyRegex", bodyRegex).add("statusRegex", statusRegex).add("path", path) - .add("hostHeader", hostHeader); + .add("bodyRegex", bodyRegex.orNull()).add("statusRegex", statusRegex.orNull()).add("path", path.orNull()) + .add("hostHeader", hostHeader.orNull()); } @Override diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/features/ContentCachingApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/features/ContentCachingApi.java new file mode 100644 index 0000000000..b7072b39c4 --- /dev/null +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/features/ContentCachingApi.java @@ -0,0 +1,47 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.rackspace.cloudloadbalancers.features; + +/** + * When content caching is enabled, recently-accessed files are stored on the load balancer for easy retrieval by web + * clients. Content caching improves the performance of high traffic web sites by temporarily storing data that was + * recently accessed. While it's cached, requests for that data will be served by the load balancer, which in turn + * reduces load off the back end nodes. The result is improved response times for those requests and less load on the + * web server. + *
+ * + * @see ContentCachingAsyncApi + * @author Everett Toews + */ +public interface ContentCachingApi { + /** + * Determine if the load balancer is content caching. + */ + boolean isContentCaching(); + + /** + * Enable content caching. + */ + void enable(); + + /** + * Disable content caching. + */ + void disable(); +} \ No newline at end of file diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/features/ContentCachingAsyncApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/features/ContentCachingAsyncApi.java new file mode 100644 index 0000000000..5e1087fc4a --- /dev/null +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/features/ContentCachingAsyncApi.java @@ -0,0 +1,84 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.rackspace.cloudloadbalancers.features; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.rackspace.cloudloadbalancers.functions.ParseNestedBoolean; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to Rackspace Cloud Load Balancers via their REST API. + * + * + * @see ContentCachingAsyncApi + * @author Everett Toews + */ +@RequestFilters(AuthenticateRequest.class) +public interface ContentCachingAsyncApi { + + /** + * @see ContentCachingApi#isContentCaching() + */ + @Named("contentcaching:state") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @ResponseParser(ParseNestedBoolean.class) + @Fallback(FalseOnNotFoundOr404.class) + @Path("/contentcaching") + ListenableFuture