diff --git a/common/openstack/src/main/java/org/jclouds/openstack/options/BaseListOptions.java b/common/openstack/src/main/java/org/jclouds/openstack/options/BaseListOptions.java index 26f62eded8..fa0aed3632 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/options/BaseListOptions.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/options/BaseListOptions.java @@ -48,10 +48,6 @@ public class BaseListOptions extends BaseHttpRequestOptions { * Indicates where to begin listing. The list will only include objects that occur after the * offset. This is convenient for pagination: To get the next page of results use the last result * number of the current page + current page offset as the offset. - *
- * This isn't supported by newer openstack API implementations - * - * @see #marker(String) for the new mechanism to set the page offset */ public BaseListOptions startAt(long offset) { checkState(offset >= 0, "offset must be >= 0"); @@ -59,19 +55,6 @@ public class BaseListOptions extends BaseHttpRequestOptions { return this; } - /** - * The marker parameter is the ID of the last item in the previous list - * (i.e. return the page of items after the marker). - * - * This is only supported by newer openstack API implementations - * - * @see #startAt for the old mechanism to set the page offset - */ - public BaseListOptions marker(String marker) { - queryParameters.put("marker", checkNotNull(marker, "marker")); - return this; - } - /** * To reduce load on the service, list operations will return a maximum of 1,000 items at a time. * To navigate the collection, the parameters limit and offset can be set in the URI @@ -97,14 +80,6 @@ public class BaseListOptions extends BaseHttpRequestOptions { return options.startAt(prefix); } - /** - * @see BaseListOptions#marker - */ - public static BaseListOptions marker(String marker) { - BaseListOptions options = new BaseListOptions(); - return options.marker(marker); - } - /** * @see BaseListOptions#maxResults */ diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ListImageOptions.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ListImageOptions.java index 1069547236..b81c07c9bc 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ListImageOptions.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ListImageOptions.java @@ -18,14 +18,14 @@ */ package org.jclouds.openstack.glance.v1_0.options; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; import static org.jclouds.openstack.glance.v1_0.options.ImageField.*; -import java.util.Date; - +import org.jclouds.http.options.BaseHttpRequestOptions; import org.jclouds.openstack.glance.v1_0.domain.ContainerFormat; import org.jclouds.openstack.glance.v1_0.domain.DiskFormat; import org.jclouds.openstack.glance.v1_0.domain.Image.Status; -import org.jclouds.openstack.options.BaseListOptions; /** * Usage The recommended way to instantiate a ListImageOptions object is to statically import @@ -36,13 +36,33 @@ import org.jclouds.openstack.options.BaseListOptions; * * * // this will list the first 10 images with the name "name", minimum required disk of 5GB. - * list = client.list(name("newName"), maxResults(10), minDisk(5)); + * list = client.list(name("newName"), limit(10), minDisk(5)); *
*
* @author Adam Lowe
* @see
*/
-public class ListImageOptions extends BaseListOptions {
+public class ListImageOptions extends BaseHttpRequestOptions {
+ public static final ListImageOptions NONE = new ListImageOptions();
+
+ /**
+ * Given a string value x, return object names greater in value than the specified marker.
+ */
+ public ListImageOptions marker(String marker) {
+ queryParameters.put("marker", checkNotNull(marker, "marker"));
+ return this;
+ }
+
+ /**
+ * For an integer value n, limits the number of results to n values.
+ */
+ public ListImageOptions limit(int limit) {
+ checkState(limit >= 0, "limit must be >= 0");
+ checkState(limit <= 10000, "limit must be <= 10000");
+ queryParameters.put("limit", Integer.toString(limit));
+ return this;
+ }
+
/**
* Return only those images having a matching name attribute
*/
@@ -228,24 +248,18 @@ public class ListImageOptions extends BaseListOptions {
}
/**
- * @see BaseListOptions#maxResults
+ * @see ListImageOptions#limit
*/
- public static ListImageOptions maxResults(int limit) {
- return ListImageOptions.class.cast(new ListImageOptions().maxResults(limit));
+ public static ListImageOptions limit(int limit) {
+ return new ListImageOptions().limit(limit);
}
/**
- * @see BaseListOptions#marker
+ * @see ListImageOptions#marker
*/
public static ListImageOptions marker(String marker) {
- return ListImageOptions.class.cast(new ListImageOptions().marker(marker));
- }
-
- /**
- * @see BaseListOptions#changesSince
- */
- public static ListImageOptions changesSince(Date ifModifiedSince) {
- return ListImageOptions.class.cast(new BaseListOptions().changesSince(ifModifiedSince));
+ ListImageOptions options = new ListImageOptions();
+ return options.marker(marker);
}
}
}
diff --git a/labs/openstack-glance/src/test/java/org/jclouds/openstack/glance/v1_0/features/ImageClientLiveTest.java b/labs/openstack-glance/src/test/java/org/jclouds/openstack/glance/v1_0/features/ImageClientLiveTest.java
index 908a835aeb..76d835e706 100644
--- a/labs/openstack-glance/src/test/java/org/jclouds/openstack/glance/v1_0/features/ImageClientLiveTest.java
+++ b/labs/openstack-glance/src/test/java/org/jclouds/openstack/glance/v1_0/features/ImageClientLiveTest.java
@@ -49,7 +49,7 @@ public class ImageClientLiveTest extends BaseGlanceClientLiveTest {
public void testList() throws Exception {
for (String zoneId : glanceContext.getApi().getConfiguredRegions()) {
ImageClient client = glanceContext.getApi().getImageClientForRegion(zoneId);
- Set response = client.list(ListImageOptions.Builder.maxResults(100));
+ Set response = client.list(ListImageOptions.Builder.limit(100));
assert null != response;
for (Image image : response) {
checkImage(image);
@@ -103,7 +103,7 @@ public class ImageClientLiveTest extends BaseGlanceClientLiveTest {
assertEquals(details.getName(), "jclouds-live-test2");
assertEquals(details.getMinDisk(), 10);
- Image fromListing = Iterables.getOnlyElement(client.list(ListImageOptions.Builder.name("jclouds-live-test2"), ListImageOptions.Builder.maxResults(2), ListImageOptions.Builder.containerFormat(ContainerFormat.BARE)));
+ Image fromListing = Iterables.getOnlyElement(client.list(ListImageOptions.Builder.name("jclouds-live-test2"), ListImageOptions.Builder.limit(2), ListImageOptions.Builder.containerFormat(ContainerFormat.BARE)));
assertEquals(fromListing.getId(), details.getId());
assertEquals(fromListing.getSize(), details.getSize());
@@ -128,7 +128,7 @@ public class ImageClientLiveTest extends BaseGlanceClientLiveTest {
assertEquals(details.getSize().get().longValue(), imageData.getRawContent().length());
assertEquals(details.getMinDisk(), 10);
- Image fromListing = Iterables.getOnlyElement(client.list(ListImageOptions.Builder.name("jclouds-live-res-test2"), ListImageOptions.Builder.maxResults(2), ListImageOptions.Builder.containerFormat(ContainerFormat.BARE)));
+ Image fromListing = Iterables.getOnlyElement(client.list(ListImageOptions.Builder.name("jclouds-live-res-test2"), ListImageOptions.Builder.limit(2), ListImageOptions.Builder.containerFormat(ContainerFormat.BARE)));
assertEquals(fromListing.getId(), details.getId());
assertEquals(fromListing.getSize(), details.getSize());