> Change looks good. Would it make sense, though, to create a couple filter 
> objects ListServerOptions and ListDatacenterOptions that extend 
> PaginationOptions and introduce the datacenter query parameters? if the 
> datacenter filter parameter is optional, then it would be better and cleaner 
> for the API to just hide it in the "options" object passed to the list method?

@nacx I gave the change you suggested a go, but I don't think this solution 
will work cleanly as you or I might have hoped. I face an issue in the 
[`org.jclouds.dimensiondata.cloudcontrol.domain.PaginatedCollection#toPaginationOptions`](https://github.com/DimensionDataDublin/jclouds-labs/blob/zones/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/PaginatedCollection.java#L101)
 method as it returns a `PaginationOptions` instead of the Subtype eg 
ListDatacenterOptions. We need the correct subtype for the cast to work in the 
Parsers. To resolve the issue we would also need to us having to create 
subclasses of  
`org.jclouds.dimensiondata.cloudcontrol.domain.PaginatedCollection` also for 
both of the filters we have already removed. 

Maybe an alternative approach could be to modify and rename 
`org.jclouds.dimensiondata.cloudcontrol.options.PaginationOptions` so that it 
has the following ability:

``` 
public PaginationOptions queryParameters(String queryParameter, Set<String> 
values) {
      for (String value : values) {
         queryParameters.put(queryParameter, value);
      }
      return this;
   }
``` 
This means we have the extra flexibility without impacting other usages of 
`PaginationOptions`. This would be my preferred approach.

Another way to resolve could be to re-build query class each time we iterate, 
but I dont really like this option:
```
   final class ParseCustomerImages extends ParseJson<CustomerImages> {

      @Inject
      ParseCustomerImages(Json json) {
         super(json, TypeLiteral.get(CustomerImages.class));
      }

      private static class ToPagedIterable extends 
Arg0ToPagedIterable<CustomerImage, ToPagedIterable> {

         private DimensionDataCloudControlApi api;

         @Inject
         ToPagedIterable(final DimensionDataCloudControlApi api) {
            this.api = api;
         }

         @Override
         protected Function<Object, IterableWithMarker<CustomerImage>> 
markerToNextForArg0(
               final Optional<Object> arg0) {
            return new Function<Object, IterableWithMarker<CustomerImage>>() {
               @Override
               public IterableWithMarker<CustomerImage> apply(Object input) {
                  ListWithDatacenterIdFilteringAndPaginationOptions options = 
new ListWithDatacenterIdFilteringAndPaginationOptions(PaginationOptions.class
                                          .cast(input),(Set<String>) arg0.get() 
) ;
                  return api.getServerImageApi().listCustomerImages(options);
               }
            };
         }
      }
   }
```
 

-- 
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-381181871

Reply via email to