mirror of https://github.com/apache/jclouds.git
hpcloud cdn support not yet out of beta
This commit is contained in:
parent
d6e8404233
commit
d381903f06
|
@ -52,6 +52,7 @@ import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.ResponseParser;
|
import org.jclouds.rest.annotations.ResponseParser;
|
||||||
import org.jclouds.rest.annotations.SkipEncoding;
|
import org.jclouds.rest.annotations.SkipEncoding;
|
||||||
|
|
||||||
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,6 +74,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient
|
||||||
/**
|
/**
|
||||||
* @see HPCloudObjectStorageClient#listCDNContainers(ListCDNContainerOptions)
|
* @see HPCloudObjectStorageClient#listCDNContainers(ListCDNContainerOptions)
|
||||||
*/
|
*/
|
||||||
|
@Beta
|
||||||
@GET
|
@GET
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@QueryParams(keys = "format", values = "json")
|
@QueryParams(keys = "format", values = "json")
|
||||||
|
@ -83,6 +85,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient
|
||||||
/**
|
/**
|
||||||
* @see HPCloudObjectStorageClient#getCDNMetadata(String)
|
* @see HPCloudObjectStorageClient#getCDNMetadata(String)
|
||||||
*/
|
*/
|
||||||
|
@Beta
|
||||||
@HEAD
|
@HEAD
|
||||||
@ResponseParser(ParseContainerCDNMetadataFromHeaders.class)
|
@ResponseParser(ParseContainerCDNMetadataFromHeaders.class)
|
||||||
@ExceptionParser(ReturnNullOnContainerNotFound.class)
|
@ExceptionParser(ReturnNullOnContainerNotFound.class)
|
||||||
|
@ -93,6 +96,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient
|
||||||
/**
|
/**
|
||||||
* @see HPCloudObjectStorageClient#getCDNMetadata(String)
|
* @see HPCloudObjectStorageClient#getCDNMetadata(String)
|
||||||
*/
|
*/
|
||||||
|
@Beta
|
||||||
@HEAD
|
@HEAD
|
||||||
@ResponseParser(ParseContainerMetadataFromHeaders.class)
|
@ResponseParser(ParseContainerMetadataFromHeaders.class)
|
||||||
@ExceptionParser(ReturnNullOnContainerNotFound.class)
|
@ExceptionParser(ReturnNullOnContainerNotFound.class)
|
||||||
|
@ -110,6 +114,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient
|
||||||
/**
|
/**
|
||||||
* @see HPCloudObjectStorageClient#enableCDN(String, long)
|
* @see HPCloudObjectStorageClient#enableCDN(String, long)
|
||||||
*/
|
*/
|
||||||
|
@Beta
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{container}")
|
@Path("/{container}")
|
||||||
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
|
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
|
||||||
|
@ -121,6 +126,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient
|
||||||
/**
|
/**
|
||||||
* @see HPCloudObjectStorageClient#enableCDN(String)
|
* @see HPCloudObjectStorageClient#enableCDN(String)
|
||||||
*/
|
*/
|
||||||
|
@Beta
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{container}")
|
@Path("/{container}")
|
||||||
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
|
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "True")
|
||||||
|
@ -131,6 +137,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient
|
||||||
/**
|
/**
|
||||||
* @see HPCloudObjectStorageClient#updateCDN(String, long)
|
* @see HPCloudObjectStorageClient#updateCDN(String, long)
|
||||||
*/
|
*/
|
||||||
|
@Beta
|
||||||
@POST
|
@POST
|
||||||
@Path("/{container}")
|
@Path("/{container}")
|
||||||
@ResponseParser(ParseCDNUriFromHeaders.class)
|
@ResponseParser(ParseCDNUriFromHeaders.class)
|
||||||
|
@ -141,6 +148,7 @@ public interface HPCloudObjectStorageAsyncClient extends CommonSwiftAsyncClient
|
||||||
/**
|
/**
|
||||||
* @see HPCloudObjectStorageClient#disableCDN(String)
|
* @see HPCloudObjectStorageClient#disableCDN(String)
|
||||||
*/
|
*/
|
||||||
|
@Beta
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{container}")
|
@Path("/{container}")
|
||||||
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "False")
|
@Headers(keys = HPCloudObjectStorageHeaders.CDN_ENABLED, values = "False")
|
||||||
|
|
|
@ -30,36 +30,44 @@ import org.jclouds.hpcloud.object.storage.options.ListCDNContainerOptions;
|
||||||
import org.jclouds.openstack.swift.CommonSwiftClient;
|
import org.jclouds.openstack.swift.CommonSwiftClient;
|
||||||
import org.jclouds.openstack.swift.domain.ContainerMetadata;
|
import org.jclouds.openstack.swift.domain.ContainerMetadata;
|
||||||
|
|
||||||
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to HP Cloud Object Storage via the REST API.
|
* Provides synchronous access to HP Cloud Object Storage via the REST API.
|
||||||
*
|
*
|
||||||
* <p/>All commands return a ListenableFuture of the result. Any exceptions incurred
|
* <p/>
|
||||||
* during processing will be wrapped in an {@link ExecutionException} as documented in
|
* All commands return a ListenableFuture of the result. Any exceptions incurred during processing
|
||||||
* {@link ListenableFuture#get()}.
|
* will be wrapped in an {@link ExecutionException} as documented in {@link ListenableFuture#get()}.
|
||||||
*
|
*
|
||||||
* @see HPCloudObjectStorageClient
|
* @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
|
* @author Jeremy Daggett
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 120, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 120, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface HPCloudObjectStorageClient extends CommonSwiftClient {
|
public interface HPCloudObjectStorageClient extends CommonSwiftClient {
|
||||||
|
|
||||||
boolean createContainer(String container, CreateContainerOptions... options);
|
boolean createContainer(String container, CreateContainerOptions... options);
|
||||||
|
|
||||||
|
ContainerMetadata getContainerMetadata(String container);
|
||||||
|
|
||||||
|
@Beta
|
||||||
Set<ContainerCDNMetadata> listCDNContainers(ListCDNContainerOptions... options);
|
Set<ContainerCDNMetadata> listCDNContainers(ListCDNContainerOptions... options);
|
||||||
|
|
||||||
|
@Beta
|
||||||
ContainerCDNMetadata getCDNMetadata(String container);
|
ContainerCDNMetadata getCDNMetadata(String container);
|
||||||
|
|
||||||
ContainerMetadata getContainerMetadata(String container);
|
@Beta
|
||||||
|
|
||||||
URI enableCDN(String container, long ttl);
|
URI enableCDN(String container, long ttl);
|
||||||
|
|
||||||
|
@Beta
|
||||||
URI enableCDN(String container);
|
URI enableCDN(String container);
|
||||||
|
|
||||||
|
@Beta
|
||||||
URI updateCDN(String container, long ttl);
|
URI updateCDN(String container, long ttl);
|
||||||
|
|
||||||
|
@Beta
|
||||||
boolean disableCDN(String container);
|
boolean disableCDN(String container);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,33 +34,21 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live", testName = "HPCloudObjectStorageClientLiveTest")
|
||||||
public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTest<HPCloudObjectStorageClient> {
|
public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTest<HPCloudObjectStorageClient> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HPCloudObjectStorageClient getApi() {
|
public HPCloudObjectStorageClient getApi() {
|
||||||
return (HPCloudObjectStorageClient) context.getProviderSpecificContext().getApi();
|
return (HPCloudObjectStorageClient) context.getProviderSpecificContext().getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void testGetObjectContentType(SwiftObject getBlob) {
|
protected void testGetObjectContentType(SwiftObject getBlob) {
|
||||||
assertEquals(getBlob.getInfo().getContentType(), "application/x-www-form-urlencoded");
|
assertEquals(getBlob.getInfo().getContentType(), "application/x-www-form-urlencoded");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
// CDN service due to go live Q1 2012
|
||||||
public void testListCDNContainers() {
|
@Test(enabled = false)
|
||||||
// FIXFIX improve
|
|
||||||
/*
|
|
||||||
try {
|
|
||||||
Set<ContainerCDNMetadata> cdnMetadataList = getApi().listCDNContainers();
|
|
||||||
System.err.println(cdnMetadataList);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCDNOperations() throws Exception {
|
public void testCDNOperations() throws Exception {
|
||||||
final long minimumTTL = 60 * 60; // The minimum TTL is 1 hour
|
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(containerNameWithCDN);
|
||||||
getApi().disableCDN(containerNameWithoutCDN);
|
getApi().disableCDN(containerNameWithoutCDN);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
ContainerCDNMetadata cdnMetadata = null;
|
ContainerCDNMetadata cdnMetadata = null;
|
||||||
|
|
||||||
|
@ -86,8 +74,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
|
||||||
assertTrue(cdnMetadata.isCDNEnabled());
|
assertTrue(cdnMetadata.isCDNEnabled());
|
||||||
|
|
||||||
assertEquals(cdnMetadata.getCDNUri(), cdnUri);
|
assertEquals(cdnMetadata.getCDNUri(), cdnUri);
|
||||||
|
|
||||||
|
|
||||||
cdnMetadata = getApi().getCDNMetadata(containerNameWithoutCDN);
|
cdnMetadata = getApi().getCDNMetadata(containerNameWithoutCDN);
|
||||||
assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
|
assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
|
||||||
+ " should not have metadata";
|
+ " should not have metadata";
|
||||||
|
@ -103,14 +90,13 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
|
||||||
final long initialTTL = cdnMetadata.getTTL();
|
final long initialTTL = cdnMetadata.getTTL();
|
||||||
assertTrue(cdnMetadataList.contains(new ContainerCDNMetadata(containerNameWithCDN, true, initialTTL, cdnUri)));
|
assertTrue(cdnMetadataList.contains(new ContainerCDNMetadata(containerNameWithCDN, true, initialTTL, cdnUri)));
|
||||||
|
|
||||||
/* Test listing with options FIXFIX
|
/*
|
||||||
cdnMetadataList = getApi().listCDNContainers(ListCDNContainerOptions.Builder.enabledOnly());
|
* Test listing with options FIXFIX cdnMetadataList =
|
||||||
assertTrue(Iterables.all(cdnMetadataList, new Predicate<ContainerCDNMetadata>() {
|
* getApi().listCDNContainers(ListCDNContainerOptions.Builder.enabledOnly());
|
||||||
public boolean apply(ContainerCDNMetadata cdnMetadata) {
|
* assertTrue(Iterables.all(cdnMetadataList, new Predicate<ContainerCDNMetadata>() { public
|
||||||
return cdnMetadata.isCDNEnabled();
|
* boolean apply(ContainerCDNMetadata cdnMetadata) { return cdnMetadata.isCDNEnabled(); }
|
||||||
}
|
* }));
|
||||||
}));
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
cdnMetadataList = getApi().listCDNContainers(
|
cdnMetadataList = getApi().listCDNContainers(
|
||||||
ListCDNContainerOptions.Builder.afterMarker(
|
ListCDNContainerOptions.Builder.afterMarker(
|
||||||
|
@ -149,7 +135,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes
|
||||||
cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
|
cdnMetadata = getApi().getCDNMetadata(containerNameWithCDN);
|
||||||
assertEquals(cdnMetadata.isCDNEnabled(), false);
|
assertEquals(cdnMetadata.isCDNEnabled(), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
recycleContainer(containerNameWithCDN);
|
recycleContainer(containerNameWithCDN);
|
||||||
recycleContainer(containerNameWithoutCDN);
|
recycleContainer(containerNameWithoutCDN);
|
||||||
|
|
Loading…
Reference in New Issue