hpcloud cdn support not yet out of beta

This commit is contained in:
Adrian Cole 2011-12-19 17:38:24 -08:00
parent d6e8404233
commit d381903f06
3 changed files with 39 additions and 37 deletions

View File

@ -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")

View File

@ -30,17 +30,19 @@ 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.
*
* <p/>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()}.
* <p/>
* 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 <a href="https://manage.hpcloud.com/pages/build/docs/object-storage/api">HP Cloud Object Storage API</a>
* @see <a href="https://manage.hpcloud.com/pages/build/docs/object-storage/api">HP Cloud Object
* Storage API</a>
* @author Jeremy Daggett
*/
@Timeout(duration = 120, timeUnit = TimeUnit.SECONDS)
@ -48,18 +50,24 @@ public interface HPCloudObjectStorageClient extends CommonSwiftClient {
boolean createContainer(String container, CreateContainerOptions... options);
Set<ContainerCDNMetadata> listCDNContainers(ListCDNContainerOptions... options);
ContainerCDNMetadata getCDNMetadata(String container);
ContainerMetadata getContainerMetadata(String container);
@Beta
Set<ContainerCDNMetadata> 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);
}

View File

@ -34,7 +34,7 @@ import org.testng.annotations.Test;
*
* @author Adrian Cole
*/
@Test(groups = "live")
@Test(groups = "live", testName = "HPCloudObjectStorageClientLiveTest")
public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTest<HPCloudObjectStorageClient> {
@Override
@ -47,20 +47,8 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
assertEquals(getBlob.getInfo().getContentType(), "application/x-www-form-urlencoded");
}
@Test
public void testListCDNContainers() {
// FIXFIX improve
/*
try {
Set<ContainerCDNMetadata> 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;
@ -87,7 +75,6 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
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<ContainerCDNMetadata>() {
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<ContainerCDNMetadata>() { 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);