From aa04ef007f06a3ba4d6ad853bd9ac7a6c96881af Mon Sep 17 00:00:00 2001 From: Jeremy Daggett Date: Fri, 25 Jul 2014 09:23:35 -0700 Subject: [PATCH] Prefer Regions to Zones --- .../cloudfiles/v1/CloudFilesApi.java | 14 ++-- .../CloudFilesAccountApiLiveTest.java | 4 +- .../v1/features/CloudFilesCDNApiLiveTest.java | 74 +++++++++---------- .../v1/features/CloudFilesCDNApiMockTest.java | 44 +++++------ 4 files changed, 68 insertions(+), 68 deletions(-) diff --git a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApi.java b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApi.java index e88872538b..2a0e50dd37 100644 --- a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApi.java +++ b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApi.java @@ -32,7 +32,7 @@ import com.google.common.annotations.Beta; *

* 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 diff --git a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesAccountApiLiveTest.java b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesAccountApiLiveTest.java index 8e57cf5fce..f91d2baa63 100644 --- a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesAccountApiLiveTest.java +++ b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesAccountApiLiveTest.java @@ -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()); } } diff --git a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java index 39e95cc6e0..887033d337 100644 --- a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java +++ b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiLiveTest.java @@ -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 cdnResponse = api.getCDNApiForRegion(regionId).list().toList(); + for (String region : regions) { + List 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.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(); } diff --git a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java index de550581b1..a3fa13c858 100644 --- a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java +++ b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesCDNApiMockTest.java @@ -61,7 +61,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest cdnContainers = cdnApi.list().toList(); @@ -82,7 +82,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest cdnContainers = cdnApi.list().toList(); @@ -104,7 +104,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest containers = api.getCDNApiForRegion("DFW").list(options).toList(); + ImmutableList containers = api.getCDNApi("DFW").list(options).toList(); for (CDNContainer container : containers) { assertCDNContainerNotNull(container); @@ -128,7 +128,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest containers = api.getCDNApiForRegion("DFW").list(options); + FluentIterable containers = api.getCDNApi("DFW").list(options); assertEquals(server.getRequestCount(), 2); assertAuthentication(server); @@ -150,7 +150,7 @@ public class CloudFilesCDNApiMockTest extends BaseOpenStackMockTest