@nacx - I have taken a look at what you are proposing. I do see the value in what you suggest. However I am slightly confused about how I might complete this. I have [pushed a new branch](https://github.com/DimensionDataDublin/jclouds-labs/tree/zones_review_updates_for_nacx) that maybe you could look at to help you understand where I am at.
First thing, I have created a new class `PaginationFilterOptions` which is more or less the same as existing `PaginationOptions` but does not extend `BaseHttpRequestOptions`. The reason for the new class is that we use `PaginationOptions` on other APIs that at the moment I do not want to change since we do have the same requirements for datacenter filtering. I have also introduced a `DatacenterIdListFilters` which does extend `BaseHttpRequestOptions` and wraps the `PaginationFilterOptions` so that it can be used for pagination. Taking the example of [ServerApi ](https://github.com/DimensionDataDublin/jclouds-labs/blob/zones/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerApi.java) as it looks on this PR we expose two methods for `listServers`. The first one is what I think is the user facing API one with the Set of `datacenterIds` we want to query on: ``` @Named("server:list") @GET @Path("/server") @Transform(ParseServers.ToPagedIterable.class) @ResponseParser(ParseServers.class) @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class) PagedIterable<Server> listServers(@QueryParam("datacenterId") Set<String> datacenterId); ``` The second is the one as used in order to iterate over the pages returned: ``` @Named("server:list") @GET @Path("/server") @ResponseParser(ParseServers.class) @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) PaginatedCollection<Server> listServers(@QueryParam("datacenterId") Set<String> datacenterId, PaginationOptions options); ``` With the changes you propose I can see this working as below. I'm hoping this is the parameters of the two listServer methods. ``` @Named("server:list") @GET @Path("/server") @ResponseParser(ParseServers.class) @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) PaginatedCollection<Server> listServers(DatacenterIdListFilters datacenterIdListFilters); @Named("server:list") @GET @Path("/server") @Transform(ParseServers.ToPagedIterable.class) @ResponseParser(ParseServers.class) @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class) PagedIterable<Server> listServers(@QueryParam("datacenterId") Set<String> datacenterId); @Singleton final class ParseServers extends ParseJson<Servers> { @Inject ParseServers(final Json json) { super(json, TypeLiteral.get(Servers.class)); } static class ToPagedIterable extends Arg0ToPagedIterable<Server, ToPagedIterable> { private DimensionDataCloudControlApi api; @Inject ToPagedIterable(final DimensionDataCloudControlApi api) { this.api = api; } @Override protected Function<Object, IterableWithMarker<Server>> markerToNextForArg0(final Optional<Object> arg0) { return new Function<Object, IterableWithMarker<Server>>() { @Override public IterableWithMarker<Server> apply(Object input) { return api.getServerApi().listServers( DatacenterIdListFilters.Builder.datacenterId((Set<String>) arg0.get()) .paginationOptions(PaginationFilterOptions.class.cast(input))); } }; } } } ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/433#issuecomment-382070591