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 <[email protected]> Authored: Tue Nov 4 11:19:22 2014 -0800 Committer: Adrian Cole <[email protected]> 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); }
