mirror of https://github.com/apache/jclouds.git
Prefer Regions to Zones
This commit is contained in:
parent
4073f7fdc4
commit
aa04ef007f
|
@ -32,7 +32,7 @@ import com.google.common.annotations.Beta;
|
|||
* <p/>
|
||||
* Additionally, Cloud Files provides a simple yet powerful way to publish and distribute content
|
||||
* behind a Content Distribution Network.
|
||||
*
|
||||
*
|
||||
* @see CDNApi
|
||||
* @see SwiftApi
|
||||
*/
|
||||
|
@ -41,21 +41,21 @@ public interface CloudFilesApi extends SwiftApi {
|
|||
|
||||
/**
|
||||
* Provides access to Cloud Files CDN features.
|
||||
*
|
||||
*
|
||||
* @param region the region to access the CDN API.
|
||||
*
|
||||
*
|
||||
* @return the {@link CDNApi} for the specified region.
|
||||
*/
|
||||
@Delegate
|
||||
CDNApi getCDNApiForRegion(@EndpointParam(parser = RegionToCDNEndpoint.class) @Nullable String region);
|
||||
CDNApi getCDNApi(@EndpointParam(parser = RegionToCDNEndpoint.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides access to Cloud Files CDN features.
|
||||
*
|
||||
*
|
||||
* @param region the region to access the CDN API.
|
||||
*
|
||||
*
|
||||
* @return the {@link CDNApi} for the specified region.
|
||||
*
|
||||
*
|
||||
* @deprecated Please use {@link #getCDNApiForRegion(String)}. This method will be removed in jclouds 1.8.
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -36,8 +36,8 @@ public class CloudFilesAccountApiLiveTest extends AccountApiLiveTest {
|
|||
}
|
||||
|
||||
public void testUrlKeyExists() throws Exception {
|
||||
for (String regionId : regions) {
|
||||
Account account = api.getAccountApiForRegion(regionId).get();
|
||||
for (String region : regions) {
|
||||
Account account = api.getAccountApi(region).get();
|
||||
assertTrue(account.getTemporaryUrlKey().isPresent());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,20 +53,20 @@ public class CloudFilesCDNApiLiveTest extends BaseCloudFilesApiLiveTest {
|
|||
}
|
||||
|
||||
public void testEnable() throws Exception {
|
||||
for (String regionId : regions) {
|
||||
assertNotNull(api.getCDNApiForRegion(regionId).enable(name));
|
||||
|
||||
CDNContainer container = api.getCDNApiForRegion(regionId).get(name);
|
||||
for (String region : regions) {
|
||||
assertNotNull(api.getCDNApi(region).enable(name));
|
||||
|
||||
CDNContainer container = api.getCDNApi(region).get(name);
|
||||
assertCDNContainerNotNull(container);
|
||||
assertTrue(container.isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
public void testEnableWithTTL() throws Exception {
|
||||
for (String regionId : regions) {
|
||||
assertNotNull(api.getCDNApiForRegion(regionId).enable(name, 777777));
|
||||
for (String region : regions) {
|
||||
assertNotNull(api.getCDNApi(region).enable(name, 777777));
|
||||
|
||||
CDNContainer container = api.getCDNApiForRegion(regionId).get(name);
|
||||
CDNContainer container = api.getCDNApi(region).get(name);
|
||||
assertCDNContainerNotNull(container);
|
||||
assertTrue(container.isEnabled());
|
||||
assertTrue(container.getTtl() == 777777);
|
||||
|
@ -74,19 +74,19 @@ public class CloudFilesCDNApiLiveTest extends BaseCloudFilesApiLiveTest {
|
|||
}
|
||||
|
||||
public void testDisable() throws Exception {
|
||||
for (String regionId : regions) {
|
||||
assertTrue(api.getCDNApiForRegion(regionId).disable(name));
|
||||
for (String region : regions) {
|
||||
assertTrue(api.getCDNApi(region).disable(name));
|
||||
|
||||
CDNContainer container = api.getCDNApiForRegion(regionId).get(name);
|
||||
CDNContainer container = api.getCDNApi(region).get(name);
|
||||
assertFalse(container.isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
public void testList() throws Exception {
|
||||
for (String regionId : regions) {
|
||||
List<CDNContainer> cdnResponse = api.getCDNApiForRegion(regionId).list().toList();
|
||||
for (String region : regions) {
|
||||
List<CDNContainer> cdnResponse = api.getCDNApi(region).list().toList();
|
||||
assertNotNull(cdnResponse);
|
||||
|
||||
|
||||
for (CDNContainer cdnContainer : cdnResponse) {
|
||||
assertCDNContainerNotNull(cdnContainer);
|
||||
assertTrue(cdnContainer.isEnabled());
|
||||
|
@ -96,35 +96,35 @@ public class CloudFilesCDNApiLiveTest extends BaseCloudFilesApiLiveTest {
|
|||
|
||||
public void testListWithOptions() throws Exception {
|
||||
String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
|
||||
for (String regionId : regions) {
|
||||
for (String region : regions) {
|
||||
ListCDNContainerOptions options = new ListCDNContainerOptions().marker(lexicographicallyBeforeName);
|
||||
|
||||
CDNContainer cdnContainer = api.getCDNApiForRegion(regionId).list(options).get(0);
|
||||
|
||||
CDNContainer cdnContainer = api.getCDNApi(region).list(options).get(0);
|
||||
assertCDNContainerNotNull(cdnContainer);
|
||||
assertTrue(cdnContainer.isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
public void testGet() throws Exception {
|
||||
for (String regionId : regions) {
|
||||
CDNContainer container = api.getCDNApiForRegion(regionId).get(name);
|
||||
for (String region : regions) {
|
||||
CDNContainer container = api.getCDNApi(region).get(name);
|
||||
assertCDNContainerNotNull(container);
|
||||
assertTrue(container.isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
public void testPurgeObject() throws Exception {
|
||||
for (String regionId : regions) {
|
||||
for (String region : regions) {
|
||||
String objectName = "testPurge";
|
||||
Payload payload = Payloads.newByteSourcePayload(ByteSource.wrap(new byte[] {1, 2, 3}));
|
||||
ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, name);
|
||||
|
||||
ObjectApi objectApi = api.getObjectApiForContainer(region, name);
|
||||
|
||||
// create a new object
|
||||
objectApi.put(objectName, payload);
|
||||
|
||||
CDNApi cdnApi = api.getCDNApiForRegion(regionId);
|
||||
|
||||
CDNApi cdnApi = api.getCDNApi(region);
|
||||
assertTrue(cdnApi.purgeObject(name, "testPurge", ImmutableList.<String>of()));
|
||||
|
||||
|
||||
// delete the object
|
||||
objectApi.delete(objectName);
|
||||
assertNull(objectApi.get(objectName, GetOptions.NONE));
|
||||
|
@ -132,12 +132,12 @@ public class CloudFilesCDNApiLiveTest extends BaseCloudFilesApiLiveTest {
|
|||
}
|
||||
|
||||
public void testUpdate() throws Exception {
|
||||
for (String regionId : regions) {
|
||||
for (String region : regions) {
|
||||
// enable with a ttl
|
||||
assertNotNull(api.getCDNApiForRegion(regionId).enable(name, 777777));
|
||||
|
||||
assertNotNull(api.getCDNApi(region).enable(name, 777777));
|
||||
|
||||
// now get the container
|
||||
CDNContainer original = api.getCDNApiForRegion(regionId).get(name);
|
||||
CDNContainer original = api.getCDNApi(region).get(name);
|
||||
assertTrue(original.isEnabled());
|
||||
assertCDNContainerNotNull(original);
|
||||
|
||||
|
@ -147,13 +147,13 @@ public class CloudFilesCDNApiLiveTest extends BaseCloudFilesApiLiveTest {
|
|||
.logRetention(true)
|
||||
.enabled(false);
|
||||
// update the container
|
||||
assertTrue(api.getCDNApiForRegion(regionId).update(name, opts));
|
||||
|
||||
assertTrue(api.getCDNApi(region).update(name, opts));
|
||||
|
||||
// now get the updated container
|
||||
CDNContainer updated = api.getCDNApiForRegion(regionId).get(name);
|
||||
CDNContainer updated = api.getCDNApi(region).get(name);
|
||||
assertFalse(updated.isEnabled());
|
||||
assertCDNContainerNotNull(updated);
|
||||
|
||||
|
||||
assertNotEquals(original.getTtl(), updated.getTtl());
|
||||
assertTrue(updated.isLogRetentionEnabled());
|
||||
}
|
||||
|
@ -173,17 +173,17 @@ public class CloudFilesCDNApiLiveTest extends BaseCloudFilesApiLiveTest {
|
|||
@BeforeClass(groups = "live")
|
||||
public void setup() {
|
||||
super.setup();
|
||||
for (String regionId : regions) {
|
||||
api.getContainerApiForRegion(regionId).create(name);
|
||||
for (String region : regions) {
|
||||
api.getContainerApi(region).create(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@AfterClass(groups = "live")
|
||||
public void tearDown() {
|
||||
for (String regionId : regions) {
|
||||
api.getCDNApiForRegion(regionId).disable(name);
|
||||
api.getContainerApiForRegion(regionId).deleteIfEmpty(name);
|
||||
for (String region : regions) {
|
||||
api.getCDNApi(region).disable(name);
|
||||
api.getContainerApi(region).deleteIfEmpty(name);
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
|
||||
try {
|
||||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
CDNApi cdnApi = api.getCDNApiForRegion("DFW");
|
||||
CDNApi cdnApi = api.getCDNApi("DFW");
|
||||
|
||||
ImmutableList<CDNContainer> cdnContainers = cdnApi.list().toList();
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
|
||||
try {
|
||||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
CDNApi cdnApi = api.getCDNApiForRegion("DFW");
|
||||
CDNApi cdnApi = api.getCDNApi("DFW");
|
||||
|
||||
List<CDNContainer> cdnContainers = cdnApi.list().toList();
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
try {
|
||||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
ListCDNContainerOptions options = new ListCDNContainerOptions().marker("cdn-container-3");
|
||||
ImmutableList<CDNContainer> containers = api.getCDNApiForRegion("DFW").list(options).toList();
|
||||
ImmutableList<CDNContainer> containers = api.getCDNApi("DFW").list(options).toList();
|
||||
|
||||
for (CDNContainer container : containers) {
|
||||
assertCDNContainerNotNull(container);
|
||||
|
@ -128,7 +128,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
try {
|
||||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
ListCDNContainerOptions options = ListCDNContainerOptions.Builder.marker("cdn-container-3");
|
||||
FluentIterable<CDNContainer> containers = api.getCDNApiForRegion("DFW").list(options);
|
||||
FluentIterable<CDNContainer> containers = api.getCDNApi("DFW").list(options);
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertAuthentication(server);
|
||||
|
@ -150,7 +150,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
// enable a CDN Container
|
||||
URI enabledContainer = api.getCDNApiForRegion("DFW").enable("container-1");
|
||||
URI enabledContainer = api.getCDNApi("DFW").enable("container-1");
|
||||
assertNotNull(enabledContainer);
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
|
@ -165,11 +165,11 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
|
||||
server.enqueue(addCommonHeaders(enabledResponse().setResponseCode(404)));
|
||||
|
||||
|
||||
try {
|
||||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
// enable a CDN Container
|
||||
assertNull(api.getCDNApiForRegion("DFW").enable("container-1"));
|
||||
assertNull(api.getCDNApi("DFW").enable("container-1"));
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertAuthentication(server);
|
||||
|
@ -188,7 +188,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
// enable a CDN Container with a TTL
|
||||
URI enabledContainer = api.getCDNApiForRegion("DFW").enable("container-1", 777777);
|
||||
URI enabledContainer = api.getCDNApi("DFW").enable("container-1", 777777);
|
||||
assertNotNull(enabledContainer);
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
|
@ -208,7 +208,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
// enable a CDN Container with a TTL
|
||||
URI enabledContainer = api.getCDNApiForRegion("DFW").enable("container-1", 777777);
|
||||
URI enabledContainer = api.getCDNApi("DFW").enable("container-1", 777777);
|
||||
assertNull(enabledContainer);
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
|
@ -228,7 +228,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
// disable a CDN Container
|
||||
assertTrue(api.getCDNApiForRegion("DFW").disable("container-1"));
|
||||
assertTrue(api.getCDNApi("DFW").disable("container-1"));
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertAuthentication(server);
|
||||
|
@ -247,7 +247,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
// disable a CDN Container
|
||||
boolean disbledContainer = api.getCDNApiForRegion("DFW").disable("container-1");
|
||||
boolean disbledContainer = api.getCDNApi("DFW").disable("container-1");
|
||||
assertFalse(disbledContainer);
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
|
@ -262,11 +262,11 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
|
||||
server.enqueue(addCommonHeaders(enabledResponse().setResponseCode(201)));
|
||||
|
||||
|
||||
try {
|
||||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
CDNContainer cdnContainer = api.getCDNApiForRegion("DFW").get("container-1");
|
||||
CDNContainer cdnContainer = api.getCDNApi("DFW").get("container-1");
|
||||
assertCDNContainerNotNull(cdnContainer);
|
||||
assertEquals(mockCDNContainer, cdnContainer);
|
||||
|
||||
|
@ -286,7 +286,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
try {
|
||||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
CDNContainer cdnContainer = api.getCDNApiForRegion("DFW").get("cdn-container with spaces");
|
||||
CDNContainer cdnContainer = api.getCDNApi("DFW").get("cdn-container with spaces");
|
||||
assertCDNContainerNotNull(cdnContainer);
|
||||
assertEquals(mockCDNContainerWithSpaces, cdnContainer);
|
||||
|
||||
|
@ -306,7 +306,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
try {
|
||||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
CDNContainer cdnContainer = api.getCDNApiForRegion("DFW").get("container-1");
|
||||
CDNContainer cdnContainer = api.getCDNApi("DFW").get("container-1");
|
||||
|
||||
assertAuthentication(server);
|
||||
assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/container-1");
|
||||
|
@ -325,7 +325,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
// purge the object
|
||||
assertTrue(api.getCDNApiForRegion("DFW").purgeObject("myContainer", "myObject", emails));
|
||||
assertTrue(api.getCDNApi("DFW").purgeObject("myContainer", "myObject", emails));
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertAuthentication(server);
|
||||
|
@ -344,7 +344,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
// purge the object
|
||||
assertFalse(api.getCDNApiForRegion("DFW").purgeObject("myContainer", "myObject", emails));
|
||||
assertFalse(api.getCDNApi("DFW").purgeObject("myContainer", "myObject", emails));
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertAuthentication(server);
|
||||
|
@ -364,13 +364,13 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
try {
|
||||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
CDNContainer cdnContainer = api.getCDNApiForRegion("DFW").get("container-1");
|
||||
CDNContainer cdnContainer = api.getCDNApi("DFW").get("container-1");
|
||||
assertCDNContainerNotNull(cdnContainer);
|
||||
|
||||
// update the CDN Container
|
||||
assertTrue(api.getCDNApiForRegion("DFW").update("container-1", enabled(false).logRetention(true).ttl(7654321)));
|
||||
assertTrue(api.getCDNApi("DFW").update("container-1", enabled(false).logRetention(true).ttl(7654321)));
|
||||
|
||||
cdnContainer = api.getCDNApiForRegion("DFW").get("container-1");
|
||||
cdnContainer = api.getCDNApi("DFW").get("container-1");
|
||||
assertCDNContainerNotNull(cdnContainer);
|
||||
|
||||
CDNContainer updatedContainer = CDNContainer.builder()
|
||||
|
@ -405,11 +405,11 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest<CloudFilesAp
|
|||
try {
|
||||
CloudFilesApi api = api(server.getUrl("/").toString(), "rackspace-cloudfiles");
|
||||
|
||||
CDNContainer cdnContainer = api.getCDNApiForRegion("DFW").get("container-1");
|
||||
CDNContainer cdnContainer = api.getCDNApi("DFW").get("container-1");
|
||||
assertCDNContainerNotNull(cdnContainer);
|
||||
|
||||
// update the CDN Container
|
||||
assertFalse(api.getCDNApiForRegion("DFW").update("container-1", enabled(false).logRetention(true).ttl(7654321)));
|
||||
assertFalse(api.getCDNApi("DFW").update("container-1", enabled(false).logRetention(true).ttl(7654321)));
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
|
|
Loading…
Reference in New Issue