diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageAsyncClient.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageAsyncClient.java
index 21912de7ea..ab7df1d307 100644
--- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageAsyncClient.java
+++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageAsyncClient.java
@@ -18,163 +18,96 @@
*/
package org.jclouds.hpcloud.objectstorage;
-import java.net.URI;
import java.util.Set;
-import java.util.concurrent.ExecutionException;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.blobstore.functions.ReturnNullOnContainerNotFound;
-import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata;
-import org.jclouds.hpcloud.objectstorage.functions.ParseCDNUriFromHeaders;
-import org.jclouds.hpcloud.objectstorage.functions.ParseContainerCDNMetadataFromHeaders;
+import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNAsyncClient;
import org.jclouds.hpcloud.objectstorage.functions.ParseContainerMetadataFromHeaders;
import org.jclouds.hpcloud.objectstorage.options.CreateContainerOptions;
-import org.jclouds.hpcloud.objectstorage.options.ListCDNContainerOptions;
-import org.jclouds.hpcloud.objectstorage.reference.HPCloudObjectStorageHeaders;
-import org.jclouds.hpcloud.services.HPExtensionCDN;
import org.jclouds.openstack.filters.AuthenticateRequest;
-import org.jclouds.openstack.services.ObjectStore;
import org.jclouds.openstack.swift.CommonSwiftAsyncClient;
import org.jclouds.openstack.swift.Storage;
import org.jclouds.openstack.swift.domain.ContainerMetadata;
import org.jclouds.openstack.swift.functions.ReturnTrueOn404FalseOn409;
import org.jclouds.openstack.swift.options.ListContainerOptions;
+import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.ExceptionParser;
-import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import com.google.common.annotations.Beta;
+import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to HP Cloud Object Storage via the REST API.
*
- *
All commands return a ListenableFuture of the result. Any exceptions incurred
- * during processing will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in
+ *
+ * All commands return a ListenableFuture of the result. Any exceptions incurred during processing
+ * will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in
* {@link ListenableFuture#get()}.
*
* @see HPCloudObjectStorageClient
- * @see HP Cloud Object Storage API
+ * @see HP Cloud Object
+ * Storage API
* @author Jeremy Daggett
*/
@SkipEncoding('/')
@RequestFilters(AuthenticateRequest.class)
-@Endpoint(ObjectStore.class)
+@Endpoint(Storage.class)
public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient {
/**
* @see HPCloudObjectStorageClient#getCDNMetadata(String)
- */
+ */
@Beta
@HEAD
@ResponseParser(ParseContainerMetadataFromHeaders.class)
@ExceptionParser(ReturnNullOnContainerNotFound.class)
@Path("/{container}")
ListenableFuture getContainerMetadata(@PathParam("container") String container);
-
+
/**
* @see HPCloudObjectStorageClient#createContainer
*/
@PUT
@Path("/{container}")
ListenableFuture createContainer(@PathParam("container") String container,
- CreateContainerOptions... options);
-
- /**
- * @see org.jclouds.openstack.swift.CommonSwiftClient#listContainers
- */
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @QueryParams(keys = "format", values = "json")
- @Path("/")
- ListenableFuture extends Set> listContainers(ListContainerOptions... options);
-
- /**
- * @see org.jclouds.openstack.swift.CommonSwiftClient#deleteContainerIfEmpty
- */
- @DELETE
- @ExceptionParser(ReturnTrueOn404FalseOn409.class)
- @Path("/{container}")
- ListenableFuture deleteContainerIfEmpty(@PathParam("container") String container);
+ CreateContainerOptions... options);
/**
- * @see HPCloudObjectStorageClient#listCDNContainers(ListCDNContainerOptions...)
+ * @see org.jclouds.openstack.swift.CommonSwiftClient#listContainers
*/
- @Beta
@GET
@Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "format", values = "json")
@Path("/")
- @Endpoint(HPExtensionCDN.class)
- ListenableFuture extends Set> listCDNContainers(ListCDNContainerOptions... options);
-
- /**
- * @see HPCloudObjectStorageClient#getCDNMetadata(String)
- */
- @Beta
- @HEAD
- @ResponseParser(ParseContainerCDNMetadataFromHeaders.class)
- @ExceptionParser(ReturnNullOnContainerNotFound.class)
- @Path("/{container}")
- @Endpoint(HPExtensionCDN.class)
- ListenableFuture getCDNMetadata(@PathParam("container") String container);
+ ListenableFuture extends Set> listContainers(ListContainerOptions... options);
/**
- * @see HPCloudObjectStorageClient#enableCDN(String, long)
+ * @see org.jclouds.openstack.swift.CommonSwiftClient#deleteContainerIfEmpty
*/
- @Beta
- @PUT
+ @DELETE
+ @ExceptionParser(ReturnTrueOn404FalseOn409.class)
@Path("/{container}")
- @Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
- @ResponseParser(ParseCDNUriFromHeaders.class)
- @Endpoint(HPExtensionCDN.class)
- ListenableFuture enableCDN(@PathParam("container") String container,
- @HeaderParam(HPCloudObjectStorageHeaders.CDN_TTL) long ttl);
+ ListenableFuture deleteContainerIfEmpty(@PathParam("container") String container);
/**
- * @see HPCloudObjectStorageClient#enableCDN(String)
+ * Provides synchronous access to CDN features.
*/
- @Beta
- @PUT
- @Path("/{container}")
- @Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
- @ResponseParser(ParseCDNUriFromHeaders.class)
- @Endpoint(HPExtensionCDN.class)
- ListenableFuture enableCDN(@PathParam("container") String container);
-
- /**
- * @see HPCloudObjectStorageClient#updateCDN(String, long)
- */
- @Beta
- @POST
- @Path("/{container}")
- @ResponseParser(ParseCDNUriFromHeaders.class)
- @Endpoint(HPExtensionCDN.class)
- ListenableFuture updateCDN(@PathParam("container") String container,
- @HeaderParam(HPCloudObjectStorageHeaders.CDN_TTL) long ttl);
-
- /**
- * @see HPCloudObjectStorageClient#disableCDN(String)
- */
- @Beta
- @PUT
- @Path("/{container}")
- @Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "False")
- @Endpoint(HPExtensionCDN.class)
- ListenableFuture disableCDN(@PathParam("container") String container);
+ @Delegate
+ Optional getCDNExtension();
}
diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClient.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClient.java
index ce9dbb85d9..5f9de9e8e5 100644
--- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClient.java
+++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClient.java
@@ -18,19 +18,16 @@
*/
package org.jclouds.hpcloud.objectstorage;
-import java.net.URI;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
-import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata;
+import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient;
import org.jclouds.hpcloud.objectstorage.options.CreateContainerOptions;
-import org.jclouds.hpcloud.objectstorage.options.ListCDNContainerOptions;
import org.jclouds.openstack.swift.CommonSwiftClient;
import org.jclouds.openstack.swift.domain.ContainerMetadata;
+import org.jclouds.rest.annotations.Delegate;
-import com.google.common.annotations.Beta;
+import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
/**
@@ -38,7 +35,8 @@ import com.google.common.util.concurrent.ListenableFuture;
*
*
* All commands return a ListenableFuture of the result. Any exceptions incurred during processing
- * will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in {@link ListenableFuture#get()}.
+ * will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in
+ * {@link ListenableFuture#get()}.
*
* @see org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient
* @see HP Cloud Object
@@ -52,22 +50,9 @@ public interface HPCloudObjectStorageClient extends CommonSwiftClient {
ContainerMetadata getContainerMetadata(String container);
- @Beta
- Set listCDNContainers(ListCDNContainerOptions... options);
-
- @Beta
- ContainerCDNMetadata getCDNMetadata(String container);
-
- @Beta
- URI enableCDN(String container, long ttl);
-
- @Beta
- URI enableCDN(String container);
-
- @Beta
- URI updateCDN(String container, long ttl);
-
- @Beta
- boolean disableCDN(String container);
-
+ /**
+ * Provides synchronous access to CDN features.
+ */
+ @Delegate
+ Optional getCDNExtension();
}
diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java
index e0a6cacc6d..e05119ed8c 100644
--- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java
+++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java
@@ -33,7 +33,6 @@ import org.jclouds.collect.Memoized;
import org.jclouds.domain.Location;
import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient;
import org.jclouds.hpcloud.objectstorage.blobstore.functions.EnableCDNAndCache;
-import org.jclouds.openstack.swift.CommonSwiftClient;
import org.jclouds.openstack.swift.blobstore.SwiftBlobStore;
import org.jclouds.openstack.swift.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions;
import org.jclouds.openstack.swift.blobstore.functions.BlobToObject;
diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/config/HPCloudObjectStorageBlobStoreContextModule.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/config/HPCloudObjectStorageBlobStoreContextModule.java
index 3beaf54ad4..158f58c9b5 100644
--- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/config/HPCloudObjectStorageBlobStoreContextModule.java
+++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/config/HPCloudObjectStorageBlobStoreContextModule.java
@@ -18,6 +18,8 @@
*/
package org.jclouds.hpcloud.objectstorage.blobstore.config;
+import static com.google.common.base.Preconditions.checkArgument;
+
import java.net.URI;
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
@@ -31,6 +33,7 @@ import org.jclouds.hpcloud.objectstorage.blobstore.HPCloudObjectStorageAsyncBlob
import org.jclouds.hpcloud.objectstorage.blobstore.HPCloudObjectStorageBlobStore;
import org.jclouds.hpcloud.objectstorage.blobstore.functions.HPCloudObjectStorageObjectToBlobMetadata;
import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata;
+import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient;
import org.jclouds.http.HttpResponseException;
import org.jclouds.openstack.swift.blobstore.SwiftAsyncBlobStore;
import org.jclouds.openstack.swift.blobstore.SwiftBlobStore;
@@ -38,6 +41,7 @@ import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule;
import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata;
import com.google.common.annotations.Beta;
+import com.google.common.base.Optional;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@@ -66,8 +70,10 @@ public class HPCloudObjectStorageBlobStoreContextModule extends SwiftBlobStoreCo
@Override
public URI load(String container) {
+ Optional cdnExension = client.getCDNExtension();
+ checkArgument(cdnExension.isPresent(), "CDN is required, but the extension is not available!");
try {
- ContainerCDNMetadata md = client.getCDNMetadata(container);
+ ContainerCDNMetadata md = cdnExension.get().getCDNMetadata(container);
return md != null ? md.getCDNUri() : null;
} catch (HttpResponseException e) {
// TODO: this is due to beta status
diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/functions/EnableCDNAndCache.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/functions/EnableCDNAndCache.java
index 1453332078..3cd6d767c9 100644
--- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/functions/EnableCDNAndCache.java
+++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/functions/EnableCDNAndCache.java
@@ -18,14 +18,18 @@
*/
package org.jclouds.hpcloud.objectstorage.blobstore.functions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import java.net.URI;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient;
+import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient;
import com.google.common.base.Function;
+import com.google.common.base.Optional;
import com.google.common.cache.LoadingCache;
/**
@@ -45,7 +49,9 @@ public class EnableCDNAndCache implements Function {
@Override
public URI apply(String input) {
- URI uri = sync.enableCDN(input);
+ Optional cdnExension = sync.getCDNExtension();
+ checkArgument(cdnExension.isPresent(), "CDN is required, but the extension is not available!");
+ URI uri = cdnExension.get().enableCDN(input);
cdnContainer.put(input, uri);
return uri;
}
diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java
index 3c72c808e8..1a0304bd2e 100644
--- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java
+++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java
@@ -21,12 +21,14 @@ package org.jclouds.hpcloud.objectstorage.config;
import static org.jclouds.util.Suppliers2.getLastValueInMap;
import java.net.URI;
+import java.util.Map;
import javax.inject.Singleton;
-import com.google.inject.Scopes;
import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageAsyncClient;
import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient;
+import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNAsyncClient;
+import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient;
import org.jclouds.hpcloud.services.HPExtensionCDN;
import org.jclouds.hpcloud.services.HPExtensionServiceType;
import org.jclouds.http.HttpErrorHandler;
@@ -40,10 +42,10 @@ import org.jclouds.location.suppliers.ImplicitLocationSupplier;
import org.jclouds.location.suppliers.RegionIdToURISupplier;
import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
-import org.jclouds.openstack.services.ObjectStore;
import org.jclouds.openstack.services.ServiceType;
import org.jclouds.openstack.swift.CommonSwiftAsyncClient;
import org.jclouds.openstack.swift.CommonSwiftClient;
+import org.jclouds.openstack.swift.Storage;
import org.jclouds.openstack.swift.config.SwiftObjectModule;
import org.jclouds.openstack.swift.handlers.ParseSwiftErrorFromHttpResponse;
import org.jclouds.rest.ConfiguresRestClient;
@@ -51,7 +53,9 @@ import org.jclouds.rest.annotations.ApiVersion;
import org.jclouds.rest.config.RestClientModule;
import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
import com.google.inject.Provides;
+import com.google.inject.Scopes;
/**
*
@@ -61,9 +65,11 @@ import com.google.inject.Provides;
@RequiresHttp
public class HPCloudObjectStorageRestClientModule extends
RestClientModule {
+ public static final Map, Class>> DELEGATE_MAP = ImmutableMap., Class>> builder().put(
+ HPCloudCDNClient.class, HPCloudCDNAsyncClient.class).build();
public HPCloudObjectStorageRestClientModule() {
- super(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class);
+ super(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class, DELEGATE_MAP);
}
protected void configure() {
@@ -72,13 +78,13 @@ public class HPCloudObjectStorageRestClientModule extends
super.configure();
}
- @Override
- protected void installLocations() {
- super.installLocations();
- // TODO: select this from KeystoneProperties.VERSION;
- install(KeystoneAuthenticationModule.forRegions());
- bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON);
- }
+ @Override
+ protected void installLocations() {
+ super.installLocations();
+ // TODO: select this from KeystoneProperties.VERSION;
+ install(KeystoneAuthenticationModule.forRegions());
+ bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON);
+ }
@Override
protected void bindErrorHandlers() {
@@ -98,7 +104,7 @@ public class HPCloudObjectStorageRestClientModule extends
CommonSwiftAsyncClient provideCommonSwiftClient(HPCloudObjectStorageAsyncClient in) {
return in;
}
-
+
@Provides
@Singleton
@HPExtensionCDN
@@ -108,7 +114,7 @@ public class HPCloudObjectStorageRestClientModule extends
@Provides
@Singleton
- @ObjectStore
+ @Storage
protected Supplier provideStorageUrl(RegionIdToURISupplier.Factory factory, @ApiVersion String apiVersion) {
return getLastValueInMap(factory.createForApiTypeAndVersion(ServiceType.OBJECT_STORE, apiVersion));
}
diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/extensions/HPCloudCDNAsyncClient.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/extensions/HPCloudCDNAsyncClient.java
new file mode 100644
index 0000000000..c5d3926cb2
--- /dev/null
+++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/extensions/HPCloudCDNAsyncClient.java
@@ -0,0 +1,130 @@
+/**
+ * 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.hpcloud.objectstorage.extensions;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HEAD;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.blobstore.functions.ReturnNullOnContainerNotFound;
+import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient;
+import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata;
+import org.jclouds.hpcloud.objectstorage.functions.ParseCDNUriFromHeaders;
+import org.jclouds.hpcloud.objectstorage.functions.ParseContainerCDNMetadataFromHeaders;
+import org.jclouds.hpcloud.objectstorage.options.ListCDNContainerOptions;
+import org.jclouds.hpcloud.objectstorage.reference.HPCloudObjectStorageHeaders;
+import org.jclouds.hpcloud.services.HPExtensionCDN;
+import org.jclouds.openstack.filters.AuthenticateRequest;
+import org.jclouds.rest.annotations.Endpoint;
+import org.jclouds.rest.annotations.ExceptionParser;
+import org.jclouds.rest.annotations.Headers;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to HP Cloud Object Storage via the REST API.
+ *
+ * All commands return a ListenableFuture of the result. Any exceptions incurred
+ * during processing will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in
+ * {@link ListenableFuture#get()}.
+ *
+ * @see HPCloudObjectStorageClient
+ * @see HP Cloud Object Storage API
+ * @author Jeremy Daggett
+ */
+@SkipEncoding('/')
+@RequestFilters(AuthenticateRequest.class)
+@Endpoint(HPExtensionCDN.class)
+public interface HPCloudCDNAsyncClient {
+
+ /**
+ * @see HPCloudObjectStorageClient#listCDNContainers(ListCDNContainerOptions...)
+ */
+ @Beta
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @QueryParams(keys = "format", values = "json")
+ @Path("/")
+ ListenableFuture extends Set> listCDNContainers(ListCDNContainerOptions... options);
+
+ /**
+ * @see HPCloudObjectStorageClient#getCDNMetadata(String)
+ */
+ @Beta
+ @HEAD
+ @ResponseParser(ParseContainerCDNMetadataFromHeaders.class)
+ @ExceptionParser(ReturnNullOnContainerNotFound.class)
+ @Path("/{container}")
+ ListenableFuture getCDNMetadata(@PathParam("container") String container);
+
+ /**
+ * @see HPCloudObjectStorageClient#enableCDN(String, long)
+ */
+ @Beta
+ @PUT
+ @Path("/{container}")
+ @Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
+ @ResponseParser(ParseCDNUriFromHeaders.class)
+ ListenableFuture enableCDN(@PathParam("container") String container,
+ @HeaderParam(HPCloudObjectStorageHeaders.CDN_TTL) long ttl);
+
+ /**
+ * @see HPCloudObjectStorageClient#enableCDN(String)
+ */
+ @Beta
+ @PUT
+ @Path("/{container}")
+ @Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
+ @ResponseParser(ParseCDNUriFromHeaders.class)
+ ListenableFuture enableCDN(@PathParam("container") String container);
+
+ /**
+ * @see HPCloudObjectStorageClient#updateCDN(String, long)
+ */
+ @Beta
+ @POST
+ @Path("/{container}")
+ @ResponseParser(ParseCDNUriFromHeaders.class)
+ ListenableFuture updateCDN(@PathParam("container") String container,
+ @HeaderParam(HPCloudObjectStorageHeaders.CDN_TTL) long ttl);
+
+ /**
+ * @see HPCloudObjectStorageClient#disableCDN(String)
+ */
+ @Beta
+ @PUT
+ @Path("/{container}")
+ @Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "False")
+ ListenableFuture disableCDN(@PathParam("container") String container);
+
+}
diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/extensions/HPCloudCDNClient.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/extensions/HPCloudCDNClient.java
new file mode 100644
index 0000000000..75798333d6
--- /dev/null
+++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/extensions/HPCloudCDNClient.java
@@ -0,0 +1,65 @@
+/**
+ * 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.hpcloud.objectstorage.extensions;
+
+import java.net.URI;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.jclouds.concurrent.Timeout;
+import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata;
+import org.jclouds.hpcloud.objectstorage.options.ListCDNContainerOptions;
+
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides synchronous access to HP Cloud Object Storage via the REST API.
+ *
+ *
+ * All commands return a ListenableFuture of the result. Any exceptions incurred during processing
+ * will be wrapped in an {@link java.util.concurrent.ExecutionException} as documented in {@link ListenableFuture#get()}.
+ *
+ * @see org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient
+ * @see HP Cloud Object
+ * Storage API
+ * @author Jeremy Daggett
+ */
+@Timeout(duration = 120, timeUnit = TimeUnit.SECONDS)
+public interface HPCloudCDNClient {
+
+ @Beta
+ Set listCDNContainers(ListCDNContainerOptions... options);
+
+ @Beta
+ ContainerCDNMetadata getCDNMetadata(String container);
+
+ @Beta
+ URI enableCDN(String container, long ttl);
+
+ @Beta
+ URI enableCDN(String container);
+
+ @Beta
+ URI updateCDN(String container, long ttl);
+
+ @Beta
+ boolean disableCDN(String container);
+
+}
diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java
index 39f5ee1b98..7deac56ea9 100644
--- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java
+++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java
@@ -57,34 +57,34 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
final String containerNameWithoutCDN = getContainerName();
try {
try {
- getApi().disableCDN(containerNameWithCDN);
- getApi().disableCDN(containerNameWithoutCDN);
+ getApi().getCDNExtension().get().disableCDN(containerNameWithCDN);
+ getApi().getCDNExtension().get().disableCDN(containerNameWithoutCDN);
} catch (Exception e) {
e.printStackTrace();
}
ContainerCDNMetadata cdnMetadata = null;
// Enable CDN with PUT for one container
- final URI cdnUri = getApi().enableCDN(containerNameWithCDN);
+ final URI cdnUri = getApi().getCDNExtension().get().enableCDN(containerNameWithCDN);
assertTrue(cdnUri != null);
// Confirm CDN is enabled via HEAD request and has default TTL
- cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
+ cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithCDN);
assertTrue(cdnMetadata.isCDNEnabled());
assertEquals(cdnMetadata.getCDNUri(), cdnUri);
- cdnMetadata = getApi().getCDNMetadata(containerNameWithoutCDN);
+ cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithoutCDN);
assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
+ " should not have metadata";
- assert getApi().getCDNMetadata("DoesNotExist") == null;
+ assert getApi().getCDNExtension().get().getCDNMetadata("DoesNotExist") == null;
// List CDN metadata for containers, and ensure all CDN info is
// available for enabled
// container
- Set cdnMetadataList = getApi().listCDNContainers();
+ Set cdnMetadataList = getApi().getCDNExtension().get().listCDNContainers();
assertTrue(cdnMetadataList.size() >= 1);
final long initialTTL = cdnMetadata.getTTL();
@@ -98,7 +98,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
* }));
*/
- cdnMetadataList = getApi().listCDNContainers(
+ cdnMetadataList = getApi().getCDNExtension().get().listCDNContainers(
ListCDNContainerOptions.Builder.afterMarker(
containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
assertEquals(cdnMetadataList.size(), 1);
@@ -106,9 +106,9 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
// Enable CDN with PUT for the same container, this time with a custom
// TTL
long ttl = 4000;
- getApi().enableCDN(containerNameWithCDN, ttl);
+ getApi().getCDNExtension().get().enableCDN(containerNameWithCDN, ttl);
- cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
+ cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithCDN);
assertTrue(cdnMetadata.isCDNEnabled());
@@ -116,23 +116,23 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
// Check POST by updating TTL settings
ttl = minimumTTL;
- getApi().updateCDN(containerNameWithCDN, minimumTTL);
+ getApi().getCDNExtension().get().updateCDN(containerNameWithCDN, minimumTTL);
- cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
+ cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithCDN);
assertTrue(cdnMetadata.isCDNEnabled());
assertEquals(cdnMetadata.getTTL(), minimumTTL);
// Confirm that minimum allowed value for TTL is 3600, lower values are
// ignored.
- getApi().updateCDN(containerNameWithCDN, 3599L);
- cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
+ getApi().getCDNExtension().get().updateCDN(containerNameWithCDN, 3599L);
+ cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithCDN);
assertEquals(cdnMetadata.getTTL(), 3599L);
// Disable CDN with POST
- assertTrue(getApi().disableCDN(containerNameWithCDN));
+ assertTrue(getApi().getCDNExtension().get().disableCDN(containerNameWithCDN));
- cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
+ cdnMetadata = getApi().getCDNExtension().get().getCDNMetadata(containerNameWithCDN);
assertEquals(cdnMetadata.isCDNEnabled(), false);
} catch (Exception e) {
e.printStackTrace();
diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java
index 4ed6ddc274..2c7bde84d1 100644
--- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java
+++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java
@@ -1,12 +1,13 @@
package org.jclouds.hpcloud.objectstorage.internal;
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
import org.jclouds.blobstore.BlobStore;
-import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextFactory;
import org.jclouds.domain.Location;
import org.jclouds.http.HttpRequest;
@@ -15,13 +16,10 @@ import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.BaseRestClientExpectTest;
import org.testng.annotations.Test;
-import java.net.URI;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
@Test(groups = "unit", testName = "HPCloudObjectStorageExpectTest")
public class HPCloudObjectStorageExpectTest extends BaseRestClientExpectTest {