From d381903f06b494d5961e895e833f98fd551b995d Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 19 Dec 2011 17:38:24 -0800 Subject: [PATCH] hpcloud cdn support not yet out of beta --- .../HPCloudObjectStorageAsyncClient.java | 8 ++++ .../storage/HPCloudObjectStorageClient.java | 24 ++++++---- .../HPCloudObjectStorageClientLiveTest.java | 44 +++++++------------ 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/providers/hpcloud-object-storage/src/main/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageAsyncClient.java b/providers/hpcloud-object-storage/src/main/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageAsyncClient.java index 63f7864724..0970c6c1c2 100644 --- a/providers/hpcloud-object-storage/src/main/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageAsyncClient.java +++ b/providers/hpcloud-object-storage/src/main/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageAsyncClient.java @@ -52,6 +52,7 @@ 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; /** @@ -73,6 +74,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient /** * @see HPCloudObjectStorageClient#listCDNContainers(ListCDNContainerOptions) */ + @Beta @GET @Consumes(MediaType.APPLICATION_JSON) @QueryParams(keys = "format", values = "json") @@ -83,6 +85,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient /** * @see HPCloudObjectStorageClient#getCDNMetadata(String) */ + @Beta @HEAD @ResponseParser(ParseContainerCDNMetadataFromHeaders.class) @ExceptionParser(ReturnNullOnContainerNotFound.class) @@ -93,6 +96,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient /** * @see HPCloudObjectStorageClient#getCDNMetadata(String) */ + @Beta @HEAD @ResponseParser(ParseContainerMetadataFromHeaders.class) @ExceptionParser(ReturnNullOnContainerNotFound.class) @@ -110,6 +114,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient /** * @see HPCloudObjectStorageClient#enableCDN(String, long) */ + @Beta @PUT @Path("/{container}") @Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True") @@ -121,6 +126,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient /** * @see HPCloudObjectStorageClient#enableCDN(String) */ + @Beta @PUT @Path("/{container}") @Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True") @@ -131,6 +137,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient /** * @see HPCloudObjectStorageClient#updateCDN(String, long) */ + @Beta @POST @Path("/{container}") @ResponseParser(ParseCDNUriFromHeaders.class) @@ -141,6 +148,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient /** * @see HPCloudObjectStorageClient#disableCDN(String) */ + @Beta @PUT @Path("/{container}") @Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "False") diff --git a/providers/hpcloud-object-storage/src/main/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageClient.java b/providers/hpcloud-object-storage/src/main/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageClient.java index d8118a3e4a..069dbfd5fc 100644 --- a/providers/hpcloud-object-storage/src/main/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageClient.java +++ b/providers/hpcloud-object-storage/src/main/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageClient.java @@ -30,36 +30,44 @@ import org.jclouds.hpcloud.object.storage.options.ListCDNContainerOptions; import org.jclouds.openstack.swift.CommonSwiftClient; import org.jclouds.openstack.swift.domain.ContainerMetadata; +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 ExecutionException} as documented in - * {@link ListenableFuture#get()}. + *

+ * All commands return a ListenableFuture of the result. Any exceptions incurred during processing + * will be wrapped in an {@link ExecutionException} as documented in {@link ListenableFuture#get()}. * * @see HPCloudObjectStorageClient - * @see HP Cloud Object Storage API + * @see HP Cloud Object + * Storage API * @author Jeremy Daggett */ @Timeout(duration = 120, timeUnit = TimeUnit.SECONDS) public interface HPCloudObjectStorageClient extends CommonSwiftClient { boolean createContainer(String container, CreateContainerOptions... options); - + + ContainerMetadata getContainerMetadata(String container); + + @Beta Set listCDNContainers(ListCDNContainerOptions... options); + @Beta ContainerCDNMetadata getCDNMetadata(String container); - - ContainerMetadata getContainerMetadata(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-object-storage/src/test/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageClientLiveTest.java b/providers/hpcloud-object-storage/src/test/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageClientLiveTest.java index fe0c129cdf..321591884c 100644 --- a/providers/hpcloud-object-storage/src/test/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageClientLiveTest.java +++ b/providers/hpcloud-object-storage/src/test/java/org/jclouds/hpcloud/object/storage/HPCloudObjectStorageClientLiveTest.java @@ -34,33 +34,21 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@Test(groups = "live") +@Test(groups = "live", testName = "HPCloudObjectStorageClientLiveTest") public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTest { - + @Override public HPCloudObjectStorageClient getApi() { return (HPCloudObjectStorageClient) context.getProviderSpecificContext().getApi(); } - + @Override protected void testGetObjectContentType(SwiftObject getBlob) { assertEquals(getBlob.getInfo().getContentType(), "application/x-www-form-urlencoded"); } - @Test - public void testListCDNContainers() { - // FIXFIX improve - /* - try { - Set cdnMetadataList = getApi().listCDNContainers(); - System.err.println(cdnMetadataList); - } catch (Exception e) { - e.printStackTrace(); - } - */ - } - - @Test + // CDN service due to go live Q1 2012 + @Test(enabled = false) public void testCDNOperations() throws Exception { final long minimumTTL = 60 * 60; // The minimum TTL is 1 hour @@ -72,7 +60,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes getApi().disableCDN(containerNameWithCDN); getApi().disableCDN(containerNameWithoutCDN); } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); } ContainerCDNMetadata cdnMetadata = null; @@ -86,8 +74,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes assertTrue(cdnMetadata.isCDNEnabled()); assertEquals(cdnMetadata.getCDNUri(), cdnUri); - - + cdnMetadata = getApi().getCDNMetadata(containerNameWithoutCDN); assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN + " should not have metadata"; @@ -103,14 +90,13 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes final long initialTTL = cdnMetadata.getTTL(); assertTrue(cdnMetadataList.contains(new ContainerCDNMetadata(containerNameWithCDN, true, initialTTL, cdnUri))); - /* Test listing with options FIXFIX - cdnMetadataList = getApi().listCDNContainers(ListCDNContainerOptions.Builder.enabledOnly()); - assertTrue(Iterables.all(cdnMetadataList, new Predicate() { - public boolean apply(ContainerCDNMetadata cdnMetadata) { - return cdnMetadata.isCDNEnabled(); - } - })); - */ + /* + * Test listing with options FIXFIX cdnMetadataList = + * getApi().listCDNContainers(ListCDNContainerOptions.Builder.enabledOnly()); + * assertTrue(Iterables.all(cdnMetadataList, new Predicate() { public + * boolean apply(ContainerCDNMetadata cdnMetadata) { return cdnMetadata.isCDNEnabled(); } + * })); + */ cdnMetadataList = getApi().listCDNContainers( ListCDNContainerOptions.Builder.afterMarker( @@ -149,7 +135,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN); assertEquals(cdnMetadata.isCDNEnabled(), false); } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); } finally { recycleContainer(containerNameWithCDN); recycleContainer(containerNameWithoutCDN);