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:50 UTC
[3/4] Migrate off PaginatedIterable to Iterator. Fix some live test
bugs.
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);
}
};
}