You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/11/04 23:22:48 UTC
[1/4] Migrate off PaginatedIterable to Iterator. Fix some live test
bugs.
Repository: jclouds-labs-google
Updated Branches:
refs/heads/master a9ea2adfd -> 7427ba238
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
index 0e1a2f8..1a4f127 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
@@ -19,8 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
@@ -120,8 +120,7 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject");
- assertEquals(regionOperationApi.listFirstPageInRegion("us-central1").toString(),
- expectedList().toString());
+ assertEquals(regionOperationApi.listInRegion("us-central1").next().toString(), expectedList().toString());
}
public void testListOperationWithPaginationOptionsResponseIs2xx() {
@@ -162,6 +161,6 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject");
- assertTrue(regionOperationApi.listInRegion("us-central1").concat().isEmpty());
+ assertFalse(regionOperationApi.listInRegion("us-central1").hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
index 4031254..66c1041 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
@@ -19,71 +19,48 @@ package org.jclouds.googlecomputeengine.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Iterator;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.SkipException;
import org.testng.annotations.Test;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
+@Test(groups = "live", testName = "RegionOperationApiLiveTest")
public class RegionOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
- private static final String ADDRESS_NAME = "region-operations-api-live-test-address";
- private Operation addOperation;
- private Operation deleteOperation;
+ private Operation operation;
private RegionOperationApi api() {
return api.getRegionOperationApi(userProject.get());
}
- private AddressApi addressApi() {
- return api.getAddressApi(userProject.get());
- }
-
- @Test(groups = "live")
- public void testCreateOperations() {
- //insert some operations by adding and deleting metadata items
- // this will make sure there is stuff to listFirstPage
- addOperation = assertRegionOperationDoneSucessfully(addressApi().createInRegion(DEFAULT_REGION_NAME,
- ADDRESS_NAME), 20);
- deleteOperation = assertRegionOperationDoneSucessfully(addressApi().deleteInRegion(DEFAULT_REGION_NAME,
- ADDRESS_NAME), 20);
-
- assertNotNull(addOperation);
- assertNotNull(deleteOperation);
- }
-
- @Test(groups = "live", dependsOnMethods = "testCreateOperations")
- public void testGetOperation() {
- Operation operation = api().getInRegion(DEFAULT_REGION_NAME, addOperation.name());
- assertNotNull(operation);
- assertOperationEquals(operation, this.addOperation);
- }
-
- @Test(groups = "live", dependsOnMethods = "testCreateOperations")
public void testListOperationsWithFiltersAndPagination() {
- PagedIterable<Operation> operations = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder()
-// .filter("operationType eq insert")
- .maxResults(1));
+ Iterator<ListPage<Operation>> operations = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder()
+ // .filter("operationType eq insert")
+ .maxResults(1));
// make sure that in spite of having only one result per page we get at least two results
- final AtomicInteger counter = new AtomicInteger();
- operations.firstMatch(new Predicate<IterableWithMarker<Operation>>() {
- @Override public boolean apply(IterableWithMarker<Operation> input) {
- counter.addAndGet(Iterables.size(input));
- return counter.get() == 2;
+ int count = 0;
+ for (; count < 2 && operations.hasNext(); ) {
+ ListPage<Operation> result = operations.next();
+ if (result.isEmpty()) {
+ operation = result.get(0);
+ count++;
}
- });
+ }
+ if (count < 2) {
+ throw new SkipException("Not enough operations in " + DEFAULT_REGION_NAME);
+ }
+ assertEquals(count, 2);
}
- private void assertOperationEquals(Operation result, Operation expected) {
- assertEquals(result.name(), expected.name());
+ @Test(groups = "live", dependsOnMethods = "testListOperationsWithFiltersAndPagination")
+ public void testGetOperation() {
+ Operation result = api().getInRegion(DEFAULT_REGION_NAME, operation.name());
+ assertNotNull(result);
+ assertEquals(result.name(), operation.name()); // Checking state besides name can lead to flaky test.
}
-
-
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiExpectTest.java
index c1a34f0..b835bb8 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiExpectTest.java
@@ -19,7 +19,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import java.net.URI;
@@ -148,8 +148,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getRouteApi("myproject");
- assertEquals(api.listFirstPage().toString(),
- new ParseRouteListTest().expected().toString());
+ assertEquals(api.list().next().toString(), new ParseRouteListTest().expected().toString());
}
public void testListRoutesResponseIs4xx() {
@@ -165,6 +164,6 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getRouteApi("myproject");
- assertTrue(api.list().concat().isEmpty());
+ assertFalse(api.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
index 1e45789..2cbaf64 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
@@ -19,18 +19,16 @@ package org.jclouds.googlecomputeengine.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
+import java.util.Iterator;
import java.util.List;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Route;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.options.RouteOptions;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
@Test(groups = "live", testName = "RouteApiLiveTest")
public class RouteApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -70,15 +68,14 @@ public class RouteApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetRoute")
public void testListRoute() {
- PagedIterable<Route> routes = api().list(new ListOptions()
+ Iterator<ListPage<Route>> routes = api().list(new ListOptions()
.filter("name eq " + ROUTE_NAME));
- List<Route> routesAsList = Lists.newArrayList(routes.concat());
+ List<Route> routesAsList = routes.next();
assertEquals(routesAsList.size(), 1);
- assertRouteEquals(Iterables.getOnlyElement(routesAsList));
-
+ assertRouteEquals(routesAsList.get(0));
}
@Test(groups = "live", dependsOnMethods = "testListRoute")
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiExpectTest.java
index 4a44ba2..efd77b7 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiExpectTest.java
@@ -18,8 +18,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.parse.ParseSnapshotListTest;
@@ -78,8 +78,7 @@ public class SnapshotApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
SnapshotApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, LIST_SNAPSHOTS_REQ, LIST_SNAPSHOTS_RESPONSE).getSnapshotApi("myproject");
- assertEquals(api.listFirstPage().toString(),
- new ParseSnapshotListTest().expected().toString());
+ assertEquals(api.list().next().toString(), new ParseSnapshotListTest().expected().toString());
}
public void testListSnapshotWithPaginationOptionsResponseIs4xx() {
@@ -89,6 +88,6 @@ public class SnapshotApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
SnapshotApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, LIST_SNAPSHOTS_REQ, operationResponse).getSnapshotApi("myproject");
- assertTrue(api.list().concat().isEmpty());
+ assertFalse(api.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
index c8e3d9b..f38a7ea 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
@@ -19,18 +19,16 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.features.DiskApiLiveTest.TIME_WAIT;
import static org.testng.Assert.assertEquals;
+import java.util.Iterator;
import java.util.List;
-import org.jclouds.collect.PagedIterable;
import org.jclouds.googlecomputeengine.domain.Disk;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Snapshot;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
public class SnapshotApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String DISK_NAME = "snapshot-api-live-test-disk";
@@ -47,11 +45,11 @@ public class SnapshotApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testCreateSnapshot() {
- assertZoneOperationDoneSucessfully(diskApi().createInZone(DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().createInZone(DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);
disk = diskApi().getInZone(DEFAULT_ZONE_NAME, DISK_NAME);
- assertZoneOperationDoneSucessfully(diskApi().createSnapshotInZone(DEFAULT_ZONE_NAME, DISK_NAME, SNAPSHOT_NAME),
- TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().createSnapshotInZone(DEFAULT_ZONE_NAME, DISK_NAME, SNAPSHOT_NAME),
+ TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testCreateSnapshot")
@@ -65,20 +63,20 @@ public class SnapshotApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetSnapshot")
public void testListSnapshot() {
- PagedIterable<Snapshot> snapshots = api().list(new ListOptions.Builder()
+ Iterator<ListPage<Snapshot>> snapshots = api().list(new ListOptions.Builder()
.filter("name eq " + SNAPSHOT_NAME));
- List<Snapshot> snapshotsAsList = Lists.newArrayList(snapshots.concat());
+ List<Snapshot> snapshotsAsList = snapshots.next();
assertEquals(snapshotsAsList.size(), 1);
- assertSnapshotEquals(Iterables.getOnlyElement(snapshotsAsList));
+ assertSnapshotEquals(snapshotsAsList.get(0));
}
@Test(groups = "live", dependsOnMethods = "testListSnapshot")
public void testDeleteDisk() {
- assertZoneOperationDoneSucessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
assertGlobalOperationDoneSucessfully(api().delete(SNAPSHOT_NAME), TIME_WAIT);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
index aa8aad7..631ca4a 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
@@ -19,7 +19,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import java.net.URI;
@@ -171,7 +171,7 @@ public class TargetPoolApiExpectTest extends BaseGoogleComputeEngineApiExpectTes
TargetPoolApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getTargetPoolApi("myproject", "us-central1");
- assertTrue(api.list().concat().isEmpty());
+ assertFalse(api.list().hasNext());
}
public void testAddInstanceResponseIs2xx() throws Exception {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
index 124d062..172a153 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
@@ -40,6 +40,7 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -72,10 +73,10 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
InstanceApi instanceApi = api.getInstanceApi(userProject.get());
HttpHealthCheckApi httpHealthCheckApi = api.getHttpHealthCheckApi(userProject.get());
+ ListPage<Image> list = api.getImageApi("centos-cloud").list(new ListOptions.Builder().filter("name eq centos.*"))
+ .next();
// Get an imageUri
- URI imageUri = api.getImageApi("centos-cloud")
- .list(new ListOptions.Builder().filter("name eq centos.*"))
- .concat()
+ URI imageUri = FluentIterable.from(list)
.filter(new Predicate<Image>() {
@Override
public boolean apply(Image input) {
@@ -103,15 +104,13 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
// Create a disk.
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(instanceTemplate.image());
- assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get())
- .createInZone(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME, diskCreationOptions),
- TIME_WAIT_LONG);
+ assertZoneOperationDoneSuccessfully(api.getDiskApi(userProject.get())
+ .createInZone(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME, diskCreationOptions),
+ TIME_WAIT_LONG);
// Create an instance.
- assertZoneOperationDoneSucessfully(instanceApi.createInZone(INSTANCE_NAME,
- DEFAULT_ZONE_NAME,
- instanceTemplate),
- TIME_WAIT_LONG);
+ assertZoneOperationDoneSuccessfully(instanceApi.createInZone(INSTANCE_NAME, DEFAULT_ZONE_NAME, instanceTemplate),
+ TIME_WAIT_LONG);
Instance instance = instanceApi.getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
instances = new ArrayList<URI>();
instances.add(instance.selfLink());
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java
index 4091678..1fa2db9 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java
@@ -18,8 +18,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.parse.ParseZoneListTest;
@@ -81,8 +81,7 @@ public class ZoneApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, LIST_ZONES_REQ, LIST_ZONES_RESPONSE).getZoneApi("myproject");
- assertEquals(api.listFirstPage().toString(),
- new ParseZoneListTest().expected().toString());
+ assertEquals(api.list().next().toString(), new ParseZoneListTest().expected().toString());
}
public void testListZoneWithPaginationOptionsResponseIs4xx() {
@@ -92,6 +91,6 @@ public class ZoneApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, LIST_ZONES_REQ, operationResponse).getZoneApi("myproject");
- assertTrue(api.list().concat().isEmpty());
+ assertFalse(api.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
index fb7d0ee..f4c885e 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
@@ -18,21 +18,17 @@ package org.jclouds.googlecomputeengine.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import java.util.Iterator;
import java.util.List;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Zone;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
-
public class ZoneApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private Zone zone;
@@ -44,18 +40,14 @@ public class ZoneApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testListZone() {
- PagedIterable<Zone> zones = api().list(new ListOptions.Builder()
- .maxResults(1));
-
- Iterator<IterableWithMarker<Zone>> pageIterator = zones.iterator();
+ Iterator<ListPage<Zone>> pageIterator = api().list(new ListOptions.Builder().maxResults(1));
assertTrue(pageIterator.hasNext());
- IterableWithMarker<Zone> singlePageIterator = pageIterator.next();
- List<Zone> zoneAsList = singlePageIterator.toList();
+ List<Zone> zoneAsList = pageIterator.next();
- assertSame(zoneAsList.size(), 1);
+ assertEquals(zoneAsList.size(), 1);
- this.zone = Iterables.getOnlyElement(zoneAsList);
+ this.zone = zoneAsList.get(0);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
index 4be46c3..4d542ce 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
@@ -19,8 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
@@ -118,7 +118,7 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject");
- assertEquals(zoneOperationApi.listFirstPageInZone("us-central1-a").toString(),
+ assertEquals(zoneOperationApi.listInZone("us-central1-a").next().toString(),
expectedList().toString());
}
@@ -158,9 +158,8 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
- ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject");
+ ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject");
- assertTrue(zoneOperationApi.listInZone("us-central1-a").concat().isEmpty());
+ assertFalse(zoneOperationApi.listInZone("us-central1-a").hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
index 542bbf3..aafea3d 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
@@ -16,73 +16,51 @@
*/
package org.jclouds.googlecomputeengine.features;
-import static org.jclouds.googlecomputeengine.features.DiskApiLiveTest.TIME_WAIT;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Iterator;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.SkipException;
import org.testng.annotations.Test;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
+@Test(groups = "live", testName = "ZoneOperationApiLiveTest")
public class ZoneOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
- private static final String DISK_NAME = "zone-operations-api-live-test-disk";
- private Operation addOperation;
- private Operation deleteOperation;
+ private Operation operation;
private ZoneOperationApi api() {
return api.getZoneOperationApi(userProject.get());
}
- private DiskApi diskApi() {
- return api.getDiskApi(userProject.get());
- }
-
- @Test(groups = "live")
- public void testCreateOperations() {
- //insert some operations by creating and deleting a disk
- // this will make sure there is stuff to listFirstPage
- addOperation = assertZoneOperationDoneSucessfully(diskApi().createInZone(DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);
- deleteOperation = assertZoneOperationDoneSucessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
-
- assertNotNull(addOperation);
- assertNotNull(deleteOperation);
- }
-
- @Test(groups = "live", dependsOnMethods = "testCreateOperations")
- public void testGetOperation() {
- Operation operation = api().getInZone(DEFAULT_ZONE_NAME, addOperation.name());
- assertNotNull(operation);
- assertOperationEquals(operation, this.addOperation);
- }
-
- @Test(groups = "live", dependsOnMethods = "testCreateOperations")
public void testListOperationsWithFiltersAndPagination() {
- PagedIterable<Operation> operations = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
+ Iterator<ListPage<Operation>> operations = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
// .filter("operationType eq insert")
.maxResults(1));
// make sure that in spite of having only one result per page we get at least two results
- final AtomicInteger counter = new AtomicInteger();
- operations.firstMatch(new Predicate<IterableWithMarker<Operation>>() {
- @Override public boolean apply(IterableWithMarker<Operation> input) {
- counter.addAndGet(Iterables.size(input));
- return counter.get() == 2;
+ int count = 0;
+ for (; count < 2 && operations.hasNext(); ) {
+ ListPage<Operation> result = operations.next();
+ if (result.isEmpty()) {
+ operation = result.get(0);
+ count++;
}
- });
+ }
+ if (count < 2) {
+ throw new SkipException("Not enough operations in " + DEFAULT_ZONE_NAME);
+ }
+ assertEquals(count, 2);
}
- private void assertOperationEquals(Operation result, Operation expected) {
- assertEquals(result.name(), expected.name());
+ @Test(groups = "live", dependsOnMethods = "testListOperationsWithFiltersAndPagination")
+ public void testGetOperation() {
+ Operation result = api().getInZone(DEFAULT_ZONE_NAME, operation.name());
+ assertNotNull(result);
+ assertEquals(result.name(), operation.name()); // Checking state besides name can lead to flaky test.
}
-
-
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java
index c5780b1..1a19bcf 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java
@@ -30,6 +30,7 @@ import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.config.UserProject;
import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
@@ -48,7 +49,6 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo
protected static final String DEFAULT_ZONE_NAME = "us-central1-a";
protected static final String DEFAULT_REGION_NAME = "us-central1";
protected static final String NETWORK_API_URL_SUFFIX = "/global/networks/";
- protected static final String DEFAULT_NETWORK_NAME = "live-test-network";
protected static final String MACHINE_TYPE_API_URL_SUFFIX = "/machineTypes/";
protected static final String DEFAULT_MACHINE_TYPE_NAME = "n1-standard-1";
protected static final String GATEWAY_API_URL_SUFFIX = "/global/gateways/";
@@ -85,37 +85,30 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo
return injector.getInstance(GoogleComputeEngineApi.class);
}
- protected Operation assertGlobalOperationDoneSucessfully(Operation operation, long maxWaitSeconds) {
- operation = waitGlobalOperationDone(operation, maxWaitSeconds);
+ protected void assertGlobalOperationDoneSucessfully(Operation operation, long maxWaitSeconds) {
+ operation = waitOperationDone(globalOperationDonePredicate, operation, maxWaitSeconds);
assertEquals(operation.status(), Operation.Status.DONE);
assertTrue(operation.errors().isEmpty());
- return operation;
}
- protected Operation waitGlobalOperationDone(Operation operation, long maxWaitSeconds) {
- return waitOperationDone(globalOperationDonePredicate, operation, maxWaitSeconds);
+ protected void waitGlobalOperationDone(Operation operation, long maxWaitSeconds) {
+ waitOperationDone(globalOperationDonePredicate, operation, maxWaitSeconds);
}
- protected Operation assertRegionOperationDoneSucessfully(Operation operation, long maxWaitSeconds) {
- operation = waitRegionOperationDone(operation, maxWaitSeconds);
+ protected void assertRegionOperationDoneSucessfully(Operation operation, long maxWaitSeconds) {
+ operation = waitOperationDone(regionOperationDonePredicate, operation, maxWaitSeconds);
assertEquals(operation.status(), Operation.Status.DONE);
assertTrue(operation.errors().isEmpty());
- return operation;
}
- protected Operation waitRegionOperationDone(Operation operation, long maxWaitSeconds) {
- return waitOperationDone(regionOperationDonePredicate, operation, maxWaitSeconds);
- }
-
- protected Operation assertZoneOperationDoneSucessfully(Operation operation, long maxWaitSeconds) {
- operation = waitZoneOperationDone(operation, maxWaitSeconds);
+ protected void assertZoneOperationDoneSuccessfully(@Nullable Operation operation, long maxWaitSeconds) {
+ operation = waitOperationDone(zoneOperationDonePredicate, operation, maxWaitSeconds);
assertEquals(operation.status(), Operation.Status.DONE);
assertTrue(operation.errors().isEmpty());
- return operation;
}
- protected Operation waitZoneOperationDone(Operation operation, long maxWaitSeconds) {
- return waitOperationDone(zoneOperationDonePredicate, operation, maxWaitSeconds);
+ protected void waitZoneOperationDone(@Nullable Operation operation, long maxWaitSeconds) {
+ waitOperationDone(zoneOperationDonePredicate, operation, maxWaitSeconds);
}
protected URI getDiskTypeUrl(String project, String zone, String diskType){
@@ -130,10 +123,6 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo
return URI.create(API_URL_PREFIX + project + ZONE_API_URL_SUFFIX + zone);
}
- protected URI getDefaultNetworkUrl(String project) {
- return getNetworkUrl(project, DEFAULT_NETWORK_NAME);
- }
-
protected URI getNetworkUrl(String project, String network) {
return URI.create(API_URL_PREFIX + project + NETWORK_API_URL_SUFFIX + network);
}
@@ -156,12 +145,14 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo
}
protected URI getDiskUrl(String project, String diskName) {
- return URI.create(API_URL_PREFIX + project + ZONE_API_URL_SUFFIX
- + DEFAULT_ZONE_NAME + "/disks/" + diskName);
+ return URI.create(API_URL_PREFIX + project + ZONE_API_URL_SUFFIX + DEFAULT_ZONE_NAME + "/disks/" + diskName);
}
- protected static Operation waitOperationDone(Predicate<AtomicReference<Operation>> operationDonePredicate,
- Operation operation, long maxWaitSeconds) {
+ private static Operation waitOperationDone(Predicate<AtomicReference<Operation>> operationDonePredicate,
+ @Nullable Operation operation, long maxWaitSeconds) {
+ if (operation == null) { // Null can mean a delete op didn't need to occur.
+ return null;
+ }
AtomicReference<Operation> operationReference = Atomics.newReference(operation);
retry(operationDonePredicate, maxWaitSeconds, 1, SECONDS).apply(operationReference);
return operationReference.get();
[4/4] git commit: Migrate off PaginatedIterable to Iterator. Fix some
live test bugs.
Posted by ad...@apache.org.
Migrate off PaginatedIterable to Iterator. Fix some live test bugs.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/7427ba23
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/7427ba23
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/7427ba23
Branch: refs/heads/master
Commit: 7427ba23800dfa2bbc3f79473e5cd00ce9365deb
Parents: a9ea2ad
Author: Adrian Cole <ac...@twitter.com>
Authored: Tue Nov 4 11:19:22 2014 -0800
Committer: Adrian Cole <ac...@twitter.com>
Committed: Tue Nov 4 14:21:36 2014 -0800
----------------------------------------------------------------------
.../GoogleComputeEngineFallbacks.java | 11 +++
.../compute/GoogleComputeEngineService.java | 21 ++---
.../GoogleComputeEngineServiceAdapter.java | 81 ++++++++++----------
...GoogleComputeEngineServiceContextModule.java | 5 +-
...ogleComputeEngineSecurityGroupExtension.java | 25 +++---
.../functions/NetworkToSecurityGroup.java | 4 +-
.../features/AddressApi.java | 58 ++++----------
.../googlecomputeengine/features/DiskApi.java | 48 +++---------
.../features/DiskTypeApi.java | 45 +++--------
.../features/FirewallApi.java | 47 +++---------
.../features/ForwardingRuleApi.java | 15 ++--
.../features/GlobalOperationApi.java | 54 ++++---------
.../features/HttpHealthCheckApi.java | 13 ++--
.../googlecomputeengine/features/ImageApi.java | 48 +++---------
.../features/InstanceApi.java | 46 ++---------
.../features/MachineTypeApi.java | 42 +++-------
.../features/NetworkApi.java | 50 +++---------
.../googlecomputeengine/features/RegionApi.java | 49 +++---------
.../features/RegionOperationApi.java | 49 +++---------
.../googlecomputeengine/features/RouteApi.java | 44 +++--------
.../features/SnapshotApi.java | 49 +++---------
.../features/TargetPoolApi.java | 20 ++---
.../googlecomputeengine/features/ZoneApi.java | 45 +++--------
.../features/ZoneOperationApi.java | 48 +++---------
.../functions/internal/AdvancingIterator.java | 48 ++++++++++++
.../internal/BaseToIteratorOfListPage.java | 67 ++++++++++++++++
.../functions/internal/BaseToPagedIterable.java | 69 -----------------
.../BaseWithRegionToIteratorOfListPage.java | 71 +++++++++++++++++
.../internal/BaseWithRegionToPagedIterable.java | 72 -----------------
.../BaseWithZoneToIteratorOfListPage.java | 72 +++++++++++++++++
.../internal/BaseWithZoneToPagedIterable.java | 72 -----------------
.../functions/internal/ParseAddresses.java | 17 ++--
.../functions/internal/ParseDiskTypes.java | 17 ++--
.../functions/internal/ParseDisks.java | 16 ++--
.../functions/internal/ParseFirewalls.java | 15 ++--
.../internal/ParseForwardingRules.java | 16 ++--
.../internal/ParseGlobalOperations.java | 16 ++--
.../internal/ParseHttpHealthChecks.java | 15 ++--
.../functions/internal/ParseImages.java | 15 ++--
.../functions/internal/ParseInstances.java | 17 ++--
.../functions/internal/ParseMachineTypes.java | 17 ++--
.../functions/internal/ParseNetworks.java | 15 ++--
.../internal/ParseRegionOperations.java | 17 ++--
.../functions/internal/ParseRegions.java | 15 ++--
.../functions/internal/ParseRoutes.java | 15 ++--
.../functions/internal/ParseSnapshots.java | 15 ++--
.../functions/internal/ParseTargetPools.java | 15 ++--
.../functions/internal/ParseZoneOperations.java | 16 ++--
.../functions/internal/ParseZones.java | 15 ++--
.../googlecomputeengine/internal/ListPages.java | 42 ++++++++++
.../PageSystemExpectTest.java | 21 +++--
.../GoogleComputeEngineServiceExpectTest.java | 2 -
.../GoogleComputeEngineServiceLiveTest.java | 2 +-
.../functions/NetworkToSecurityGroupTest.java | 8 +-
.../features/AddressApiExpectTest.java | 7 +-
.../features/AddressApiLiveTest.java | 13 +---
.../features/DiskApiExpectTest.java | 7 +-
.../features/DiskApiLiveTest.java | 21 +++--
.../features/DiskTypeApiExpectTest.java | 6 +-
.../features/DiskTypeApiLiveTest.java | 20 ++---
.../features/FirewallApiExpectTest.java | 7 +-
.../features/FirewallApiLiveTest.java | 9 +--
.../features/ForwardingRuleApiExpectTest.java | 8 +-
.../features/GlobalOperationApiExpectTest.java | 6 +-
.../features/GlobalOperationApiLiveTest.java | 71 ++++++-----------
.../features/HttpHealthCheckApiExpectTest.java | 9 +--
.../features/ImageApiExpectTest.java | 7 +-
.../features/ImageApiLiveTest.java | 23 ++----
.../features/InstanceApiExpectTest.java | 6 +-
.../features/InstanceApiLiveTest.java | 74 +++++++++---------
.../features/MachineTypeApiExpectTest.java | 6 +-
.../features/MachineTypeApiLiveTest.java | 20 ++---
.../features/NetworkApiExpectTest.java | 10 +--
.../features/NetworkApiLiveTest.java | 15 ++--
.../features/RegionApiExpectTest.java | 7 +-
.../features/RegionApiLiveTest.java | 19 ++---
.../features/RegionOperationApiExpectTest.java | 7 +-
.../features/RegionOperationApiLiveTest.java | 71 ++++++-----------
.../features/RouteApiExpectTest.java | 7 +-
.../features/RouteApiLiveTest.java | 13 ++--
.../features/SnapshotApiExpectTest.java | 7 +-
.../features/SnapshotApiLiveTest.java | 20 +++--
.../features/TargetPoolApiExpectTest.java | 4 +-
.../features/TargetPoolApiLiveTest.java | 19 +++--
.../features/ZoneApiExpectTest.java | 7 +-
.../features/ZoneApiLiveTest.java | 18 ++---
.../features/ZoneOperationApiExpectTest.java | 9 +--
.../features/ZoneOperationApiLiveTest.java | 66 ++++++----------
.../BaseGoogleComputeEngineApiLiveTest.java | 43 ++++-------
89 files changed, 952 insertions(+), 1457 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineFallbacks.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineFallbacks.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineFallbacks.java
index 4cdbad1..4ba6eae 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineFallbacks.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineFallbacks.java
@@ -23,9 +23,13 @@ import static com.google.common.primitives.Ints.asList;
import static org.jclouds.Fallbacks.valOnNotFoundOr404;
import static org.jclouds.http.HttpUtils.returnValueOnCodeOrNull;
+import java.util.Iterator;
+
import org.jclouds.Fallback;
import org.jclouds.googlecomputeengine.domain.ListPage;
+import com.google.common.collect.Iterators;
+
public final class GoogleComputeEngineFallbacks {
public static class NullOn400or404 implements Fallback<Object> {
@Override public Object createOrPropagate(Throwable t) throws Exception {
@@ -35,9 +39,16 @@ public final class GoogleComputeEngineFallbacks {
throw propagate(t);
}
}
+
public static final class EmptyListPageOnNotFoundOr404 implements Fallback<Object> {
@Override public ListPage<Object> createOrPropagate(Throwable t) throws Exception {
return valOnNotFoundOr404(ListPage.create(null, null), t);
}
}
+
+ public static final class EmptyIteratorOnNotFoundOr404 implements Fallback<Object> {
+ @Override public Iterator<Object> createOrPropagate(Throwable t) throws Exception {
+ return valOnNotFoundOr404(Iterators.emptyIterator(), t);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
index d6418ea..a523e64 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
@@ -23,6 +23,7 @@ import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_S
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_INTERVAL;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
+import static org.jclouds.googlecomputeengine.internal.ListPages.concat;
import static org.jclouds.util.Predicates2.retry;
import java.util.Map;
@@ -72,7 +73,6 @@ import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
-import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Atomics;
import com.google.common.util.concurrent.ListeningExecutorService;
@@ -151,21 +151,14 @@ public class GoogleComputeEngineService extends BaseComputeService {
protected void cleanUpNetworksAndFirewallsForGroup(final String groupName) {
String resourceName = namingConvention.create().sharedNameForGroup(groupName);
- final Network network = api.getNetworkApi(project.get()).get(resourceName);
+ Network network = api.getNetworkApi(project.get()).get(resourceName);
FirewallApi firewallApi = api.getFirewallApi(project.get());
- Predicate<Firewall> firewallBelongsToNetwork = new Predicate<Firewall>() {
- @Override
- public boolean apply(Firewall input) {
- return input != null && input.network().equals(network.selfLink());
- }
- };
-
- Set<AtomicReference<Operation>> operations = Sets.newLinkedHashSet();
- for (Firewall firewall : firewallApi.list().concat().filter(firewallBelongsToNetwork)) {
- operations.add(new AtomicReference<Operation>(firewallApi.delete(firewall.name())));
- }
- for (AtomicReference<Operation> operation : operations) {
+ for (Firewall firewall : concat(firewallApi.list())) {
+ if (firewall == null || !firewall.network().equals(network.selfLink())) {
+ continue;
+ }
+ AtomicReference<Operation> operation = Atomics.newReference(firewallApi.delete(firewall.name()));
retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
MILLISECONDS).apply(operation);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
index f306d2d..3a80bea 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Iterables.contains;
import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Iterables.tryFind;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.CENTOS_PROJECT;
@@ -30,16 +31,19 @@ import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_I
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_INTERVAL;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
import static org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig.Type;
+import static org.jclouds.googlecomputeengine.internal.ListPages.concat;
import static org.jclouds.googlecomputeengine.predicates.InstancePredicates.isBootDisk;
import static org.jclouds.util.Predicates2.retry;
import java.net.URI;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
+import javax.inject.Inject;
import javax.inject.Named;
import org.jclouds.collect.Memoized;
@@ -61,6 +65,7 @@ import org.jclouds.googlecomputeengine.domain.Image;
import org.jclouds.googlecomputeengine.domain.Instance;
import org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk;
import org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk.Mode;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.MachineType;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.domain.Zone;
@@ -74,13 +79,13 @@ import com.google.common.base.Objects;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;
import com.google.common.util.concurrent.Atomics;
import com.google.common.util.concurrent.UncheckedTimeoutException;
-import com.google.inject.Inject;
public final class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<InstanceInZone, MachineTypeInZone, Image, Zone> {
@@ -241,25 +246,25 @@ public final class GoogleComputeEngineServiceAdapter implements ComputeServiceAd
@Override
public Iterable<MachineTypeInZone> listHardwareProfiles() {
- ImmutableSet.Builder<MachineTypeInZone> builder = ImmutableSet.builder();
+ ImmutableList.Builder<MachineTypeInZone> builder = ImmutableList.builder();
for (final Location zone : zones.get().values()) {
- builder.addAll(api.getMachineTypeApi(userProject.get())
- .listInZone(zone.getId())
- .concat()
- .filter(new Predicate<MachineType>() {
- @Override
- public boolean apply(MachineType input) {
- return input.deprecated() == null;
- }
- })
- .transform(new Function<MachineType, MachineTypeInZone>() {
-
- @Override
- public MachineTypeInZone apply(MachineType arg0) {
- return new MachineTypeInZone(arg0, arg0.zone());
- }
- }));
+ for (Iterator<ListPage<MachineType>> i = api.getMachineTypeApi(userProject.get()).listInZone(zone.getId());
+ i.hasNext(); ) {
+ builder.addAll(FluentIterable.from(i.next()).filter(new Predicate<MachineType>() {
+ @Override
+ public boolean apply(MachineType input) {
+ return input.deprecated() == null;
+ }
+ }).transform(new Function<MachineType, MachineTypeInZone>() {
+
+ @Override
+ public MachineTypeInZone apply(MachineType arg0) {
+ return new MachineTypeInZone(arg0, arg0.zone());
+ }
+ }));
+ }
+
}
return builder.build();
@@ -267,15 +272,14 @@ public final class GoogleComputeEngineServiceAdapter implements ComputeServiceAd
@Override
public Iterable<Image> listImages() {
- return ImmutableSet.<Image>builder()
- .addAll(api.getImageApi(userProject.get()).list().concat())
- .addAll(api.getImageApi(DEBIAN_PROJECT).list().concat())
- .addAll(api.getImageApi(CENTOS_PROJECT).list().concat())
- .build();
+ return Iterables.concat( //
+ concat(api.getImageApi(userProject.get()).list()), //
+ concat(api.getImageApi(DEBIAN_PROJECT).list()), //
+ concat(api.getImageApi(CENTOS_PROJECT).list()));
}
@SuppressWarnings("deprecation")
-@Override
+ @Override
public Image getImage(String id) {
return Objects.firstNonNull(api.getImageApi(userProject.get()).get(id),
Objects.firstNonNull(api.getImageApi(DEBIAN_PROJECT).get(id),
@@ -285,7 +289,7 @@ public final class GoogleComputeEngineServiceAdapter implements ComputeServiceAd
@Override
public Iterable<Zone> listLocations() {
- return api.getZoneApi(userProject.get()).list().concat();
+ return concat(api.getZoneApi(userProject.get()).list());
}
@Override
@@ -300,19 +304,18 @@ public final class GoogleComputeEngineServiceAdapter implements ComputeServiceAd
@Override
public Iterable<InstanceInZone> listNodes() {
- return FluentIterable.from(zones.get().values()).transformAndConcat(new Function<Location, ImmutableSet<InstanceInZone>>() {
- @Override
- public ImmutableSet<InstanceInZone> apply(final Location input) {
- return api.getInstanceApi(userProject.get()).listInZone(input.getId()).concat()
- .transform(new Function<Instance, InstanceInZone>() {
-
- @Override
- public InstanceInZone apply(Instance arg0) {
- return new InstanceInZone(arg0, input.getId());
- }
- }).toSet();
- }
- }).toSet();
+ return FluentIterable.from(zones.get().values())
+ .transformAndConcat(new Function<Location, Iterable<InstanceInZone>>() {
+ @Override
+ public Iterable<InstanceInZone> apply(final Location input) {
+ return transform(concat(api.getInstanceApi(userProject.get()).listInZone(input.getId())),
+ new Function<Instance, InstanceInZone>() {
+ @Override public InstanceInZone apply(Instance arg0) {
+ return new InstanceInZone(arg0, input.getId());
+ }
+ });
+ }
+ }).toList();
}
@Override
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/config/GoogleComputeEngineServiceContextModule.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/config/GoogleComputeEngineServiceContextModule.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/config/GoogleComputeEngineServiceContextModule.java
index 99f27e1..70c2b23 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/config/GoogleComputeEngineServiceContextModule.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/config/GoogleComputeEngineServiceContextModule.java
@@ -19,6 +19,7 @@ package org.jclouds.googlecomputeengine.compute.config;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Maps.uniqueIndex;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+import static org.jclouds.googlecomputeengine.internal.ListPages.concat;
import java.net.URI;
import java.util.Map;
@@ -212,7 +213,7 @@ public class GoogleComputeEngineServiceContextModule
new Supplier<Map<URI, ? extends Location>>() {
@Override
public Map<URI, ? extends Location> get() {
- return uniqueIndex(transform(api.getZoneApi(userProject.get()).list().concat(), zoneToLocation),
+ return uniqueIndex(transform(concat(api.getZoneApi(userProject.get()).list()), zoneToLocation),
new Function<Location, URI>() {
@Override
public URI apply(Location input) {
@@ -236,7 +237,7 @@ public class GoogleComputeEngineServiceContextModule
new Supplier<Map<URI, Region>>() {
@Override
public Map<URI, Region> get() {
- return uniqueIndex(api.getRegionApi(userProject.get()).list().concat(),
+ return uniqueIndex(concat(api.getRegionApi(userProject.get()).list()),
new Function<Region, URI>() {
@Override
public URI apply(Region input) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
index 3d46764..98abf0e 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
@@ -22,6 +22,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_INTERVAL;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
import static org.jclouds.googlecomputeengine.compute.strategy.CreateNodesWithGroupEncodedIntoNameThenAddToSet.DEFAULT_INTERNAL_NETWORK_RANGE;
+import static org.jclouds.googlecomputeengine.internal.ListPages.concat;
import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.equalsIpPermission;
import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.providesIpPermission;
import static org.jclouds.util.Predicates2.retry;
@@ -102,7 +103,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
@Override
public Set<SecurityGroup> listSecurityGroups() {
- return api.getNetworkApi(userProject.get()).list().concat().transform(groupConverter).toSet();
+ return FluentIterable.from(concat(api.getNetworkApi(userProject.get()).list())).transform(groupConverter).toSet();
}
@Override
@@ -172,7 +173,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
ListOptions options = new ListOptions.Builder().filter("network eq .*/" + id);
- FluentIterable<Firewall> fws = api.getFirewallApi(userProject.get()).list(options).concat();
+ FluentIterable<Firewall> fws = FluentIterable.from(concat(api.getFirewallApi(userProject.get()).list(options)));
for (Firewall fw : fws) {
AtomicReference<Operation> operation = Atomics
@@ -205,7 +206,8 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
ListOptions options = new ListOptions.Builder().filter("network eq .*/" + group.getName());
- if (api.getFirewallApi(userProject.get()).list(options).concat().anyMatch(providesIpPermission(ipPermission))) {
+ if (Iterables
+ .any(concat(api.getFirewallApi(userProject.get()).list(options)), providesIpPermission(ipPermission))) {
// Permission already exists.
return group;
}
@@ -267,7 +269,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
ListOptions options = new ListOptions.Builder().filter("network eq .*/" + group.getName());
- FluentIterable<Firewall> fws = api.getFirewallApi(userProject.get()).list(options).concat();
+ FluentIterable<Firewall> fws = FluentIterable.from(concat(api.getFirewallApi(userProject.get()).list(options)));
for (Firewall fw : fws) {
if (equalsIpPermission(ipPermission).apply(fw)) {
@@ -328,13 +330,14 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
private SecurityGroup groupForTagsInNetwork(Network nw, final Collection<String> tags) {
ListOptions opts = new Builder().filter("network eq .*/" + nw.name());
- List<Firewall> fws = api.getFirewallApi(userProject.get()).list(opts).concat().filter(new Predicate<Firewall>() {
- @Override public boolean apply(final Firewall input) {
- // If any of the targetTags on the firewall apply or the firewall has no target tags...
- return Iterables.any(input.targetTags(), Predicates.in(tags)) || Predicates.equalTo(0)
- .apply(input.targetTags().size());
- }
- }).toList();
+ List<Firewall> fws = FluentIterable.from(concat(api.getFirewallApi(userProject.get()).list(opts)))
+ .filter(new Predicate<Firewall>() {
+ @Override public boolean apply(final Firewall input) {
+ // If any of the targetTags on the firewall apply or the firewall has no target tags...
+ return Iterables.any(input.targetTags(), Predicates.in(tags)) || Predicates.equalTo(0)
+ .apply(input.targetTags().size());
+ }
+ }).toList();
if (fws.isEmpty()) {
return null;
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
index 8747b44..5c4d8ce 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
@@ -16,6 +16,8 @@
*/
package org.jclouds.googlecomputeengine.compute.functions;
+import static org.jclouds.googlecomputeengine.internal.ListPages.concat;
+
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
@@ -70,7 +72,7 @@ public class NetworkToSecurityGroup implements Function<Network, SecurityGroup>
ListOptions options = new ListOptions.Builder().filter("network eq .*/" + network.name());
- for (Firewall fw : api.getFirewallApi(project.get()).list(options).concat()) {
+ for (Firewall fw : concat(api.getFirewallApi(project.get()).list(options))) {
permBuilder.addAll(firewallToPerms.apply(fw));
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
index bbb65de..8babee2 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
@@ -19,6 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -30,9 +32,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.Address;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -65,7 +66,7 @@ public interface AddressApi {
* @param addressName name of the address resource to return.
* @return a Address resource.
*/
- @Named("Addresss:get")
+ @Named("Addresses:get")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/regions/{region}/addresses/{address}")
@@ -83,7 +84,7 @@ public interface AddressApi {
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
- @Named("Addresss:insert")
+ @Named("Addresses:insert")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@@ -100,7 +101,7 @@ public interface AddressApi {
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
- @Named("Addresss:delete")
+ @Named("Addresses:delete")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("/regions/{region}/addresses/{address}")
@@ -110,30 +111,6 @@ public interface AddressApi {
Operation deleteInRegion(@PathParam("region") String region, @PathParam("address") String addressName);
/**
- * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Addresss:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/regions/{region}/addresses")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseAddresses.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Address> listFirstPageInRegion(@PathParam("region") String region);
-
- /**
- * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Addresss:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/regions/{region}/addresses")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseAddresses.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Address> listAtMarkerInRegion(@PathParam("region") String region, @QueryParam("pageToken") @Nullable String marker);
-
- /**
* Retrieves the listPage of address resources contained within the specified project and region.
* By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has
* not been set.
@@ -145,7 +122,7 @@ public interface AddressApi {
* @see org.jclouds.googlecomputeengine.options.ListOptions
* @see org.jclouds.googlecomputeengine.domain.ListPage
*/
- @Named("Addresss:list")
+ @Named("Addresses:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/regions/{region}/addresses")
@@ -158,27 +135,26 @@ public interface AddressApi {
* A paged version of AddressApi#listPageInRegion(String)
*
* @param region the region to list in
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see org.jclouds.collect.PagedIterable
- * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @return an Iterator that is able to fetch additional pages when required
+ * @see #listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
- @Named("Addresss:list")
+ @Named("Addresses:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/regions/{region}/addresses")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseAddresses.class)
- @Transform(ParseAddresses.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Address> listInRegion(@PathParam("region") String region);
+ @Transform(ParseAddresses.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Address>> listInRegion(@PathParam("region") String region);
- @Named("Addresss:list")
+ @Named("Addresses:list")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/regions/{region}/addresses")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseAddresses.class)
- @Transform(ParseAddresses.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Address> listInRegion(@PathParam("region") String region, ListOptions options);
+ @Transform(ParseAddresses.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Address>> listInRegion(@PathParam("region") String region, ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
index 7159a6f..d38c48a 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
@@ -19,6 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -30,9 +32,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.binders.DiskCreationBinder;
import org.jclouds.googlecomputeengine.domain.Disk;
@@ -103,7 +104,7 @@ public interface DiskApi {
* @param diskName the name of disk.
* @param sizeGb the size of the disk
* @param zone the name of the zone where the disk is to be created.
- * @param diskCreationOption the options of the disk to create.
+ * @param options the options of the disk to create.
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
@@ -117,7 +118,7 @@ public interface DiskApi {
Operation createInZone(@PayloadParam("name") String diskName,
@PayloadParam("sizeGb") int sizeGb,
@PathParam("zone") String zone,
- @PayloadParam("options") DiskCreationOptions diskCreationOptions);
+ @PayloadParam("options") DiskCreationOptions options);
/**
* Deletes the specified persistent disk resource.
@@ -137,30 +138,6 @@ public interface DiskApi {
Operation deleteInZone(@PathParam("zone") String zone, @PathParam("disk") String diskName);
/**
- * @see DiskApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Disks:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/disks")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseDisks.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Disk> listFirstPageInZone(@PathParam("zone") String zone);
-
- /**
- * @see DiskApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Disks:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/disks")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseDisks.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Disk> listAtMarkerInZone(@PathParam("zone") String zone, @QueryParam("pageToken") @Nullable String marker);
-
- /**
* Retrieves the listPage of persistent disk resources contained within the specified project and zone.
* By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has
* not been set.
@@ -185,8 +162,7 @@ public interface DiskApi {
* A paged version of DiskApi#listPageInZone(String)
*
* @param zone the zone to list in
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see PagedIterable
+ * @return an Iterator that is able to fetch additional pages when required
* @see DiskApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Disks:list")
@@ -195,9 +171,9 @@ public interface DiskApi {
@Path("/zones/{zone}/disks")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseDisks.class)
- @Transform(ParseDisks.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Disk> listInZone(@PathParam("zone") String zone);
+ @Transform(ParseDisks.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Disk>> listInZone(@PathParam("zone") String zone);
@Named("Disks:list")
@GET
@@ -205,9 +181,9 @@ public interface DiskApi {
@Path("/zones/{zone}/disks")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseDisks.class)
- @Transform(ParseDisks.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Disk> listInZone(@PathParam("zone") String zone, ListOptions options);
+ @Transform(ParseDisks.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Disk>> listInZone(@PathParam("zone") String zone, ListOptions options);
/**
* Create a snapshot of a given disk in a zone.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskTypeApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskTypeApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskTypeApi.java
index ab72f4c..32cf465 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskTypeApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskTypeApi.java
@@ -18,6 +18,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -26,9 +28,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.DiskType;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -65,29 +66,7 @@ public interface DiskTypeApi {
@Path("/zones/{zone}/diskTypes/{diskType}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
- DiskType getInZone(@PathParam("zone") String zone, @PathParam("diskType") String diskTypeName);
-
- /**
- * @see DiskTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("DiskTypes:list")
- @GET
- @Path("/zones/{zone}/diskTypes")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseDiskTypes.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<DiskType> listFirstPageInZone(@PathParam("zone") String zone);
-
- /**
- * @see DiskTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("DiskTypes:list")
- @GET
- @Path("/zones/{zone}/diskType")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseDiskTypes.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<DiskType> listAtMarkerInZone(@PathParam("zone") String zone, @QueryParam("pageToken") @Nullable String marker);
+ DiskType getInZone(@PathParam("zone") String zone, @PathParam("diskType") String diskType);
/**
* Retrieves the list of disk type resources available to the specified project.
@@ -119,24 +98,22 @@ public interface DiskTypeApi {
@Path("/zones/{zone}/diskTypes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseDiskTypes.class)
- @Transform(ParseDiskTypes.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<DiskType> listInZone(@PathParam("zone") String zone);
+ @Transform(ParseDiskTypes.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<DiskType>> listInZone(@PathParam("zone") String zone);
/**
* @see DiskTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
*
* @param zone the zone to list in
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see PagedIterable
+ * @return an Iterator that is able to fetch additional pages when required
*/
@Named("DiskTypes:list")
@GET
@Path("/zones/{zone}/diskTypes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseDiskTypes.class)
- @Transform(ParseDiskTypes.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<DiskType> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
-
+ @Transform(ParseDiskTypes.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<DiskType>> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
index 1e161de..5a6567d 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
@@ -20,6 +20,7 @@ import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPU
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import java.net.URI;
+import java.util.Iterator;
import javax.inject.Named;
import javax.ws.rs.Consumes;
@@ -33,9 +34,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.binders.FirewallBinder;
import org.jclouds.googlecomputeengine.domain.Firewall;
@@ -149,36 +149,12 @@ public interface FirewallApi {
Operation delete(@PathParam("firewall") String firewallName);
/**
- * @see FirewallApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Firewalls:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/firewalls")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseFirewalls.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Firewall> listFirstPage();
-
- /**
- * @see FirewallApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Firewalls:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/firewalls")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseFirewalls.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Firewall> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
-
- /**
* Retrieves the list of firewall resources available to the specified project.
* By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
* been set.
*
- * @param marker marks the beginning of the next list page
- * @param listOptions listing options
+ * @param marker marks the beginning of the next list page
+ * @param options listing options
* @return a page of the list
* @see ListOptions
* @see org.jclouds.googlecomputeengine.domain.ListPage
@@ -201,15 +177,14 @@ public interface FirewallApi {
@Path("/global/firewalls")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseFirewalls.class)
- @Transform(ParseFirewalls.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Firewall> list();
+ @Transform(ParseFirewalls.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Firewall>> list();
/**
* A paged version of FirewallApi#list()
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see PagedIterable
+ * @return an Iterator that is able to fetch additional pages when required
* @see FirewallApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Firewalls:list")
@@ -218,7 +193,7 @@ public interface FirewallApi {
@Path("/global/firewalls")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseFirewalls.class)
- @Transform(ParseFirewalls.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Firewall> list(ListOptions options);
+ @Transform(ParseFirewalls.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Firewall>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApi.java
index 2e8820c..95009c0 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApi.java
@@ -20,6 +20,7 @@ import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPU
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import java.net.URI;
+import java.util.Iterator;
import javax.inject.Named;
import javax.ws.rs.Consumes;
@@ -31,9 +32,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.binders.ForwardingRuleCreationBinder;
import org.jclouds.googlecomputeengine.domain.ForwardingRule;
@@ -80,8 +80,6 @@ public interface ForwardingRuleApi {
* Creates a ForwardingRule resource in the specified project and region using the data included in the request.
*
* @param forwardingRuleName the name of the forwarding rule.
- * @param targetSelfLink the URL of the target resource to receive the matched traffic. The target resource must live
- * in the same region as this forwarding rule.
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
@@ -110,9 +108,8 @@ public interface ForwardingRuleApi {
@Nullable
Operation delete(@PathParam("forwardingRule") String forwardingRule);
-
/**
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @return an Iterator that is able to fetch additional pages when required
* @see org.jclouds.collect.PagedIterable
*/
@Named("ForwardingRules:list")
@@ -120,9 +117,9 @@ public interface ForwardingRuleApi {
@Path("/forwardingRules")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseForwardingRules.class)
- @Transform(ParseForwardingRules.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<ForwardingRule> list();
+ @Transform(ParseForwardingRules.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<ForwardingRule>> list();
@Named("ForwardingRules:list")
@GET
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
index 572af71..0d23b03 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
@@ -19,6 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -28,9 +30,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
@@ -79,30 +80,6 @@ public interface GlobalOperationApi {
void delete(@PathParam("operation") String operationName);
/**
- * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("GlobalOperations:list")
- @GET
- @Path("/global/operations")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
- @ResponseParser(ParseGlobalOperations.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Operation> listFirstPage();
-
- /**
- * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("GlobalOperations:list")
- @GET
- @Path("/global/operations")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
- @ResponseParser(ParseGlobalOperations.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Operation> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
-
- /**
* Retrieves the listFirstPage of operation resources contained within the specified project.
* By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
* has not been set.
@@ -110,8 +87,6 @@ public interface GlobalOperationApi {
* @param marker marks the beginning of the next list page
* @param listOptions listing options
* @return a page of the list, starting at marker
- * @see org.jclouds.googlecomputeengine.options.ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
*/
@Named("GlobalOperations:list")
@GET
@@ -120,11 +95,10 @@ public interface GlobalOperationApi {
@Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseGlobalOperations.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Operation> listAtMarker(@QueryParam("pageToken") @Nullable String marker,
- ListOptions listOptions);
+ ListPage<Operation> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
/**
- * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see GlobalOperationApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("GlobalOperations:list")
@GET
@@ -132,16 +106,15 @@ public interface GlobalOperationApi {
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseGlobalOperations.class)
- @Transform(ParseGlobalOperations.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Operation> list();
+ @Transform(ParseGlobalOperations.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Operation>> list();
/**
* A paged version of GlobalOperationApi#listFirstPage()
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see org.jclouds.collect.PagedIterable
- * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @return an Iterator that is able to fetch additional pages when required
+ * @see GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("GlobalOperations:list")
@GET
@@ -149,8 +122,7 @@ public interface GlobalOperationApi {
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseGlobalOperations.class)
- @Transform(ParseGlobalOperations.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Operation> list(ListOptions listOptions);
-
+ @Transform(ParseGlobalOperations.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Operation>> list(ListOptions listOptions);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
index 5974729..892bba3 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
@@ -20,6 +20,8 @@ import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPU
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -31,9 +33,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.binders.HttpHealthCheckCreationBinder;
import org.jclouds.googlecomputeengine.domain.HttpHealthCheck;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -120,16 +121,16 @@ public interface HttpHealthCheckApi {
Operation delete(@PathParam("httpHealthCheck") String httpHealthCheck);
/**
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @return an Iterator that is able to fetch additional pages when required
* @see org.jclouds.collect.PagedIterable
*/
@Named("HttpHealthChecks:list")
@GET
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseHttpHealthChecks.class)
- @Transform(ParseHttpHealthChecks.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<HttpHealthCheck> list();
+ @Transform(ParseHttpHealthChecks.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<HttpHealthCheck>> list();
/**
* @param options @see org.jclouds.googlecomputeengine.options.ListOptions
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
index 5521116..2b4562a 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
@@ -19,6 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -30,9 +32,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.Image;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -89,30 +90,6 @@ public interface ImageApi {
Operation delete(@PathParam("image") String imageName);
/**
- * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Images:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/images")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseImages.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Image> listFirstPage();
-
- /**
- * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Images:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/images")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseImages.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Image> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
-
- /**
* Retrieves the list of image resources available to the specified project.
* By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
* been set.
@@ -135,8 +112,7 @@ public interface ImageApi {
/**
* A paged version of ImageApi#list()
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see PagedIterable
+ * @return an Iterator that is able to fetch additional pages when required
* @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Images:list")
@@ -145,15 +121,14 @@ public interface ImageApi {
@Path("/global/images")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseImages.class)
- @Transform(ParseImages.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Image> list();
+ @Transform(ParseImages.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Image>> list();
/**
* A paged version of ImageApi#list()
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see PagedIterable
+ * @return an Iterator that is able to fetch additional pages when required
* @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Images:list")
@@ -162,9 +137,9 @@ public interface ImageApi {
@Path("/global/images")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseImages.class)
- @Transform(ParseImages.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Image> list(ListOptions options);
+ @Transform(ParseImages.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Image>> list(ListOptions options);
/**
* Creates an image resource in the specified project from the provided persistent disk.
@@ -182,5 +157,4 @@ public interface ImageApi {
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(BindToJsonPayload.class)
Operation createImageFromPD(@PayloadParam("name") String imageName, @PayloadParam("sourceDisk") String sourceDisk);
-
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
index f5f033b..35f12d9 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
@@ -19,6 +19,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import java.util.Iterator;
import java.util.Map;
import javax.inject.Named;
@@ -32,9 +33,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.binders.InstanceBinder;
import org.jclouds.googlecomputeengine.binders.MetadataBinder;
@@ -121,23 +121,6 @@ public interface InstanceApi {
Operation deleteInZone(@PathParam("zone") String zone, @PathParam("instance") String instanceName);
/**
- * A paged version of InstanceApi#listInZone()
- *
- * @param zone zone instances are in
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see PagedIterable
- * @see InstanceApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Instances:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/instances")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseInstances.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Instance> listFirstPageInZone(@PathParam("zone") String zone);
-
- /**
* Retrieves the list of instance resources available to the specified project.
* By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
* been set.
@@ -160,19 +143,6 @@ public interface InstanceApi {
ListOptions listOptions);
/**
- * @see InstanceApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Instances:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/instances")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseInstances.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Instance> listAtMarkerInZone(@PathParam("zone") String zone,
- @Nullable String marker);
-
- /**
* @see InstanceApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Instances:list")
@@ -181,9 +151,9 @@ public interface InstanceApi {
@Path("/zones/{zone}/instances")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseInstances.class)
- @Transform(ParseInstances.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Instance> listInZone(@PathParam("zone") String zone);
+ @Transform(ParseInstances.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Instance>> listInZone(@PathParam("zone") String zone);
/**
* @see InstanceApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions)
@@ -194,9 +164,9 @@ public interface InstanceApi {
@Path("/zones/{zone}/instances")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseInstances.class)
- @Transform(ParseInstances.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Instance> listInZone(@PathParam("zone") String zone, ListOptions options);
+ @Transform(ParseInstances.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Instance>> listInZone(@PathParam("zone") String zone, ListOptions options);
/**
* Adds an access config to an instance's network interface.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
index 0c5df8c..f78d12d 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
@@ -18,6 +18,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -26,9 +28,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.MachineType;
@@ -66,28 +67,6 @@ public interface MachineTypeApi {
MachineType getInZone(@PathParam("zone") String zone, @PathParam("machineType") String machineTypeName);
/**
- * @see MachineTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("MachineTypes:list")
- @GET
- @Path("/zones/{zone}/machineTypes")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseMachineTypes.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<MachineType> listFirstPageInZone(@PathParam("zone") String zone);
-
- /**
- * @see MachineTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("MachineTypes:list")
- @GET
- @Path("/zones/{zone}/machineTypes")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseMachineTypes.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<MachineType> listAtMarkerInZone(@PathParam("zone") String zone, @QueryParam("pageToken") @Nullable String marker);
-
- /**
* Retrieves the list of machine type resources available to the specified project.
* By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
* been set.
@@ -117,16 +96,15 @@ public interface MachineTypeApi {
@Path("/zones/{zone}/machineTypes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseMachineTypes.class)
- @Transform(ParseMachineTypes.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<MachineType> listInZone(@PathParam("zone") String zone);
+ @Transform(ParseMachineTypes.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<MachineType>> listInZone(@PathParam("zone") String zone);
/**
* A paged version of MachineTypeApi#listInZone(String)
*
* @param zone the zone to list in
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see PagedIterable
+ * @return an Iterator that is able to fetch additional pages when required
* @see MachineTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("MachineTypes:list")
@@ -134,8 +112,8 @@ public interface MachineTypeApi {
@Path("/zones/{zone}/machineTypes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseMachineTypes.class)
- @Transform(ParseMachineTypes.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<MachineType> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
+ @Transform(ParseMachineTypes.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<MachineType>> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
index 88ac001..c998be5 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
@@ -19,6 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -30,9 +32,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Network;
@@ -126,39 +127,14 @@ public interface NetworkApi {
Operation delete(@PathParam("network") String networkName);
/**
- * @see NetworkApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Networks:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/networks")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseNetworks.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Network> listFirstPage();
-
- /**
- * @see NetworkApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Networks:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/networks")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseNetworks.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Network> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
-
- /**
* Retrieves the list of persistent network resources contained within the specified project.
* By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
* been set.
*
* @param marker marks the beginning of the next list page
- * @param listOptions listing options
+ * @param options listing options
* @return a page of the list
* @see ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
*/
@Named("Networks:list")
@GET
@@ -167,8 +143,7 @@ public interface NetworkApi {
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseNetworks.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Network> listAtMarker(@QueryParam("pageToken") @Nullable String marker,
- ListOptions options);
+ ListPage<Network> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions options);
/**
* @see NetworkApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
@@ -179,15 +154,14 @@ public interface NetworkApi {
@Path("/global/networks")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseNetworks.class)
- @Transform(ParseNetworks.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Network> list();
+ @Transform(ParseNetworks.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Network>> list();
/**
* A paged version of NetworkApi#list()
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see PagedIterable
+ * @return an Iterator that is able to fetch additional pages when required
* @see NetworkApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Networks:list")
@@ -196,7 +170,7 @@ public interface NetworkApi {
@Path("/global/networks")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseNetworks.class)
- @Transform(ParseNetworks.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Network> list(ListOptions options);
+ @Transform(ParseNetworks.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Network>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
index ae760a0..6480a14 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
@@ -18,6 +18,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -25,9 +27,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Region;
@@ -63,37 +64,12 @@ public interface RegionApi {
Region get(@PathParam("region") String regionName);
/**
- * @see org.jclouds.googlecomputeengine.features.RegionApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Regions:list")
- @GET
- @Path("/regions")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseRegions.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Region> listFirstPage();
-
- /**
- * @see org.jclouds.googlecomputeengine.features.RegionApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Regions:list")
- @GET
- @Path("/regions")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseRegions.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Region> listAtMarker(String marker);
-
- /**
* Retrieves the listFirstPage of region resources available to the specified project.
* By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
* has not been set.
*
* @param marker marks the beginning of the next list page
* @param listOptions listing options
- * @return a page of the listFirstPage
- * @see org.jclouds.googlecomputeengine.options.ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
*/
@Named("Regions:list")
@GET
@@ -104,30 +80,29 @@ public interface RegionApi {
ListPage<Region> listAtMarker(String marker, ListOptions listOptions);
/**
- * @see org.jclouds.googlecomputeengine.features.RegionApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see RegionApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Regions:list")
@GET
@Path("/regions")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseRegions.class)
- @Transform(ParseRegions.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Region> list();
+ @Transform(ParseRegions.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Region>> list();
/**
* A paged version of RegionApi#listFirstPage()
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see org.jclouds.googlecomputeengine.features.RegionApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- * @see org.jclouds.collect.PagedIterable
+ * @return an Iterator that is able to fetch additional pages when required
+ * @see RegionApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Regions:list")
@GET
@Path("/regions")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseRegions.class)
- @Transform(ParseRegions.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Region> list(ListOptions listOptions);
+ @Transform(ParseRegions.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Region>> list(ListOptions listOptions);
}
[3/4] Migrate off PaginatedIterable to Iterator. Fix some live test
bugs.
Posted by ad...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
index 9985483..5a2f662 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
@@ -19,6 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -28,9 +30,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
@@ -81,31 +82,6 @@ public interface RegionOperationApi {
void deleteInRegion(@PathParam("region") String region, @PathParam("operation") String operationName);
/**
- * @see org.jclouds.googlecomputeengine.features.RegionOperationApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("RegionOperations:list")
- @GET
- @Path("/regions/{region}/operations")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
- @ResponseParser(ParseRegionOperations.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Operation> listFirstPageInRegion(@PathParam("region") String region);
-
- /**
- * @see org.jclouds.googlecomputeengine.features.RegionOperationApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("RegionOperations:list")
- @GET
- @Path("/regions/{region}/operations")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
- @ResponseParser(ParseRegionOperations.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Operation> listAtMarkerInRegion(@PathParam("region") String region,
- @QueryParam("pageToken") @Nullable String marker);
-
- /**
* Retrieves the listFirstPage of operation resources contained within the specified project.
* By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
* has not been set.
@@ -129,7 +105,7 @@ public interface RegionOperationApi {
ListOptions listOptions);
/**
- * @see org.jclouds.googlecomputeengine.features.RegionOperationApi#listInRegion(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see RegionOperationApi#listInRegion(String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("RegionOperations:list")
@GET
@@ -137,16 +113,16 @@ public interface RegionOperationApi {
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseRegionOperations.class)
- @Transform(ParseRegionOperations.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Operation> listInRegion(@PathParam("region") String region);
+ @Transform(ParseRegionOperations.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Operation>> listInRegion(@PathParam("region") String region);
/**
* A paged version of RegionOperationApi#listFirstPage(String)
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @return an Iterator that is able to fetch additional pages when required
* @see org.jclouds.collect.PagedIterable
- * @see org.jclouds.googlecomputeengine.features.RegionOperationApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see RegionOperationApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("RegionOperations:list")
@GET
@@ -154,8 +130,7 @@ public interface RegionOperationApi {
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseRegionOperations.class)
- @Transform(ParseRegionOperations.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Operation> listInRegion(@PathParam("region") String region, ListOptions listOptions);
-
+ @Transform(ParseRegionOperations.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Operation>> listInRegion(@PathParam("region") String region, ListOptions listOptions);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
index 1d8b0eb..a2916cc 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
@@ -20,6 +20,7 @@ import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPU
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import java.net.URI;
+import java.util.Iterator;
import javax.inject.Named;
import javax.ws.rs.Consumes;
@@ -31,9 +32,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.binders.RouteBinder;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -75,28 +75,6 @@ public interface RouteApi {
Route get(@PathParam("route") String routeName);
/**
- * @see org.jclouds.googlecomputeengine.features.RouteApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Routes:list")
- @GET
- @Path("/global/routes")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseRoutes.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Route> listFirstPage();
-
- /**
- * @see org.jclouds.googlecomputeengine.features.RouteApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Routes:list")
- @GET
- @Path("/global/routes")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseRoutes.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Route> listAtMarker(String marker);
-
- /**
* Retrieves the listFirstPage of route resources available to the specified project.
* By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
* has not been set.
@@ -116,22 +94,22 @@ public interface RouteApi {
ListPage<Route> listAtMarker(String marker, ListOptions listOptions);
/**
- * @see org.jclouds.googlecomputeengine.features.RouteApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see RouteApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Routes:list")
@GET
@Path("/global/routes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseRoutes.class)
- @Transform(ParseRoutes.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Route> list();
+ @Transform(ParseRoutes.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Route>> list();
/**
* A paged version of RegionApi#listFirstPage()
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see org.jclouds.googlecomputeengine.features.RouteApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @return an Iterator that is able to fetch additional pages when required
+ * @see RouteApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
* @see org.jclouds.collect.PagedIterable
*/
@Named("Routes:list")
@@ -139,9 +117,9 @@ public interface RouteApi {
@Path("/global/routes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseRoutes.class)
- @Transform(ParseRoutes.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Route> list(ListOptions listOptions);
+ @Transform(ParseRoutes.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Route>> list(ListOptions listOptions);
/**
* Deletes the specified route resource.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
index 282ad07..840f1d4 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
@@ -19,6 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -28,9 +30,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
@@ -85,39 +86,12 @@ public interface SnapshotApi {
Operation delete(@PathParam("snapshot") String snapshotName);
/**
- * @see org.jclouds.googlecomputeengine.features.SnapshotApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Snapshots:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/snapshots")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseSnapshots.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Snapshot> listFirstPage();
-
- /**
- * @see org.jclouds.googlecomputeengine.features.SnapshotApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Snapshots:list")
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/snapshots")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseSnapshots.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Snapshot> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
-
- /**
* Retrieves the listPage of persistent disk resources contained within the specified project and zone.
* By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has
* not been set.
*
* @param marker marks the beginning of the next list page
* @param listOptions listing options
- * @return a page of the listPage
- * @see org.jclouds.googlecomputeengine.options.ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
*/
@Named("Snapshots:list")
@GET
@@ -131,9 +105,7 @@ public interface SnapshotApi {
/**
* A paged version of SnapshotApi#listPage(String)
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see org.jclouds.collect.PagedIterable
- * @see org.jclouds.googlecomputeengine.features.SnapshotApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @return an Iterator that is able to fetch additional pages when required
*/
@Named("Snapshots:list")
@GET
@@ -141,9 +113,9 @@ public interface SnapshotApi {
@Path("/global/snapshots")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseSnapshots.class)
- @Transform(ParseSnapshots.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Snapshot> list();
+ @Transform(ParseSnapshots.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Snapshot>> list();
@Named("Snapshots:list")
@GET
@@ -151,8 +123,7 @@ public interface SnapshotApi {
@Path("/global/snapshots")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseSnapshots.class)
- @Transform(ParseSnapshots.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Snapshot> list(ListOptions options);
-
+ @Transform(ParseSnapshots.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Snapshot>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
index 5725937..a630fd7 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
@@ -20,6 +20,7 @@ import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPU
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import java.net.URI;
+import java.util.Iterator;
import java.util.List;
import javax.inject.Named;
@@ -33,9 +34,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeHealthChecksBinder;
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeInstancesBinder;
@@ -112,7 +112,7 @@ public interface TargetPoolApi {
Operation delete(@PathParam("targetPool") String targetPool);
/**
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @return an Iterator that is able to fetch additional pages when required
* @see org.jclouds.collect.PagedIterable
*/
@Named("TargetPools:list")
@@ -120,9 +120,9 @@ public interface TargetPoolApi {
@Path("/targetPools")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseTargetPools.class)
- @Transform(ParseTargetPools.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<TargetPool> list();
+ @Transform(ParseTargetPools.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<TargetPool>> list();
/**
* @param options @see org.jclouds.googlecomputeengine.options.ListOptions
@@ -140,7 +140,7 @@ public interface TargetPoolApi {
* Adds instance to the targetPool.
*
* @param targetPool the name of the target pool.
- * @param instanceName the name for the instance to be added to targetPool.
+ * @param instances the self-links of the instances to be added to targetPool.
*
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
@@ -157,7 +157,7 @@ public interface TargetPoolApi {
* Removes instance URL from targetPool.
*
* @param targetPool the name of the target pool.
- * @param instanceName the name for the instance to be removed from targetPool.
+ * @param instances the self-links of the instances to be removed from the targetPool.
*
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
@@ -174,7 +174,7 @@ public interface TargetPoolApi {
* Adds health check URL to targetPool.
*
* @param targetPool the name of the target pool.
- * @param healthCheck the name for the healthCheck to be added to targetPool.
+ * @param healthChecks the self-links of the health checks to be added to targetPool.
*
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
@@ -192,7 +192,7 @@ public interface TargetPoolApi {
* Removes health check URL from targetPool.
*
* @param targetPool the name of the target pool.
- * @param the name for the instance to be removed from targetPool.
+ * @param healthChecks the self-links of the health checks to be removed from the targetPool.
*
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
index 61293b2..b043900 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
@@ -18,6 +18,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -25,9 +27,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Zone;
@@ -63,37 +64,12 @@ public interface ZoneApi {
Zone get(@PathParam("zone") String zoneName);
/**
- * @see ZoneApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Zones:list")
- @GET
- @Path("/zones")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseZones.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Zone> listFirstPage();
-
- /**
- * @see ZoneApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("Zones:list")
- @GET
- @Path("/zones")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseZones.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Zone> listAtMarker(String marker);
-
- /**
* Retrieves the listFirstPage of zone resources available to the specified project.
* By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
* has not been set.
*
* @param marker marks the beginning of the next list page
* @param listOptions listing options
- * @return a page of the listFirstPage
- * @see ListOptions
- * @see ListPage
*/
@Named("Zones:list")
@GET
@@ -111,23 +87,22 @@ public interface ZoneApi {
@Path("/zones")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseZones.class)
- @Transform(ParseZones.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Zone> list();
+ @Transform(ParseZones.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Zone>> list();
/**
* A paged version of ZoneApi#listFirstPage()
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @return an Iterator that is able to fetch additional pages when required
* @see ZoneApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- * @see PagedIterable
*/
@Named("Zones:list")
@GET
@Path("/zones")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseZones.class)
- @Transform(ParseZones.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Zone> list(ListOptions listOptions);
+ @Transform(ParseZones.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Zone>> list(ListOptions listOptions);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
index 8d6a0d1..d486ea2 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
@@ -19,6 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import java.util.Iterator;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -28,9 +30,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
@@ -81,31 +82,6 @@ public interface ZoneOperationApi {
void deleteInZone(@PathParam("zone") String zone, @PathParam("operation") String operationName);
/**
- * @see ZoneOperationApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("ZoneOperations:list")
- @GET
- @Path("/zones/{zone}/operations")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
- @ResponseParser(ParseZoneOperations.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Operation> listFirstPageInZone(@PathParam("zone") String zone);
-
- /**
- * @see ZoneOperationApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("ZoneOperations:list")
- @GET
- @Path("/zones/{zone}/operations")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
- @ResponseParser(ParseZoneOperations.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Operation> listAtMarkerInZone(@PathParam("zone") String zone,
- @QueryParam("pageToken") @Nullable String marker);
-
- /**
* Retrieves the listFirstPage of operation resources contained within the specified project.
* By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
* has not been set.
@@ -114,8 +90,6 @@ public interface ZoneOperationApi {
* @param marker marks the beginning of the next list page
* @param listOptions listing options
* @return a page of the list, starting at marker
- * @see ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
*/
@Named("ZoneOperations:list")
@GET
@@ -137,15 +111,14 @@ public interface ZoneOperationApi {
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseZoneOperations.class)
- @Transform(ParseZoneOperations.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Operation> listInZone(@PathParam("zone") String zone);
+ @Transform(ParseZoneOperations.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Operation>> listInZone(@PathParam("zone") String zone);
/**
* A paged version of ZoneOperationApi#listFirstPageInZone(String)
*
- * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
- * @see PagedIterable
+ * @return an Iterator that is able to fetch additional pages when required
* @see ZoneOperationApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("ZoneOperations:list")
@@ -154,8 +127,7 @@ public interface ZoneOperationApi {
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseZoneOperations.class)
- @Transform(ParseZoneOperations.ToPagedIterable.class)
- @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
- PagedIterable<Operation> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
-
+ @Transform(ParseZoneOperations.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<Operation>> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/AdvancingIterator.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/AdvancingIterator.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/AdvancingIterator.java
new file mode 100644
index 0000000..73054b4
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/AdvancingIterator.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+
+import com.google.common.base.Function;
+import com.google.common.collect.AbstractIterator;
+
+final class AdvancingIterator<T> extends AbstractIterator<ListPage<T>> {
+
+ private final Function<String, ListPage<T>> tokenToNext;
+ private ListPage<T> current;
+ private boolean unread = true;
+
+ AdvancingIterator(ListPage<T> initial, Function<String, ListPage<T>> tokenToNext) {
+ this.current = initial;
+ this.tokenToNext = tokenToNext;
+ }
+
+ @Override protected ListPage<T> computeNext() {
+ if (unread) {
+ try {
+ return current;
+ } finally {
+ unread = false;
+ }
+ } else if (current.nextPageToken() != null) {
+ return current = tokenToNext.apply(current.nextPageToken());
+ } else {
+ return endOfData();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToIteratorOfListPage.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToIteratorOfListPage.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToIteratorOfListPage.java
new file mode 100644
index 0000000..05cc6ee
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToIteratorOfListPage.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.collect.Iterables.tryFind;
+
+import java.util.Iterator;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.InvocationContext;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterators;
+
+@Beta
+public abstract class BaseToIteratorOfListPage<T, I extends BaseToIteratorOfListPage<T, I>>
+ implements Function<ListPage<T>, Iterator<ListPage<T>>>, InvocationContext<I> {
+
+ private GeneratedHttpRequest request;
+
+ @Override
+ public Iterator<ListPage<T>> apply(ListPage<T> input) {
+ if (input.nextPageToken() == null) {
+ return Iterators.singletonIterator(input);
+ }
+
+ Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
+
+ Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
+
+ assert project.isPresent() :
+ String.format("programming error, method %s should have a string param for the " + "project",
+ request.getCaller().get().getInvokable());
+
+ return new AdvancingIterator<T>(input,
+ fetchNextPage(project.get().toString(), (ListOptions) listOptions.orNull()));
+ }
+
+ protected abstract Function<String, ListPage<T>> fetchNextPage(String projectName, ListOptions listOptions);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public I setContext(HttpRequest request) {
+ this.request = GeneratedHttpRequest.class.cast(request);
+ return (I) this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToPagedIterable.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToPagedIterable.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToPagedIterable.java
deleted file mode 100644
index bf91986..0000000
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToPagedIterable.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecomputeengine.functions.internal;
-
-import static com.google.common.base.Predicates.instanceOf;
-import static com.google.common.collect.Iterables.tryFind;
-
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.collect.PagedIterables;
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.InvocationContext;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-
-@Beta
-public abstract class BaseToPagedIterable<T, I extends BaseToPagedIterable<T, I>> implements
- Function<ListPage<T>, PagedIterable<T>>, InvocationContext<I> {
-
- private GeneratedHttpRequest request;
-
- @Override
- public PagedIterable<T> apply(ListPage<T> input) {
- if (input.nextPageToken() == null) {
- return PagedIterables.onlyPage(IterableWithMarkers.from(input));
- }
-
- Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
-
- Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
-
- assert project.isPresent() :
- String.format("programming error, method %s should have a string param for the " + "project",
- request.getCaller().get().getInvokable());
-
- return PagedIterables.advance(IterableWithMarkers.from(input, input.nextPageToken()),
- fetchNextPage(project.get().toString(), (ListOptions) listOptions.orNull()));
- }
-
- protected abstract Function<Object, IterableWithMarker<T>> fetchNextPage(String projectName,
- ListOptions listOptions);
-
- @SuppressWarnings("unchecked")
- @Override
- public I setContext(HttpRequest request) {
- this.request = GeneratedHttpRequest.class.cast(request);
- return (I) this;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToIteratorOfListPage.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToIteratorOfListPage.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToIteratorOfListPage.java
new file mode 100644
index 0000000..e522dc0
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToIteratorOfListPage.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.collect.Iterables.tryFind;
+
+import java.util.Iterator;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.InvocationContext;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterators;
+
+@Beta
+public abstract class BaseWithRegionToIteratorOfListPage<T, I extends BaseWithRegionToIteratorOfListPage<T, I>>
+ implements Function<ListPage<T>, Iterator<ListPage<T>>>, InvocationContext<I> {
+
+ private GeneratedHttpRequest request;
+
+ @Override public Iterator<ListPage<T>> apply(ListPage<T> input) {
+ if (input.nextPageToken() == null)
+ return Iterators.singletonIterator(input);
+
+ Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
+
+ Optional<Object> region = tryFind(request.getInvocation().getArgs(), instanceOf(String.class));
+
+ Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
+
+ assert project.isPresent() : String.format("programming error, method %s should have a string param for the "
+ + "project", request.getCaller().get().getInvokable());
+
+ assert region.isPresent() : String.format("programming error, method %s should have a string param for the "
+ + "region", request.getCaller().get().getInvokable());
+
+ return new AdvancingIterator<T>(input,
+ fetchNextPage(project.get().toString(), region.get().toString(), (ListOptions) listOptions.orNull()));
+ }
+
+ protected abstract Function<String, ListPage<T>> fetchNextPage(String projectName,
+ String regionName,
+ ListOptions listOptions);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public I setContext(HttpRequest request) {
+ this.request = GeneratedHttpRequest.class.cast(request);
+ return (I) this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java
deleted file mode 100644
index b02422c..0000000
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecomputeengine.functions.internal;
-
-import static com.google.common.base.Predicates.instanceOf;
-import static com.google.common.collect.Iterables.tryFind;
-
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.collect.PagedIterables;
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.InvocationContext;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-
-@Beta
-public abstract class BaseWithRegionToPagedIterable<T, I extends BaseWithRegionToPagedIterable<T, I>> implements
- Function<ListPage<T>, PagedIterable<T>>, InvocationContext<I> {
-
- private GeneratedHttpRequest request;
-
- @Override public PagedIterable<T> apply(ListPage<T> input) {
- if (input.nextPageToken() == null)
- return PagedIterables.onlyPage(IterableWithMarkers.from(input));
-
- Optional <Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
-
- Optional<Object> region = tryFind(request.getInvocation().getArgs(), instanceOf(String.class));
-
- Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
-
- assert project.isPresent() : String.format("programming error, method %s should have a string param for the "
- + "project", request.getCaller().get().getInvokable());
-
- assert region.isPresent() : String.format("programming error, method %s should have a string param for the "
- + "region", request.getCaller().get().getInvokable());
-
- return PagedIterables.advance(IterableWithMarkers.from(input, input.nextPageToken()),
- fetchNextPage(project.get().toString(), region.get().toString(), (ListOptions) listOptions.orNull()));
- }
-
- protected abstract Function<Object, IterableWithMarker<T>> fetchNextPage(String projectName,
- String regionName,
- ListOptions listOptions);
-
- @SuppressWarnings("unchecked")
- @Override
- public I setContext(HttpRequest request) {
- this.request = GeneratedHttpRequest.class.cast(request);
- return (I) this;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToIteratorOfListPage.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToIteratorOfListPage.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToIteratorOfListPage.java
new file mode 100644
index 0000000..4d4b576
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToIteratorOfListPage.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.collect.Iterables.tryFind;
+
+import java.util.Iterator;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.InvocationContext;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterators;
+
+@Beta
+public abstract class BaseWithZoneToIteratorOfListPage<T, I extends BaseWithZoneToIteratorOfListPage<T, I>>
+ implements Function<ListPage<T>, Iterator<ListPage<T>>>, InvocationContext<I> {
+
+ private GeneratedHttpRequest request;
+
+ @Override public Iterator<ListPage<T>> apply(ListPage<T> input) {
+ if (input.nextPageToken() == null) {
+ return Iterators.singletonIterator(input);
+ }
+
+ Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
+
+ Optional<Object> zone = tryFind(request.getInvocation().getArgs(), instanceOf(String.class));
+
+ Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
+
+ assert project.isPresent() : String.format("programming error, method %s should have a string param for the "
+ + "project", request.getCaller().get().getInvokable());
+
+ assert zone.isPresent() : String.format("programming error, method %s should have a string param for the "
+ + "zone", request.getCaller().get().getInvokable());
+
+ return new AdvancingIterator<T>(input,
+ fetchNextPage(project.get().toString(), zone.get().toString(), (ListOptions) listOptions.orNull()));
+ }
+
+ protected abstract Function<String, ListPage<T>> fetchNextPage(String projectName,
+ String zoneName,
+ ListOptions listOptions);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public I setContext(HttpRequest request) {
+ this.request = GeneratedHttpRequest.class.cast(request);
+ return (I) this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java
deleted file mode 100644
index 312ff10..0000000
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecomputeengine.functions.internal;
-
-import static com.google.common.base.Predicates.instanceOf;
-import static com.google.common.collect.Iterables.tryFind;
-
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.collect.PagedIterables;
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.InvocationContext;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-
-@Beta
-public abstract class BaseWithZoneToPagedIterable<T, I extends BaseWithZoneToPagedIterable<T, I>> implements
- Function<ListPage<T>, PagedIterable<T>>, InvocationContext<I> {
-
- private GeneratedHttpRequest request;
-
- @Override public PagedIterable<T> apply(ListPage<T> input) {
- if (input.nextPageToken() == null)
- return PagedIterables.onlyPage(IterableWithMarkers.from(input));
-
- Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
-
- Optional<Object> zone = tryFind(request.getInvocation().getArgs(), instanceOf(String.class));
-
- Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
-
- assert project.isPresent() : String.format("programming error, method %s should have a string param for the "
- + "project", request.getCaller().get().getInvokable());
-
- assert zone.isPresent() : String.format("programming error, method %s should have a string param for the "
- + "zone", request.getCaller().get().getInvokable());
-
- return PagedIterables.advance(IterableWithMarkers.from(input, input.nextPageToken()),
- fetchNextPage(project.get().toString(), zone.get().toString(), (ListOptions) listOptions.orNull()));
- }
-
- protected abstract Function<Object, IterableWithMarker<T>> fetchNextPage(String projectName,
- String zoneName,
- ListOptions listOptions);
-
- @SuppressWarnings("unchecked")
- @Override
- public I setContext(HttpRequest request) {
- this.request = GeneratedHttpRequest.class.cast(request);
- return (I) this;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
index 22da307..24245af 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.Address;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -37,22 +35,19 @@ public final class ParseAddresses extends ParseJson<ListPage<Address>> {
});
}
- public static class ToPagedIterable extends BaseWithRegionToPagedIterable<Address, ToPagedIterable> {
+ public static class ToIteratorOfListPage extends BaseWithRegionToIteratorOfListPage<Address, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<Address>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<Address>> fetchNextPage(final String projectName,
final String regionName, final ListOptions options) {
- return new Function<Object, IterableWithMarker<Address>>() {
-
- @Override public IterableWithMarker<Address> apply(Object input) {
- ListPage<Address> result = api.getAddressApi(projectName)
- .listAtMarkerInRegion(regionName, input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Address>>() {
+ @Override public ListPage<Address> apply(String input) {
+ return api.getAddressApi(projectName).listAtMarkerInRegion(regionName, input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java
index b62f719..060460d 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.DiskType;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -37,22 +35,19 @@ public final class ParseDiskTypes extends ParseJson<ListPage<DiskType>> {
});
}
- public static class ToPagedIterable extends BaseWithZoneToPagedIterable<DiskType, ToPagedIterable> {
+ public static class ToIteratorOfListPage extends BaseWithZoneToIteratorOfListPage<DiskType, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<DiskType>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<DiskType>> fetchNextPage(final String projectName,
final String zoneName, final ListOptions options) {
- return new Function<Object, IterableWithMarker<DiskType>>() {
-
- @Override public IterableWithMarker<DiskType> apply(Object input) {
- ListPage<DiskType> result = api.getDiskTypeApi(projectName)
- .listAtMarkerInZone(zoneName, input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<DiskType>>() {
+ @Override public ListPage<DiskType> apply(String input) {
+ return api.getDiskTypeApi(projectName).listAtMarkerInZone(zoneName, input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
index 03dd198..02361e7 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.Disk;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -37,22 +35,20 @@ public final class ParseDisks extends ParseJson<ListPage<Disk>> {
});
}
- public static class ToPagedIterable extends BaseWithZoneToPagedIterable<Disk, ToPagedIterable> {
+ public static class ToIteratorOfListPage extends BaseWithZoneToIteratorOfListPage<Disk, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<Disk>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<Disk>> fetchNextPage(final String projectName,
final String zoneName, final ListOptions options) {
- return new Function<Object, IterableWithMarker<Disk>>() {
+ return new Function<String, ListPage<Disk>>() {
- @Override public IterableWithMarker<Disk> apply(Object input) {
- ListPage<Disk> result = api.getDiskApi(projectName)
- .listAtMarkerInZone(zoneName, input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ @Override public ListPage<Disk> apply(String input) {
+ return api.getDiskApi(projectName).listAtMarkerInZone(zoneName, input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
index 732ad3f..348d7a4 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.Firewall;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -37,20 +35,19 @@ public final class ParseFirewalls extends ParseJson<ListPage<Firewall>> {
});
}
- public static final class ToPagedIterable extends BaseToPagedIterable<Firewall, ToPagedIterable> {
+ public static final class ToIteratorOfListPage extends BaseToIteratorOfListPage<Firewall, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<Firewall>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<Firewall>> fetchNextPage(final String projectName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<Firewall>>() {
- @Override public IterableWithMarker<Firewall> apply(Object input) {
- ListPage<Firewall> result = api.getFirewallApi(projectName).listAtMarker(input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Firewall>>() {
+ @Override public ListPage<Firewall> apply(String input) {
+ return api.getFirewallApi(projectName).listAtMarker(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java
index 4805179..e7e1826 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ForwardingRule;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -37,21 +35,21 @@ public final class ParseForwardingRules extends ParseJson<ListPage<ForwardingRul
});
}
- public static class ToPagedIterable extends BaseWithRegionToPagedIterable<ForwardingRule, ToPagedIterable> {
+ public static class ToIteratorOfListPage
+ extends BaseWithRegionToIteratorOfListPage<ForwardingRule, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<ForwardingRule>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<ForwardingRule>> fetchNextPage(final String projectName,
final String regionName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<ForwardingRule>>() {
- @Override public IterableWithMarker<ForwardingRule> apply(Object input) {
- ListPage<ForwardingRule> result = api.getForwardingRuleApi(projectName, regionName).list(options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<ForwardingRule>>() {
+ @Override public ListPage<ForwardingRule> apply(String input) {
+ return api.getForwardingRuleApi(projectName, regionName).list(options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
index 9aa079a..99935e4 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
@@ -37,22 +35,20 @@ public final class ParseGlobalOperations extends ParseJson<ListPage<Operation>>
});
}
- public static final class ToPagedIterable extends BaseToPagedIterable<Operation, ToPagedIterable> {
+ public static final class ToIteratorOfListPage extends BaseToIteratorOfListPage<Operation, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
@Override
- protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName,
+ protected Function<String, ListPage<Operation>> fetchNextPage(final String projectName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<Operation>>() {
- @Override public IterableWithMarker<Operation> apply(Object input) {
- ListPage<Operation> result = api.getGlobalOperationApi(projectName)
- .listAtMarker(input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Operation>>() {
+ @Override public ListPage<Operation> apply(String input) {
+ return api.getGlobalOperationApi(projectName).listAtMarker(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java
index 1027c1f..aba3d8d 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java
@@ -20,8 +20,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.HttpHealthCheck;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -39,21 +37,20 @@ public final class ParseHttpHealthChecks extends ParseJson<ListPage<HttpHealthCh
});
}
- public static class ToPagedIterable extends BaseToPagedIterable<HttpHealthCheck, ToPagedIterable> {
+ public static class ToIteratorOfListPage extends BaseToIteratorOfListPage<HttpHealthCheck, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = checkNotNull(api, "api");
}
- @Override protected Function<Object, IterableWithMarker<HttpHealthCheck>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<HttpHealthCheck>> fetchNextPage(final String projectName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<HttpHealthCheck>>() {
+ return new Function<String, ListPage<HttpHealthCheck>>() {
- @Override public IterableWithMarker<HttpHealthCheck> apply(Object input) {
- ListPage<HttpHealthCheck> result = api.getHttpHealthCheckApi(projectName).list(options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ @Override public ListPage<HttpHealthCheck> apply(String input) {
+ return api.getHttpHealthCheckApi(projectName).list(options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
index 6bd1e16..ada754b 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.Image;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -37,20 +35,19 @@ public final class ParseImages extends ParseJson<ListPage<Image>> {
});
}
- public static final class ToPagedIterable extends BaseToPagedIterable<Image, ToPagedIterable> {
+ public static final class ToIteratorOfListPage extends BaseToIteratorOfListPage<Image, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<Image>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<Image>> fetchNextPage(final String projectName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<Image>>() {
- @Override public IterableWithMarker<Image> apply(Object input) {
- ListPage<Image> result = api.getImageApi(projectName).listAtMarker(input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Image>>() {
+ @Override public ListPage<Image> apply(String input) {
+ return api.getImageApi(projectName).listAtMarker(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java
index adf0546..dbf6ff6 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.Instance;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -37,22 +35,21 @@ public final class ParseInstances extends ParseJson<ListPage<Instance>> {
});
}
- public static final class ToPagedIterable extends BaseWithZoneToPagedIterable<Instance, ToPagedIterable> {
+ public static final class ToIteratorOfListPage
+ extends BaseWithZoneToIteratorOfListPage<Instance, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
@Override
- protected Function<Object, IterableWithMarker<Instance>> fetchNextPage(final String project, final String zone,
+ protected Function<String, ListPage<Instance>> fetchNextPage(final String project, final String zone,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<Instance>>() {
- @Override public IterableWithMarker<Instance> apply(Object input) {
- ListPage<Instance> result = api.getInstanceApi(project)
- .listAtMarkerInZone(zone, input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Instance>>() {
+ @Override public ListPage<Instance> apply(String input) {
+ return api.getInstanceApi(project).listAtMarkerInZone(zone, input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
index 54111fb..0e48546 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.MachineType;
@@ -37,22 +35,21 @@ public final class ParseMachineTypes extends ParseJson<ListPage<MachineType>> {
});
}
- public static class ToPagedIterable extends BaseWithZoneToPagedIterable<MachineType, ToPagedIterable> {
+ public static class ToIteratorOfListPage
+ extends BaseWithZoneToIteratorOfListPage<MachineType, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<MachineType>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<MachineType>> fetchNextPage(final String projectName,
final String zoneName, final ListOptions options) {
- return new Function<Object, IterableWithMarker<MachineType>>() {
+ return new Function<String, ListPage<MachineType>>() {
- @Override public IterableWithMarker<MachineType> apply(Object input) {
- ListPage<MachineType> result = api.getMachineTypeApi(projectName)
- .listAtMarkerInZone(zoneName, input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ @Override public ListPage<MachineType> apply(String input) {
+ return api.getMachineTypeApi(projectName).listAtMarkerInZone(zoneName, input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
index f3249bb..4d0a716 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Network;
@@ -37,20 +35,19 @@ public final class ParseNetworks extends ParseJson<ListPage<Network>> {
});
}
- public static final class ToPagedIterable extends BaseToPagedIterable<Network, ToPagedIterable> {
+ public static final class ToIteratorOfListPage extends BaseToIteratorOfListPage<Network, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<Network>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<Network>> fetchNextPage(final String projectName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<Network>>() {
- @Override public IterableWithMarker<Network> apply(Object input) {
- ListPage<Network> result = api.getNetworkApi(projectName).listAtMarker(input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Network>>() {
+ @Override public ListPage<Network> apply(String input) {
+ return api.getNetworkApi(projectName).listAtMarker(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
index a8897d1..95a39d8 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
@@ -37,21 +35,20 @@ public final class ParseRegionOperations extends ParseJson<ListPage<Operation>>
});
}
- public static class ToPagedIterable extends BaseWithRegionToPagedIterable<Operation, ToPagedIterable> {
+ public static class ToIteratorOfListPage
+ extends BaseWithRegionToIteratorOfListPage<Operation, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<Operation>> fetchNextPage(final String projectName,
final String regionName, final ListOptions options) {
- return new Function<Object, IterableWithMarker<Operation>>() {
- @Override public IterableWithMarker<Operation> apply(Object input) {
- ListPage<Operation> result = api.getRegionOperationApi(projectName)
- .listAtMarkerInRegion(regionName, input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Operation>>() {
+ @Override public ListPage<Operation> apply(String input) {
+ return api.getRegionOperationApi(projectName).listAtMarkerInRegion(regionName, input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
index 2c7e68b..707f8c6 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Region;
@@ -37,20 +35,19 @@ public final class ParseRegions extends ParseJson<ListPage<Region>> {
});
}
- public static final class ToPagedIterable extends BaseToPagedIterable<Region, ToPagedIterable> {
+ public static final class ToIteratorOfListPage extends BaseToIteratorOfListPage<Region, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<Region>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<Region>> fetchNextPage(final String projectName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<Region>>() {
- @Override public IterableWithMarker<Region> apply(Object input) {
- ListPage<Region> result = api.getRegionApi(projectName).listAtMarker(input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Region>>() {
+ @Override public ListPage<Region> apply(String input) {
+ return api.getRegionApi(projectName).listAtMarker(input, options);
}
};
}
[2/4] Migrate off PaginatedIterable to Iterator. Fix some live test
bugs.
Posted by ad...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
index 4f46dc6..59053e5 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Route;
@@ -37,21 +35,20 @@ public final class ParseRoutes extends ParseJson<ListPage<Route>> {
});
}
- public static final class ToPagedIterable extends BaseToPagedIterable<Route, ToPagedIterable> {
+ public static final class ToIteratorOfListPage extends BaseToIteratorOfListPage<Route, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
@Override
- protected Function<Object, IterableWithMarker<Route>> fetchNextPage(final String projectName,
+ protected Function<String, ListPage<Route>> fetchNextPage(final String projectName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<Route>>() {
- @Override public IterableWithMarker<Route> apply(Object input) {
- ListPage<Route> result = api.getRouteApi(projectName).listAtMarker(input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Route>>() {
+ @Override public ListPage<Route> apply(String input) {
+ return api.getRouteApi(projectName).listAtMarker(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
index ab7309d..a5df763 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Snapshot;
@@ -37,20 +35,19 @@ public final class ParseSnapshots extends ParseJson<ListPage<Snapshot>> {
});
}
- public static final class ToPagedIterable extends BaseToPagedIterable<Snapshot, ToPagedIterable> {
+ public static final class ToIteratorOfListPage extends BaseToIteratorOfListPage<Snapshot, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<Snapshot>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<Snapshot>> fetchNextPage(final String projectName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<Snapshot>>() {
- @Override public IterableWithMarker<Snapshot> apply(Object input) {
- ListPage<Snapshot> result = api.getSnapshotApi(projectName).listAtMarker(input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Snapshot>>() {
+ @Override public ListPage<Snapshot> apply(String input) {
+ return api.getSnapshotApi(projectName).listAtMarker(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java
index 80e4194..466a859 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java
@@ -20,8 +20,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.TargetPool;
@@ -39,23 +37,22 @@ public final class ParseTargetPools extends ParseJson<ListPage<TargetPool>> {
});
}
- public static class ToPagedIterable extends BaseWithZoneToPagedIterable<TargetPool, ToPagedIterable> {
+ public static class ToIteratorOfListPage extends BaseWithZoneToIteratorOfListPage<TargetPool, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = checkNotNull(api, "api");
}
- @Override protected Function<Object, IterableWithMarker<TargetPool>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<TargetPool>> fetchNextPage(final String projectName,
final String regionName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<TargetPool>>() {
+ return new Function<String, ListPage<TargetPool>>() {
@Override
- public IterableWithMarker<TargetPool> apply(Object input) {
- ListPage<TargetPool> result = api.getTargetPoolApi(projectName, regionName).list(options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ public ListPage<TargetPool> apply(String input) {
+ return api.getTargetPoolApi(projectName, regionName).list(options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
index 3019f7d..5bad3df 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
@@ -37,22 +35,20 @@ public final class ParseZoneOperations extends ParseJson<ListPage<Operation>> {
});
}
- public static class ToPagedIterable extends BaseWithZoneToPagedIterable<Operation, ToPagedIterable> {
+ public static class ToIteratorOfListPage extends BaseWithZoneToIteratorOfListPage<Operation, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
- @Override protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName,
+ @Override protected Function<String, ListPage<Operation>> fetchNextPage(final String projectName,
final String zoneName, final ListOptions options) {
- return new Function<Object, IterableWithMarker<Operation>>() {
+ return new Function<String, ListPage<Operation>>() {
- @Override public IterableWithMarker<Operation> apply(Object input) {
- ListPage<Operation> result = api.getZoneOperationApi(projectName)
- .listAtMarkerInZone(zoneName, input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ @Override public ListPage<Operation> apply(String input) {
+ return api.getZoneOperationApi(projectName).listAtMarkerInZone(zoneName, input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
index 24e925e..0253f9e 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.functions.internal;
import javax.inject.Inject;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Zone;
@@ -37,21 +35,20 @@ public final class ParseZones extends ParseJson<ListPage<Zone>> {
});
}
- public static final class ToPagedIterable extends BaseToPagedIterable<Zone, ToPagedIterable> {
+ public static final class ToIteratorOfListPage extends BaseToIteratorOfListPage<Zone, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
- @Inject ToPagedIterable(GoogleComputeEngineApi api) {
+ @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
this.api = api;
}
@Override
- protected Function<Object, IterableWithMarker<Zone>> fetchNextPage(final String projectName,
+ protected Function<String, ListPage<Zone>> fetchNextPage(final String projectName,
final ListOptions options) {
- return new Function<Object, IterableWithMarker<Zone>>() {
- @Override public IterableWithMarker<Zone> apply(Object input) {
- ListPage<Zone> result = api.getZoneApi(projectName).listAtMarker(input.toString(), options);
- return IterableWithMarkers.from(result, result.nextPageToken());
+ return new Function<String, ListPage<Zone>>() {
+ @Override public ListPage<Zone> apply(String input) {
+ return api.getZoneApi(projectName).listAtMarker(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/ListPages.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/ListPages.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/ListPages.java
new file mode 100644
index 0000000..5ab2420
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/ListPages.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import java.util.Iterator;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+
+import com.google.common.collect.AbstractIterator;
+import com.google.common.collect.Iterators;
+
+public final class ListPages {
+
+ public static <T> Iterable<T> concat(final Iterator<ListPage<T>> input) {
+ return new Iterable<T>() {
+ @Override public Iterator<T> iterator() {
+ return Iterators.concat(new AbstractIterator<Iterator<T>>() {
+ @Override protected Iterator<T> computeNext() {
+ return input.hasNext() ? input.next().iterator() : endOfData();
+ }
+ });
+ }
+ };
+ }
+
+ private ListPages() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java
index e437ffe..7f2ed9d 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java
@@ -17,11 +17,13 @@
package org.jclouds.googlecomputeengine;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertSame;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
+import java.util.Iterator;
+
import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.features.ImageApi;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
@@ -51,12 +53,9 @@ public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest {
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getImageApi("myproject");
- PagedIterable<Image> images = imageApi.list();
+ Iterator<ListPage<Image>> images = imageApi.list();
- // expect one page
- assertSame(images.size(), 1);
- // with three images
- assertSame(images.concat().size(), 3);
+ assertEquals(images.next().size(), 3);
}
public void testGetMultiplePages() {
@@ -100,13 +99,11 @@ public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest {
TOKEN_RESPONSE, list1, list1response, list2, list2Response, list3, list3Response)
.getImageApi("myproject");
- PagedIterable<Image> images = imageApi.list(new ListOptions.Builder().maxResults(3));
+ Iterator<ListPage<Image>> images = imageApi.list(new ListOptions.Builder().maxResults(3));
int imageCounter = 0;
- for (IterableWithMarker<Image> page : images) {
- for (Image image : page) {
- imageCounter++;
- }
+ while (images.hasNext()) {
+ imageCounter += images.next().size();
}
assertSame(imageCounter, 9);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
index eef70c9..c765a81 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
@@ -415,8 +415,6 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
@Test(dependsOnMethods = "testListLocationsWhenResponseIs2xx")
public void testCreateNodeWhenNetworkNorFirewallExistDoesNotExist() throws RunNodesException, IOException {
-
-
String payload = Strings2.toStringAndClose(InstanceApiExpectTest.class.getResourceAsStream("/instance_get.json"));
payload = payload.replace("test-0", "test-1");
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
index 3d29f08..e7470e7 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
@@ -67,7 +67,7 @@ public class GoogleComputeEngineServiceLiveTest extends BaseComputeServiceLiveTe
}, UserProject.class));
ImmutableSet.Builder<String> deprecatedMachineTypes = ImmutableSet.builder();
for (MachineType machine : api.getMachineTypeApi(userProject.get())
- .listInZone(DEFAULT_ZONE_NAME).concat()) {
+ .listInZone(DEFAULT_ZONE_NAME).next()) {
if (machine.deprecated() != null) {
deprecatedMachineTypes.add(machine.id());
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
index a3f3319..76454d4 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.compute.functions;
+import static com.google.common.collect.Iterators.singletonIterator;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
@@ -26,10 +27,9 @@ import static org.testng.Assert.assertTrue;
import java.net.URI;
-import org.jclouds.collect.IterableWithMarkers;
-import org.jclouds.collect.PagedIterables;
import org.jclouds.compute.domain.SecurityGroup;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Network;
import org.jclouds.googlecomputeengine.features.FirewallApi;
import org.jclouds.googlecomputeengine.options.ListOptions;
@@ -39,7 +39,7 @@ import org.testng.annotations.Test;
import com.google.common.base.Predicates;
import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
public class NetworkToSecurityGroupTest {
@@ -62,7 +62,7 @@ public class NetworkToSecurityGroupTest {
expect(api.getFirewallApi(projectSupplier.get()))
.andReturn(fwApi);
expect(fwApi.list(options)).andReturn(
- PagedIterables.onlyPage(IterableWithMarkers.from(ImmutableSet.of(FirewallToIpPermissionTest.fwForTest()))));
+ singletonIterator(ListPage.create(ImmutableList.of(FirewallToIpPermissionTest.fwForTest()), null)));
replay(api, fwApi);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
index e6e0c02..09e9057 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
@@ -19,7 +19,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import javax.ws.rs.core.MediaType;
@@ -137,8 +137,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject");
- assertEquals(api.listFirstPageInRegion("us-central1").toString(),
- new ParseAddressListTest().expected().toString());
+ assertEquals(api.listInRegion("us-central1").next().toString(), new ParseAddressListTest().expected().toString());
}
public void testListAddresssResponseIs4xx() {
@@ -154,6 +153,6 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject");
- assertTrue(api.listInRegion("us-central1").concat().isEmpty());
+ assertFalse(api.listInRegion("us-central1").hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
index 20b4f81..cbd707c 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
@@ -19,16 +19,14 @@ package org.jclouds.googlecomputeengine.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import java.util.List;
+import java.util.Iterator;
-import org.jclouds.collect.PagedIterable;
import org.jclouds.googlecomputeengine.domain.Address;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import com.google.common.collect.Lists;
-
public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final String ADDRESS_NAME = "address-api-live-test-address";
@@ -54,13 +52,10 @@ public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetAddress")
public void testListAddress() {
- PagedIterable<Address> addresss = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder()
+ Iterator<ListPage<Address>> addresses = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder()
.filter("name eq " + ADDRESS_NAME));
- List<Address> addresssAsList = Lists.newArrayList(addresss.concat());
-
- assertEquals(addresssAsList.size(), 1);
-
+ assertEquals(addresses.next().size(), 1);
}
@Test(groups = "live", dependsOnMethods = "testListAddress")
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
index 226815e..d11f26d 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
@@ -19,7 +19,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import java.net.URI;
@@ -228,8 +228,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject");
- assertEquals(api.listFirstPageInZone("us-central1-a").toString(),
- new ParseDiskListTest().expected().toString());
+ assertEquals(api.listInZone("us-central1-a").next().toString(), new ParseDiskListTest().expected().toString());
}
public void testListDisksResponseIs4xx() {
@@ -245,6 +244,6 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject");
- assertTrue(api.listInZone("us-central1-a").concat().isEmpty());
+ assertFalse(api.listInZone("us-central1-a").hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
index 625b820..d05454a 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
@@ -20,18 +20,16 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.net.URI;
+import java.util.Iterator;
import java.util.List;
-import org.jclouds.collect.PagedIterable;
import org.jclouds.googlecomputeengine.domain.Disk;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
public static final String DISK_NAME = "disk-api-live-test-disk";
@@ -45,7 +43,7 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testInsertDisk() {
- assertZoneOperationDoneSucessfully(api().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testInsertDisk")
@@ -59,21 +57,21 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetDisk")
public void testListDisk() {
- PagedIterable<Disk> disks = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
+ Iterator<ListPage<Disk>> disks = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
.filter("name eq " + DISK_NAME));
- List<Disk> disksAsList = Lists.newArrayList(disks.concat());
+ List<Disk> disksAsList = disks.next();
assertEquals(disksAsList.size(), 1);
- assertDiskEquals(Iterables.getOnlyElement(disksAsList));
+ assertDiskEquals(disksAsList.get(0));
}
@Test(groups = "live", dependsOnMethods = "testListDisk")
public void testDeleteDisk() {
- assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
}
private void assertDiskEquals(Disk result) {
@@ -86,7 +84,8 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
public void testInsertSSDDisk() {
URI diskType = getDiskTypeUrl(userProject.get(), DEFAULT_ZONE_NAME, "pd-ssd");
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(diskType);
- assertZoneOperationDoneSucessfully(api().createInZone(SSD_DISK_NAME, sizeGb, DEFAULT_ZONE_NAME, diskCreationOptions), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(
+ api().createInZone(SSD_DISK_NAME, sizeGb, DEFAULT_ZONE_NAME, diskCreationOptions), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testInsertSSDDisk")
@@ -100,7 +99,7 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetSSDDisk")
public void testDeleteSSDDisk() {
- assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, SSD_DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().deleteInZone(DEFAULT_ZONE_NAME, SSD_DISK_NAME), TIME_WAIT);
}
private void assertSSDDiskEquals(Disk result) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
index 5f8f648..b62a251 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
@@ -18,8 +18,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.parse.ParseDiskTypeListTest;
@@ -95,7 +95,7 @@ public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, LIST_DISK_TYPES_RESPONSE).getDiskTypeApi
("myproject");
- assertEquals(diskTypeApi.listFirstPageInZone("us-central1-a").toString(),
+ assertEquals(diskTypeApi.listInZone("us-central1-a").next().toString(),
new ParseDiskTypeListTest().expected().toString());
}
@@ -106,6 +106,6 @@ public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, operationResponse).getDiskTypeApi("myproject");
- assertTrue(diskTypeApi.listInZone("us-central1-a").concat().isEmpty());
+ assertFalse(diskTypeApi.listInZone("us-central1-a").hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java
index b97f34e..03c7b36 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java
@@ -18,21 +18,16 @@ package org.jclouds.googlecomputeengine.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import java.util.Iterator;
-import java.util.List;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
import org.jclouds.googlecomputeengine.domain.DiskType;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
-
public class DiskTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private DiskType diskType;
@@ -44,18 +39,15 @@ public class DiskTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testDiskType() {
- PagedIterable<DiskType> diskTypes = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
- .maxResults(1));
-
- Iterator<IterableWithMarker<DiskType>> pageIterator = diskTypes.iterator();
+ Iterator<ListPage<DiskType>> pageIterator = api().listInZone(DEFAULT_ZONE_NAME,
+ new ListOptions.Builder().maxResults(1));
assertTrue(pageIterator.hasNext());
- IterableWithMarker<DiskType> singlePageIterator = pageIterator.next();
- List<DiskType> diskTypeAsList = singlePageIterator.toList();
+ ListPage<DiskType> page = pageIterator.next();
- assertSame(diskTypeAsList.size(), 1);
+ assertEquals(page.size(), 1);
- this.diskType = Iterables.getOnlyElement(diskTypeAsList);
+ this.diskType = page.get(0);
}
@Test(groups = "live", dependsOnMethods = "testDiskType")
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
index 1222f58..1fc0497 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
@@ -24,7 +24,7 @@ import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPU
import static org.jclouds.io.Payloads.newStringPayload;
import static org.jclouds.util.Strings2.toStringAndClose;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import java.io.IOException;
@@ -259,8 +259,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getFirewallApi("myproject");
- assertEquals(api.listFirstPage().toString(),
- new ParseFirewallListTest().expected().toString());
+ assertEquals(api.list().next().toString(), new ParseFirewallListTest().expected().toString());
}
public void testListFirewallsResponseIs4xx() {
@@ -276,6 +275,6 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getFirewallApi("myproject");
- assertTrue(api.list().concat().isEmpty());
+ assertFalse(api.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
index 652d47a..f17c69e 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
@@ -20,17 +20,17 @@ import static com.google.common.collect.Iterables.getOnlyElement;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
+import java.util.Iterator;
import java.util.List;
-import org.jclouds.collect.PagedIterable;
import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.FirewallOptions;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
@Test(groups = "live", testName = "FirewallApiLiveTest")
public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -110,13 +110,12 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetFirewall")
public void testListFirewall() {
- PagedIterable<Firewall> firewalls = api().list(new ListOptions.Builder()
+ Iterator<ListPage<Firewall>> firewalls = api().list(new ListOptions.Builder()
.filter("name eq " + FIREWALL_NAME));
- List<Firewall> firewallsAsList = Lists.newArrayList(firewalls.concat());
+ List<Firewall> firewallsAsList = firewalls.next();
assertEquals(firewallsAsList.size(), 1);
-
}
@Test(groups = "live", dependsOnMethods = "testListFirewall")
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java
index 866eadd..161d27d 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java
@@ -19,7 +19,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import java.net.URI;
@@ -28,7 +28,6 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.options.ForwardingRuleCreationOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleListTest;
import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleTest;
import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
@@ -142,8 +141,7 @@ public class ForwardingRuleApiExpectTest extends BaseGoogleComputeEngineApiExpec
ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getForwardingRuleApi("myproject", "us-central1");
- ListOptions options = new ListOptions();
- assertEquals(api.list(options).toString(), new ParseForwardingRuleListTest().expected().toString());
+ assertEquals(api.list().next().toString(), new ParseForwardingRuleListTest().expected().toString());
}
public void testListForwardingRulesResponseIs4xx() {
@@ -159,7 +157,7 @@ public class ForwardingRuleApiExpectTest extends BaseGoogleComputeEngineApiExpec
ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getForwardingRuleApi("myproject", "us-central1");
- assertTrue(api.list().concat().isEmpty());
+ assertFalse(api.list().hasNext());
}
public void testSetTargetForwardingRuleResponseIs2xx(){
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
index a7c6731..d66532a 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
@@ -19,8 +19,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
@@ -108,7 +108,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApi("myproject");
- assertEquals(globalOperationApi.listFirstPage().toString(),
+ assertEquals(globalOperationApi.list().next().toString(),
new ParseGlobalOperationListTest().expected().toString());
}
@@ -150,6 +150,6 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApi("myproject");
- assertTrue(globalOperationApi.list().concat().isEmpty());
+ assertFalse(globalOperationApi.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
index 526bc26..0d40738 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
@@ -16,74 +16,51 @@
*/
package org.jclouds.googlecomputeengine.features;
-import static org.jclouds.googlecomputeengine.features.ProjectApiLiveTest.addItemToMetadata;
-import static org.jclouds.googlecomputeengine.features.ProjectApiLiveTest.deleteItemFromMetadata;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Iterator;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.SkipException;
import org.testng.annotations.Test;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
+@Test(groups = "live", testName = "GlobalOperationApiLiveTest")
public class GlobalOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
- private static final String METADATA_ITEM_KEY = "operationLiveTestTestProp";
- private static final String METADATA_ITEM_VALUE = "operationLiveTestTestValue";
- private Operation addOperation;
- private Operation deleteOperation;
+ private Operation operation;
private GlobalOperationApi api() {
return api.getGlobalOperationApi(userProject.get());
}
-
- @Test(groups = "live")
- public void testCreateOperations() {
- //insert some operations by adding and deleting metadata items
- // this will make sure there is stuff to listFirstPage
- addOperation = assertGlobalOperationDoneSucessfully(addItemToMetadata(api.getProjectApi(),
- userProject.get(), METADATA_ITEM_KEY, METADATA_ITEM_VALUE), 20);
- deleteOperation = assertGlobalOperationDoneSucessfully(deleteItemFromMetadata(api
- .getProjectApi(), userProject.get(), METADATA_ITEM_KEY), 20);
-
- assertNotNull(addOperation);
- assertNotNull(deleteOperation);
- }
-
- @Test(groups = "live", dependsOnMethods = "testCreateOperations")
- public void testGetOperation() {
- Operation operation = api().get(addOperation.name());
- assertNotNull(operation);
- assertOperationEquals(operation, this.addOperation);
- }
-
- @Test(groups = "live", dependsOnMethods = "testCreateOperations")
public void testListOperationsWithFiltersAndPagination() {
- PagedIterable<Operation> operations = api().list(new ListOptions.Builder()
- .filter("operationType eq setMetadata")
- .maxResults(1));
+ Iterator<ListPage<Operation>> operations = api().list(new ListOptions.Builder()
+ // .filter("operationType eq insert")
+ .maxResults(1));
// make sure that in spite of having only one result per page we get at least two results
- final AtomicInteger counter = new AtomicInteger();
- operations.firstMatch(new Predicate<IterableWithMarker<Operation>>() {
- @Override public boolean apply(IterableWithMarker<Operation> input) {
- counter.addAndGet(Iterables.size(input));
- return counter.get() == 2;
+ int count = 0;
+ for (; count < 2 && operations.hasNext(); ) {
+ ListPage<Operation> result = operations.next();
+ if (result.isEmpty()) {
+ operation = result.get(0);
+ count++;
}
- });
+ }
+ if (count < 2) {
+ throw new SkipException("Not enough global operations");
+ }
+ assertEquals(count, 2);
}
- private void assertOperationEquals(Operation result, Operation expected) {
- assertEquals(result.name(), expected.name());
+ @Test(groups = "live", dependsOnMethods = "testListOperationsWithFiltersAndPagination")
+ public void testGetOperation() {
+ Operation result = api().get(operation.name());
+ assertNotNull(result);
+ assertEquals(result.name(), operation.name()); // Checking state besides name can lead to flaky test.
}
-
-
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
index 5c165fd..24a2011 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
@@ -19,14 +19,13 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import javax.ws.rs.core.MediaType;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.options.HttpHealthCheckCreationOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.parse.ParseGlobalOperationTest;
import org.jclouds.googlecomputeengine.parse.ParseHttpHealthCheckListTest;
import org.jclouds.googlecomputeengine.parse.ParseHttpHealthCheckTest;
@@ -161,9 +160,7 @@ public class HttpHealthCheckApiExpectTest extends BaseGoogleComputeEngineApiExpe
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getHttpHealthCheckApi("myproject");
- ListOptions options = new ListOptions();
- assertEquals(api.list(options).toString(),
- new ParseHttpHealthCheckListTest().expected().toString());
+ assertEquals(api.list().next().toString(), new ParseHttpHealthCheckListTest().expected().toString());
}
public void testListHttpHealthChecksResponseIs4xx() {
@@ -179,7 +176,7 @@ public class HttpHealthCheckApiExpectTest extends BaseGoogleComputeEngineApiExpe
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getHttpHealthCheckApi("myproject");
- assertTrue(api.list().concat().isEmpty());
+ assertFalse(api.list().hasNext());
}
public void testPatchHttpHealthChecksResponseIs2xx() {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
index 5f8ed31..039adec 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
@@ -19,7 +19,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
@@ -139,8 +139,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE).getImageApi
("myproject");
- assertEquals(imageApi.listFirstPage().toString(),
- new ParseImageListTest().expected().toString());
+ assertEquals(imageApi.list().next().toString(), new ParseImageListTest().expected().toString());
}
public void testListImagesResponseIs4xx() {
@@ -150,7 +149,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, operationResponse).getImageApi("myproject");
- assertTrue(imageApi.list().concat().isEmpty());
+ assertFalse(imageApi.list().hasNext());
}
public void testCreateImageFromPdResponseIs2xx(){
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
index 8c3f0bf..c9e34c9 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
@@ -18,23 +18,18 @@ package org.jclouds.googlecomputeengine.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
import java.net.URI;
import java.util.Iterator;
import java.util.List;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
import org.jclouds.googlecomputeengine.domain.Disk;
import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
-
public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
public static final String DISK_NAME = "image-api-live-test-disk";
@@ -60,17 +55,13 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testListImage() {
- PagedIterable<Image> images = api().list(new ListOptions.Builder().maxResults(1));
-
- Iterator<IterableWithMarker<Image>> pageIterator = images.iterator();
- assertTrue(pageIterator.hasNext());
+ Iterator<ListPage<Image>> images = api().list(new ListOptions.Builder().maxResults(1));
- IterableWithMarker<Image> singlePageIterator = pageIterator.next();
- List<Image> imageAsList = singlePageIterator.toList();
+ List<Image> imageAsList = images.next();
- assertSame(imageAsList.size(), 1);
+ assertEquals(imageAsList.size(), 1);
- this.image = Iterables.getOnlyElement(imageAsList);
+ this.image = imageAsList.get(0);
}
@@ -87,7 +78,7 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testInsertDisk() {
- assertZoneOperationDoneSucessfully(diskApi().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT);
Disk disk = diskApi().getInZone(DEFAULT_ZONE_NAME, DISK_NAME);
diskURI = disk.selfLink();
}
@@ -106,7 +97,7 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetCreatedImage")
public void testCleanup(){
assertGlobalOperationDoneSucessfully(imageApi().delete(IMAGE_NAME), TIME_WAIT);
- assertZoneOperationDoneSucessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
}
private void assertImageEquals(Image result) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java
index 4515233..17d7d92 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java
@@ -22,7 +22,7 @@ import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPU
import static org.jclouds.googlecomputeengine.features.ProjectApiExpectTest.GET_PROJECT_REQUEST;
import static org.jclouds.googlecomputeengine.features.ProjectApiExpectTest.GET_PROJECT_RESPONSE;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import java.net.URI;
@@ -216,7 +216,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE,
LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE).getInstanceApi("myproject");
- assertEquals(api.listFirstPageInZone("us-central1-a").toString(),
+ assertEquals(api.listInZone("us-central1-a").next().toString(),
new ParseInstanceListTest().expected().toString());
}
@@ -233,7 +233,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getInstanceApi("myproject");
- assertTrue(api.listInZone("us-central1-a").concat().isEmpty());
+ assertFalse(api.listInZone("us-central1-a").hasNext());
}
public void testSetInstanceMetadataResponseIs2xx() {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
index f799948..11f4915 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
@@ -21,14 +21,15 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.net.URI;
+import java.util.Iterator;
import java.util.List;
import java.util.Properties;
-import org.jclouds.collect.PagedIterable;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.domain.Image;
import org.jclouds.googlecomputeengine.domain.Instance;
import org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.templates.InstanceTemplate;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.AttachDiskOptions;
@@ -40,10 +41,10 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
import com.google.inject.Module;
@Test(groups = "live", testName = "InstanceApiLiveTest")
@@ -68,9 +69,9 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Override
protected GoogleComputeEngineApi create(Properties props, Iterable<Module> modules) {
GoogleComputeEngineApi api = super.create(props, modules);
- URI imageUri = api.getImageApi("centos-cloud")
- .list(new ListOptions.Builder().filter("name eq centos.*"))
- .concat()
+ List<Image> list = api.getImageApi("centos-cloud")
+ .list(new ListOptions.Builder().filter("name eq centos.*")).next();
+ URI imageUri = FluentIterable.from(list)
.filter(new Predicate<Image>() {
@Override
public boolean apply(Image input) {
@@ -111,15 +112,15 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
(INSTANCE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(instance.image());
- assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get())
- .createInZone(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME, diskCreationOptions),
- TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api.getDiskApi(userProject.get())
+ .createInZone(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME, diskCreationOptions),
+ TIME_WAIT);
- assertZoneOperationDoneSucessfully(diskApi().createInZone
- ("instance-live-test-disk", DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(
+ diskApi().createInZone("instance-live-test-disk", DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME), TIME_WAIT);
- assertZoneOperationDoneSucessfully(api().createInZone(INSTANCE_NAME, DEFAULT_ZONE_NAME, instance), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().createInZone(INSTANCE_NAME, DEFAULT_ZONE_NAME, instance), TIME_WAIT);
}
@@ -134,10 +135,9 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListInstance")
public void testSetMetadataForInstance() {
Instance originalInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
- assertZoneOperationDoneSucessfully(api().setMetadataInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
- ImmutableMap.of(METADATA_ITEM_KEY, METADATA_ITEM_VALUE),
- originalInstance.metadata().fingerprint()),
- TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().setMetadataInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
+ ImmutableMap.of(METADATA_ITEM_KEY, METADATA_ITEM_VALUE), originalInstance.metadata().fingerprint()),
+ TIME_WAIT);
Instance modifiedInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
@@ -150,9 +150,9 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListInstance")
public void testSetTagsForInstance() {
Instance originalInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
- assertZoneOperationDoneSucessfully(api().setTagsInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME, TAGS,
- originalInstance.tags().fingerprint()),
- TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(
+ api().setTagsInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME, TAGS, originalInstance.tags().fingerprint()),
+ TIME_WAIT);
Instance modifiedInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
@@ -162,15 +162,13 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testSetMetadataForInstance")
public void testAttachDiskToInstance() {
- assertZoneOperationDoneSucessfully(diskApi().createInZone(ATTACH_DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().createInZone(ATTACH_DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);
Instance originalInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
- assertZoneOperationDoneSucessfully(api().attachDiskInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
- new AttachDiskOptions().type(DiskType.PERSISTENT)
- .source(getDiskUrl(userProject.get(), ATTACH_DISK_NAME))
- .mode(DiskMode.READ_ONLY)
- .deviceName(ATTACH_DISK_DEVICE_NAME)),
- TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().attachDiskInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
+ new AttachDiskOptions().type(DiskType.PERSISTENT)
+ .source(getDiskUrl(userProject.get(), ATTACH_DISK_NAME)).mode(DiskMode.READ_ONLY)
+ .deviceName(ATTACH_DISK_DEVICE_NAME)), TIME_WAIT);
Instance modifiedInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
@@ -188,44 +186,42 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testAttachDiskToInstance")
public void testDetachDiskFromInstance() {
Instance originalInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
- assertZoneOperationDoneSucessfully(api().detachDiskInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
- ATTACH_DISK_DEVICE_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(
+ api().detachDiskInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME, ATTACH_DISK_DEVICE_NAME), TIME_WAIT);
Instance modifiedInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
assertTrue(modifiedInstance.disks().size() < originalInstance.disks().size());
- assertZoneOperationDoneSucessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, ATTACH_DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, ATTACH_DISK_NAME), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testInsertInstance")
public void testListInstance() {
- PagedIterable<Instance> instances = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
+ Iterator<ListPage<Instance>> instances = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
.filter("name eq " + INSTANCE_NAME));
- List<Instance> instancesAsList = Lists.newArrayList(instances.concat());
+ List<Instance> instancesAsList = instances.next();
assertEquals(instancesAsList.size(), 1);
- assertInstanceEquals(Iterables.getOnlyElement(instancesAsList), instance);
+ assertInstanceEquals(instancesAsList.get(0), instance);
}
@Test(groups = "live", dependsOnMethods = "testDetachDiskFromInstance")
public void testResetInstance() {
- assertZoneOperationDoneSucessfully(api().resetInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME),
- TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().resetInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testResetInstance")
public void testDeleteInstance() {
-
- assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME), TIME_WAIT);
- assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
- TIME_WAIT);
- assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
- TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().deleteInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
+ TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(
+ api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME), TIME_WAIT);
assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).delete
(INSTANCE_NETWORK_NAME), TIME_WAIT);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
index dc829b2..1400232 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
@@ -18,8 +18,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.parse.ParseMachineTypeListTest;
@@ -95,7 +95,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE).getMachineTypeApi
("myproject");
- assertEquals(machineTypeApi.listFirstPageInZone("us-central1-a").toString(),
+ assertEquals(machineTypeApi.listInZone("us-central1-a").next().toString(),
new ParseMachineTypeListTest().expected().toString());
}
@@ -106,6 +106,6 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, operationResponse).getMachineTypeApi("myproject");
- assertTrue(machineTypeApi.listInZone("us-central1-a").concat().isEmpty());
+ assertFalse(machineTypeApi.listInZone("us-central1-a").hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
index 00f3acb..89c7257 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
@@ -18,21 +18,17 @@ package org.jclouds.googlecomputeengine.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import java.util.Iterator;
import java.util.List;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.MachineType;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
-
public class MachineTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private MachineType machineType;
@@ -43,19 +39,15 @@ public class MachineTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testListMachineType() {
-
- PagedIterable<MachineType> machineTypes = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
- .maxResults(1));
-
- Iterator<IterableWithMarker<MachineType>> pageIterator = machineTypes.iterator();
+ Iterator<ListPage<MachineType>> pageIterator = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
+ .maxResults(1));
assertTrue(pageIterator.hasNext());
- IterableWithMarker<MachineType> singlePageIterator = pageIterator.next();
- List<MachineType> machineTypeAsList = singlePageIterator.toList();
+ List<MachineType> machineTypeAsList = pageIterator.next();
- assertSame(machineTypeAsList.size(), 1);
+ assertEquals(machineTypeAsList.size(), 1);
- this.machineType = Iterables.getOnlyElement(machineTypeAsList);
+ this.machineType = machineTypeAsList.get(0);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java
index 2f0d7a0..61f319b 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java
@@ -19,7 +19,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import javax.ws.rs.core.MediaType;
@@ -138,7 +138,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, list, operationResponse).getNetworkApi("myproject");
- assertEquals(api.listFirstPage().toString(),
+ assertEquals(api.list().next().toString(),
new ParseNetworkListTest().expected().toString());
}
@@ -152,9 +152,9 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
- NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getNetworkApi("myproject");
+ NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE, list,
+ operationResponse).getNetworkApi("myproject");
- assertTrue(api.list().concat().isEmpty());
+ assertFalse(api.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
index 2a336ee..9363370 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
@@ -19,17 +19,15 @@ package org.jclouds.googlecomputeengine.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
+import java.util.Iterator;
import java.util.List;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Network;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
@Test(groups = "live", testName = "NetworkApiLiveTest")
public class NetworkApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -43,14 +41,11 @@ public class NetworkApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testInsertNetwork() {
-
assertGlobalOperationDoneSucessfully(api().createInIPv4Range(NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
-
}
@Test(groups = "live", dependsOnMethods = "testInsertNetwork")
public void testGetNetwork() {
-
Network network = api().get(NETWORK_NAME);
assertNotNull(network);
assertNetworkEquals(network);
@@ -59,14 +54,14 @@ public class NetworkApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetNetwork")
public void testListNetwork() {
- PagedIterable<Network> networks = api().list(new ListOptions.Builder()
+ Iterator<ListPage<Network>> networks = api().list(new ListOptions.Builder()
.filter("name eq " + NETWORK_NAME));
- List<Network> networksAsList = Lists.newArrayList(networks.concat());
+ List<Network> networksAsList = networks.next();
assertEquals(networksAsList.size(), 1);
- assertNetworkEquals(Iterables.getOnlyElement(networksAsList));
+ assertNetworkEquals(networksAsList.get(0));
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java
index b041647..4ede7f6 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java
@@ -18,8 +18,8 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
import org.jclouds.googlecomputeengine.parse.ParseRegionListTest;
@@ -78,8 +78,7 @@ public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, LIST_REGIONS_REQ, LIST_REGIONS_RESPONSE).getRegionApi("myproject");
- assertEquals(api.listFirstPage().toString(),
- new ParseRegionListTest().expected().toString());
+ assertEquals(api.list().next().toString(), new ParseRegionListTest().expected().toString());
}
public void testListRegionWithPaginationOptionsResponseIs4xx() {
@@ -89,6 +88,6 @@ public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, LIST_REGIONS_REQ, operationResponse).getRegionApi("myproject");
- assertTrue(api.list().concat().isEmpty());
+ assertFalse(api.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/7427ba23/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
index 6c47e4b..e360863 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
@@ -18,21 +18,17 @@ package org.jclouds.googlecomputeengine.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import java.util.Iterator;
import java.util.List;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Region;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
-import com.google.common.collect.Iterables;
-
public class RegionApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private Region region;
@@ -43,19 +39,14 @@ public class RegionApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testListRegion() {
-
- PagedIterable<Region> regions = api().list(new ListOptions.Builder()
- .maxResults(1));
-
- Iterator<IterableWithMarker<Region>> pageIterator = regions.iterator();
+ Iterator<ListPage<Region>> pageIterator = api().list(new ListOptions.Builder().maxResults(1));
assertTrue(pageIterator.hasNext());
- IterableWithMarker<Region> singlePageIterator = pageIterator.next();
- List<Region> regionAsList = singlePageIterator.toList();
+ List<Region> regionAsList = pageIterator.next();
- assertSame(regionAsList.size(), 1);
+ assertEquals(regionAsList.size(), 1);
- this.region = Iterables.getOnlyElement(regionAsList);
+ this.region = regionAsList.get(0);
}
@Test(groups = "live", dependsOnMethods = "testListRegion")