mirror of
https://github.com/apache/jclouds.git
synced 2025-02-17 15:35:44 +00:00
Refactored OpenStack pagination. Removed Rackspace pagination. Prefer PaginationOptions.
This commit is contained in:
parent
ac5559ca9e
commit
1013986585
@ -20,7 +20,7 @@ import static com.google.common.util.concurrent.Futures.immediateFuture;
|
|||||||
import static org.jclouds.Fallbacks.valOnNotFoundOr404;
|
import static org.jclouds.Fallbacks.valOnNotFoundOr404;
|
||||||
|
|
||||||
import org.jclouds.Fallback;
|
import org.jclouds.Fallback;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
|
||||||
|
|
||||||
import static org.jclouds.http.utils.Queries.queryParser;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.collect.FluentIterable;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* base class for a paginated collection in openstack
|
|
||||||
*
|
|
||||||
* @see <a
|
|
||||||
* href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Paginated_Collections-d1e325.html">
|
|
||||||
* docs</a>
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Beta
|
|
||||||
public class PaginatedCollection<T> extends IterableWithMarker<T> {
|
|
||||||
private Iterable<T> resources;
|
|
||||||
private Iterable<Link> links;
|
|
||||||
|
|
||||||
protected PaginatedCollection(Iterable<T> resources, Iterable<Link> links) {
|
|
||||||
this.resources = resources != null ? resources : ImmutableSet.<T> of();
|
|
||||||
this.links = links != null ? links : ImmutableSet.<Link> of();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<T> iterator() {
|
|
||||||
return resources.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* links that relate to this collection
|
|
||||||
*/
|
|
||||||
public Iterable<Link> getLinks() {
|
|
||||||
return links;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Object> nextMarker() {
|
|
||||||
return FluentIterable.from(getLinks()).filter(new Predicate<Link>() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(Link link) {
|
|
||||||
return Link.Relation.NEXT == link.getRelation();
|
|
||||||
}
|
|
||||||
}).transform(new Function<Link, Optional<Object>>() {
|
|
||||||
@Override
|
|
||||||
public Optional<Object> apply(Link link) {
|
|
||||||
Collection<String> markers = queryParser().apply(link.getHref().getRawQuery()).get("marker");
|
|
||||||
return Optional.<Object> fromNullable(markers == null ? null : Iterables.get(markers, 0));
|
|
||||||
}
|
|
||||||
}).first().or(Optional.absent());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -17,7 +17,7 @@
|
|||||||
package org.jclouds.openstack.keystone.v2_0.features;
|
package org.jclouds.openstack.keystone.v2_0.features;
|
||||||
|
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||||
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
|
|||||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseTenants;
|
import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseTenants;
|
||||||
|
@ -18,7 +18,7 @@ package org.jclouds.openstack.keystone.v2_0.features;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Role;
|
import org.jclouds.openstack.keystone.v2_0.domain.Role;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
||||||
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
@ -31,7 +31,7 @@ import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
|||||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Role;
|
import org.jclouds.openstack.keystone.v2_0.domain.Role;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
|
@ -17,19 +17,19 @@
|
|||||||
package org.jclouds.openstack.keystone.v2_0.functions.internal;
|
package org.jclouds.openstack.keystone.v2_0.functions.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.CallerArg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.TenantApi;
|
import org.jclouds.openstack.keystone.v2_0.features.TenantApi;
|
||||||
import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseTenants.Tenants;
|
import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseTenants.Tenants;
|
||||||
@ -38,6 +38,7 @@ import org.jclouds.openstack.v2_0.domain.Link;
|
|||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
@ -61,7 +62,7 @@ public class ParseTenants extends ParseJson<Tenants> {
|
|||||||
super(json, TypeLiteral.get(Tenants.class));
|
super(json, TypeLiteral.get(Tenants.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ToPagedIterable extends CallerArg0ToPagedIterable<Tenant, ToPagedIterable> {
|
public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Tenant, ToPagedIterable> {
|
||||||
|
|
||||||
private final KeystoneApi api;
|
private final KeystoneApi api;
|
||||||
|
|
||||||
@ -71,14 +72,15 @@ public class ParseTenants extends ParseJson<Tenants> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Tenant>> markerToNextForCallingArg0(final String ignored) {
|
protected Function<Object, IterableWithMarker<Tenant>> markerToNextForArg0(Optional<Object> ignored) {
|
||||||
final TenantApi tenantApi = api.getTenantApi().get();
|
final TenantApi tenantApi = api.getTenantApi().get();
|
||||||
return new Function<Object, IterableWithMarker<Tenant>>() {
|
return new Function<Object, IterableWithMarker<Tenant>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<Tenant> apply(Object input) {
|
public IterableWithMarker<Tenant> apply(Object input) {
|
||||||
return IterableWithMarker.class.cast(tenantApi.list(marker(input.toString())));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
return IterableWithMarker.class.cast(tenantApi.list(paginationOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,19 +17,19 @@
|
|||||||
package org.jclouds.openstack.keystone.v2_0.functions.internal;
|
package org.jclouds.openstack.keystone.v2_0.functions.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.CallerArg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
||||||
import org.jclouds.openstack.keystone.v2_0.features.UserApi;
|
import org.jclouds.openstack.keystone.v2_0.features.UserApi;
|
||||||
import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseUsers.Users;
|
import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseUsers.Users;
|
||||||
@ -38,6 +38,7 @@ import org.jclouds.openstack.v2_0.domain.Link;
|
|||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
@ -61,7 +62,7 @@ public class ParseUsers extends ParseJson<Users> {
|
|||||||
super(json, TypeLiteral.get(Users.class));
|
super(json, TypeLiteral.get(Users.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ToPagedIterable extends CallerArg0ToPagedIterable<User, ToPagedIterable> {
|
public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<User, ToPagedIterable> {
|
||||||
|
|
||||||
private final KeystoneApi api;
|
private final KeystoneApi api;
|
||||||
|
|
||||||
@ -71,14 +72,15 @@ public class ParseUsers extends ParseJson<Users> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<User>> markerToNextForCallingArg0(final String ignored) {
|
protected Function<Object, IterableWithMarker<User>> markerToNextForArg0(Optional<Object> ignored) {
|
||||||
final UserApi userApi = api.getUserApi().get();
|
final UserApi userApi = api.getUserApi().get();
|
||||||
return new Function<Object, IterableWithMarker<User>>() {
|
return new Function<Object, IterableWithMarker<User>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<User> apply(Object input) {
|
public IterableWithMarker<User> apply(Object input) {
|
||||||
return IterableWithMarker.class.cast(userApi.list(marker(input.toString())));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
return IterableWithMarker.class.cast(userApi.list(paginationOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,39 +14,42 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rackspace.cloudidentity.v2_0.domain;
|
package org.jclouds.openstack.v2_0.domain;
|
||||||
|
|
||||||
import static org.jclouds.http.utils.Queries.queryParser;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.options.PaginationOptions;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import static org.jclouds.http.utils.Queries.queryParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for a paginated collection in Rackspace.
|
* Base class for a paginated collection in OpenStack.
|
||||||
*
|
*
|
||||||
|
* @see <a
|
||||||
|
* href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Paginated_Collections-d1e325.html">
|
||||||
|
* docs</a>
|
||||||
* @author Everett Toews
|
* @author Everett Toews
|
||||||
*/
|
*/
|
||||||
@Beta
|
|
||||||
public class PaginatedCollection<T> extends IterableWithMarker<T> {
|
public class PaginatedCollection<T> extends IterableWithMarker<T> {
|
||||||
private Iterable<T> resources;
|
private final Iterable<T> resources;
|
||||||
private Iterable<Link> links;
|
private final Iterable<Link> links;
|
||||||
private int totalEntries;
|
private final Integer totalEntries;
|
||||||
|
|
||||||
protected PaginatedCollection(@Nullable Iterable<T> resources, @Nullable Iterable<Link> links, int totalEntries) {
|
protected PaginatedCollection(Iterable<T> resources, Iterable<Link> links, @Nullable Integer totalEntries) {
|
||||||
this.resources = resources != null ? resources : ImmutableSet.<T> of();
|
this.resources = resources != null ? resources : ImmutableSet.<T> of();
|
||||||
this.links = links != null ? links : ImmutableSet.<Link> of();
|
this.links = links != null ? links : ImmutableSet.<Link> of();
|
||||||
this.totalEntries = totalEntries;
|
this.totalEntries = totalEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected PaginatedCollection(Iterable<T> resources, Iterable<Link> links) {
|
||||||
|
this(resources, links, null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<T> iterator() {
|
public Iterator<T> iterator() {
|
||||||
return resources.iterator();
|
return resources.iterator();
|
||||||
@ -59,8 +62,11 @@ public class PaginatedCollection<T> extends IterableWithMarker<T> {
|
|||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalEntries() {
|
/**
|
||||||
return totalEntries;
|
* @return The total number of entries in this collection, if that information is present.
|
||||||
|
*/
|
||||||
|
public Optional<Integer> getTotalEntries() {
|
||||||
|
return Optional.fromNullable(totalEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PaginationOptions nextPaginationOptions() {
|
public PaginationOptions nextPaginationOptions() {
|
||||||
@ -71,7 +77,7 @@ public class PaginatedCollection<T> extends IterableWithMarker<T> {
|
|||||||
public Optional<Object> nextMarker() {
|
public Optional<Object> nextMarker() {
|
||||||
for (Link link: getLinks()) {
|
for (Link link: getLinks()) {
|
||||||
if (Link.Relation.NEXT == link.getRelation()) {
|
if (Link.Relation.NEXT == link.getRelation()) {
|
||||||
return Optional.<Object> of(toPaginationOptions(link));
|
return Optional.of(toPaginationOptions(link));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,6 +21,7 @@ import static com.google.common.base.Preconditions.checkState;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +33,16 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
|||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class PaginationOptions extends BaseHttpRequestOptions {
|
public class PaginationOptions extends BaseHttpRequestOptions {
|
||||||
|
/**
|
||||||
|
* Many OpenStack interfaces take different params for pagination. Using queryParams allows you to make
|
||||||
|
* use of them all if necessary.
|
||||||
|
*/
|
||||||
|
public PaginationOptions queryParameters(Multimap<String, String> queryParams) {
|
||||||
|
checkNotNull(queryParams, "queryParams");
|
||||||
|
queryParameters.putAll(queryParams);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only return objects changed since this time.
|
* Only return objects changed since this time.
|
||||||
*/
|
*/
|
||||||
@ -65,6 +76,13 @@ public class PaginationOptions extends BaseHttpRequestOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
/**
|
||||||
|
* @see PaginationOptions#queryParameters(Multimap)
|
||||||
|
*/
|
||||||
|
public static PaginationOptions queryParameters(Multimap<String, String> queryParams) {
|
||||||
|
PaginationOptions options = new PaginationOptions();
|
||||||
|
return options.queryParameters(queryParams);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PaginationOptions#marker(String)
|
* @see PaginationOptions#marker(String)
|
||||||
|
@ -28,7 +28,7 @@ import java.util.Set;
|
|||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.HttpResponseException;
|
import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Role;
|
import org.jclouds.openstack.keystone.v2_0.domain.Role;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
||||||
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestApiExpectTest;
|
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestApiExpectTest;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
package org.jclouds.openstack.nova.v2_0.features;
|
package org.jclouds.openstack.nova.v2_0.features;
|
||||||
|
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
||||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||||
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
@ -31,7 +31,7 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
|||||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
||||||
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavorDetails;
|
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavorDetails;
|
||||||
|
@ -19,7 +19,7 @@ package org.jclouds.openstack.nova.v2_0.features;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
||||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||||
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
@ -35,7 +35,7 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
|||||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload;
|
import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
||||||
|
@ -20,7 +20,7 @@ import com.google.common.base.Optional;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.RebootType;
|
import org.jclouds.openstack.nova.v2_0.domain.RebootType;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
|
import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
|
||||||
|
@ -38,7 +38,7 @@ import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
|||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload;
|
import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.RebootType;
|
import org.jclouds.openstack.nova.v2_0.domain.RebootType;
|
||||||
|
@ -19,14 +19,10 @@ package org.jclouds.openstack.nova.v2_0.functions.internal;
|
|||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.internal.GsonWrapper;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.base.Supplier;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,18 +17,18 @@
|
|||||||
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.CallerArg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
|
import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
|
||||||
@ -38,6 +38,7 @@ import org.jclouds.openstack.v2_0.domain.Link;
|
|||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
@ -61,7 +62,7 @@ public class ParseFlavorDetails extends ParseJson<Flavors> {
|
|||||||
super(json, TypeLiteral.get(Flavors.class));
|
super(json, TypeLiteral.get(Flavors.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ToPagedIterable extends CallerArg0ToPagedIterable<Flavor, ToPagedIterable> {
|
public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Flavor, ToPagedIterable> {
|
||||||
|
|
||||||
private final NovaApi api;
|
private final NovaApi api;
|
||||||
|
|
||||||
@ -71,14 +72,16 @@ public class ParseFlavorDetails extends ParseJson<Flavors> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Flavor>> markerToNextForCallingArg0(final String zone) {
|
protected Function<Object, IterableWithMarker<Flavor>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
|
String zone = arg0.get().toString();
|
||||||
final FlavorApi flavorApi = api.getFlavorApiForZone(zone);
|
final FlavorApi flavorApi = api.getFlavorApiForZone(zone);
|
||||||
return new Function<Object, IterableWithMarker<Flavor>>() {
|
return new Function<Object, IterableWithMarker<Flavor>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<Flavor> apply(Object input) {
|
public IterableWithMarker<Flavor> apply(Object input) {
|
||||||
return IterableWithMarker.class.cast(flavorApi.listInDetail(marker(input.toString())));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
return IterableWithMarker.class.cast(flavorApi.listInDetail(paginationOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,7 +90,5 @@ public class ParseFlavorDetails extends ParseJson<Flavors> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,18 +17,18 @@
|
|||||||
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.CallerArg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
|
import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavors.Flavors;
|
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavors.Flavors;
|
||||||
@ -38,6 +38,7 @@ import org.jclouds.openstack.v2_0.domain.Resource;
|
|||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
@ -61,7 +62,7 @@ public class ParseFlavors extends ParseJson<Flavors> {
|
|||||||
super(json, TypeLiteral.get(Flavors.class));
|
super(json, TypeLiteral.get(Flavors.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ToPagedIterable extends CallerArg0ToPagedIterable<Resource, ToPagedIterable> {
|
public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Resource, ToPagedIterable> {
|
||||||
|
|
||||||
private final NovaApi api;
|
private final NovaApi api;
|
||||||
|
|
||||||
@ -71,14 +72,16 @@ public class ParseFlavors extends ParseJson<Flavors> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Resource>> markerToNextForCallingArg0(final String zone) {
|
protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
|
String zone = arg0.get().toString();
|
||||||
final FlavorApi flavorApi = api.getFlavorApiForZone(zone);
|
final FlavorApi flavorApi = api.getFlavorApiForZone(zone);
|
||||||
return new Function<Object, IterableWithMarker<Resource>>() {
|
return new Function<Object, IterableWithMarker<Resource>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<Resource> apply(Object input) {
|
public IterableWithMarker<Resource> apply(Object input) {
|
||||||
return IterableWithMarker.class.cast(flavorApi.list(marker(input.toString())));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
return IterableWithMarker.class.cast(flavorApi.list(paginationOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,18 +17,18 @@
|
|||||||
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.CallerArg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
|
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
|
||||||
@ -38,6 +38,7 @@ import org.jclouds.openstack.v2_0.domain.Link;
|
|||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
@ -61,7 +62,7 @@ public class ParseImageDetails extends ParseJson<Images> {
|
|||||||
super(json, TypeLiteral.get(Images.class));
|
super(json, TypeLiteral.get(Images.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ToPagedIterable extends CallerArg0ToPagedIterable<Image, ToPagedIterable> {
|
public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Image, ToPagedIterable> {
|
||||||
|
|
||||||
private final NovaApi api;
|
private final NovaApi api;
|
||||||
|
|
||||||
@ -71,14 +72,16 @@ public class ParseImageDetails extends ParseJson<Images> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Image>> markerToNextForCallingArg0(final String zone) {
|
protected Function<Object, IterableWithMarker<Image>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
|
String zone = arg0.get().toString();
|
||||||
final ImageApi imageApi = api.getImageApiForZone(zone);
|
final ImageApi imageApi = api.getImageApiForZone(zone);
|
||||||
return new Function<Object, IterableWithMarker<Image>>() {
|
return new Function<Object, IterableWithMarker<Image>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<Image> apply(Object input) {
|
public IterableWithMarker<Image> apply(Object input) {
|
||||||
return IterableWithMarker.class.cast(imageApi.listInDetail(marker(input.toString())));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
return IterableWithMarker.class.cast(imageApi.listInDetail(paginationOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,7 +90,6 @@ public class ParseImageDetails extends ParseJson<Images> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,18 +17,18 @@
|
|||||||
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.CallerArg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
|
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImages.Images;
|
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImages.Images;
|
||||||
@ -38,6 +38,7 @@ import org.jclouds.openstack.v2_0.domain.Resource;
|
|||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
@ -61,7 +62,7 @@ public class ParseImages extends ParseJson<Images> {
|
|||||||
super(json, TypeLiteral.get(Images.class));
|
super(json, TypeLiteral.get(Images.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ToPagedIterable extends CallerArg0ToPagedIterable<Resource, ToPagedIterable> {
|
public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Resource, ToPagedIterable> {
|
||||||
|
|
||||||
private final NovaApi api;
|
private final NovaApi api;
|
||||||
|
|
||||||
@ -71,14 +72,16 @@ public class ParseImages extends ParseJson<Images> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Resource>> markerToNextForCallingArg0(final String zone) {
|
protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
|
String zone = arg0.get().toString();
|
||||||
final ImageApi imageApi = api.getImageApiForZone(zone);
|
final ImageApi imageApi = api.getImageApiForZone(zone);
|
||||||
return new Function<Object, IterableWithMarker<Resource>>() {
|
return new Function<Object, IterableWithMarker<Resource>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<Resource> apply(Object input) {
|
public IterableWithMarker<Resource> apply(Object input) {
|
||||||
return IterableWithMarker.class.cast(imageApi.list(marker(input.toString())));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
return IterableWithMarker.class.cast(imageApi.list(paginationOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,18 +17,18 @@
|
|||||||
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.CallerArg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
|
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
|
||||||
@ -38,6 +38,7 @@ import org.jclouds.openstack.v2_0.domain.Link;
|
|||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
@ -61,7 +62,7 @@ public class ParseServerDetails extends ParseJson<Servers> {
|
|||||||
super(json, TypeLiteral.get(Servers.class));
|
super(json, TypeLiteral.get(Servers.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ToPagedIterable extends CallerArg0ToPagedIterable<Server, ToPagedIterable> {
|
public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Server, ToPagedIterable> {
|
||||||
|
|
||||||
private final NovaApi api;
|
private final NovaApi api;
|
||||||
|
|
||||||
@ -71,14 +72,16 @@ public class ParseServerDetails extends ParseJson<Servers> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Server>> markerToNextForCallingArg0(final String zone) {
|
protected Function<Object, IterableWithMarker<Server>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
|
String zone = arg0.get().toString();
|
||||||
final ServerApi serverApi = api.getServerApiForZone(zone);
|
final ServerApi serverApi = api.getServerApiForZone(zone);
|
||||||
return new Function<Object, IterableWithMarker<Server>>() {
|
return new Function<Object, IterableWithMarker<Server>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<Server> apply(Object input) {
|
public IterableWithMarker<Server> apply(Object input) {
|
||||||
return IterableWithMarker.class.cast(serverApi.listInDetail(marker(input.toString())));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
return IterableWithMarker.class.cast(serverApi.listInDetail(paginationOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,7 +90,5 @@ public class ParseServerDetails extends ParseJson<Servers> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,18 +17,18 @@
|
|||||||
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
package org.jclouds.openstack.nova.v2_0.functions.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.CallerArg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
|
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers.Servers;
|
import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers.Servers;
|
||||||
@ -38,6 +38,7 @@ import org.jclouds.openstack.v2_0.domain.Resource;
|
|||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boiler plate until we determine a better way
|
* boiler plate until we determine a better way
|
||||||
@ -61,7 +62,7 @@ public class ParseServers extends ParseJson<Servers> {
|
|||||||
super(json, TypeLiteral.get(Servers.class));
|
super(json, TypeLiteral.get(Servers.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ToPagedIterable extends CallerArg0ToPagedIterable<Resource, ToPagedIterable> {
|
public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Resource, ToPagedIterable> {
|
||||||
|
|
||||||
private final NovaApi api;
|
private final NovaApi api;
|
||||||
|
|
||||||
@ -71,14 +72,16 @@ public class ParseServers extends ParseJson<Servers> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Resource>> markerToNextForCallingArg0(final String zone) {
|
protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
|
String zone = arg0.get().toString();
|
||||||
final ServerApi serverApi = api.getServerApiForZone(zone);
|
final ServerApi serverApi = api.getServerApiForZone(zone);
|
||||||
return new Function<Object, IterableWithMarker<Resource>>() {
|
return new Function<Object, IterableWithMarker<Resource>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<Resource> apply(Object input) {
|
public IterableWithMarker<Resource> apply(Object input) {
|
||||||
return IterableWithMarker.class.cast(serverApi.list(marker(input.toString())));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
return IterableWithMarker.class.cast(serverApi.list(paginationOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -37,7 +37,10 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
|||||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
import org.jclouds.rackspace.clouddns.v1.CloudDNSApi;
|
import org.jclouds.rackspace.clouddns.v1.CloudDNSApi;
|
||||||
import org.jclouds.rackspace.clouddns.v1.binders.FormatAndContentsToJSON;
|
import org.jclouds.rackspace.clouddns.v1.binders.FormatAndContentsToJSON;
|
||||||
import org.jclouds.rackspace.clouddns.v1.binders.UpdateDomainsToJSON;
|
import org.jclouds.rackspace.clouddns.v1.binders.UpdateDomainsToJSON;
|
||||||
@ -55,10 +58,8 @@ import org.jclouds.rackspace.clouddns.v1.functions.ParseJob;
|
|||||||
import org.jclouds.rackspace.clouddns.v1.functions.ParseSubdomains;
|
import org.jclouds.rackspace.clouddns.v1.functions.ParseSubdomains;
|
||||||
import org.jclouds.rackspace.clouddns.v1.functions.SubdomainsToPagedIterable;
|
import org.jclouds.rackspace.clouddns.v1.functions.SubdomainsToPagedIterable;
|
||||||
import org.jclouds.rackspace.clouddns.v1.predicates.JobPredicates;
|
import org.jclouds.rackspace.clouddns.v1.predicates.JobPredicates;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.CloudIdentityFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.domain.PaginatedCollection;
|
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.functions.DateParser;
|
import org.jclouds.rackspace.cloudidentity.v2_0.functions.DateParser;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.options.PaginationOptions;
|
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
import org.jclouds.rest.annotations.Fallback;
|
import org.jclouds.rest.annotations.Fallback;
|
||||||
@ -144,7 +145,7 @@ public interface DomainApi {
|
|||||||
@GET
|
@GET
|
||||||
@ResponseParser(ParseDomains.class)
|
@ResponseParser(ParseDomains.class)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
|
@Fallback(KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404.class)
|
||||||
@Path("/domains")
|
@Path("/domains")
|
||||||
PaginatedCollection<Domain> list(PaginationOptions options);
|
PaginatedCollection<Domain> list(PaginationOptions options);
|
||||||
|
|
||||||
@ -168,7 +169,7 @@ public interface DomainApi {
|
|||||||
@GET
|
@GET
|
||||||
@ResponseParser(ParseSubdomains.class)
|
@ResponseParser(ParseSubdomains.class)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
|
@Fallback(KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404.class)
|
||||||
@Path("/domains/{domainId}/subdomains")
|
@Path("/domains/{domainId}/subdomains")
|
||||||
PaginatedCollection<Subdomain> listSubdomains(@PathParam("domainId") int domainId,
|
PaginatedCollection<Subdomain> listSubdomains(@PathParam("domainId") int domainId,
|
||||||
PaginationOptions options);
|
PaginationOptions options);
|
||||||
|
@ -35,7 +35,10 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
|||||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||||
import org.jclouds.collect.PagedIterable;
|
import org.jclouds.collect.PagedIterable;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
import org.jclouds.rackspace.clouddns.v1.CloudDNSApi;
|
import org.jclouds.rackspace.clouddns.v1.CloudDNSApi;
|
||||||
import org.jclouds.rackspace.clouddns.v1.binders.UpdateRecordsToJSON;
|
import org.jclouds.rackspace.clouddns.v1.binders.UpdateRecordsToJSON;
|
||||||
import org.jclouds.rackspace.clouddns.v1.config.CloudDNS;
|
import org.jclouds.rackspace.clouddns.v1.config.CloudDNS;
|
||||||
@ -48,9 +51,6 @@ import org.jclouds.rackspace.clouddns.v1.functions.ParseRecord;
|
|||||||
import org.jclouds.rackspace.clouddns.v1.functions.ParseRecords;
|
import org.jclouds.rackspace.clouddns.v1.functions.ParseRecords;
|
||||||
import org.jclouds.rackspace.clouddns.v1.functions.RecordsToPagedIterable;
|
import org.jclouds.rackspace.clouddns.v1.functions.RecordsToPagedIterable;
|
||||||
import org.jclouds.rackspace.clouddns.v1.predicates.JobPredicates;
|
import org.jclouds.rackspace.clouddns.v1.predicates.JobPredicates;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.CloudIdentityFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
|
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.domain.PaginatedCollection;
|
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.options.PaginationOptions;
|
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
import org.jclouds.rest.annotations.Fallback;
|
import org.jclouds.rest.annotations.Fallback;
|
||||||
@ -142,7 +142,7 @@ public interface RecordApi {
|
|||||||
@GET
|
@GET
|
||||||
@ResponseParser(ParseRecords.class)
|
@ResponseParser(ParseRecords.class)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
|
@Fallback(KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404.class)
|
||||||
@Path("/records")
|
@Path("/records")
|
||||||
PaginatedCollection<RecordDetail> list(PaginationOptions options);
|
PaginatedCollection<RecordDetail> list(PaginationOptions options);
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
import org.jclouds.rackspace.clouddns.v1.CloudDNSApi;
|
import org.jclouds.rackspace.clouddns.v1.CloudDNSApi;
|
||||||
import org.jclouds.rackspace.clouddns.v1.domain.Domain;
|
import org.jclouds.rackspace.clouddns.v1.domain.Domain;
|
||||||
import org.jclouds.rackspace.clouddns.v1.features.DomainApi;
|
import org.jclouds.rackspace.clouddns.v1.features.DomainApi;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.domain.PaginatedCollection;
|
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.options.PaginationOptions;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -25,8 +25,8 @@ import javax.inject.Inject;
|
|||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.rackspace.clouddns.v1.domain.Domain;
|
import org.jclouds.rackspace.clouddns.v1.domain.Domain;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.domain.PaginatedCollection;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ import javax.inject.Inject;
|
|||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.rackspace.clouddns.v1.domain.RecordDetail;
|
import org.jclouds.rackspace.clouddns.v1.domain.RecordDetail;
|
||||||
import org.jclouds.rackspace.clouddns.v1.functions.ParseRecord.RawRecord;
|
import org.jclouds.rackspace.clouddns.v1.functions.ParseRecord.RawRecord;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.domain.PaginatedCollection;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class ParseRecords implements Function<HttpResponse, PaginatedCollection<
|
|||||||
RawRecords rawRecords = json.apply(response);
|
RawRecords rawRecords = json.apply(response);
|
||||||
Iterable<RecordDetail> records = rawRecords.transform(toRecordDetails);
|
Iterable<RecordDetail> records = rawRecords.transform(toRecordDetails);
|
||||||
|
|
||||||
return new Records(records, rawRecords.getLinks(), rawRecords.getTotalEntries());
|
return new Records(records, rawRecords.getLinks(), rawRecords.getTotalEntries().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RawRecords extends PaginatedCollection<RawRecord> {
|
private static class RawRecords extends PaginatedCollection<RawRecord> {
|
||||||
|
@ -26,8 +26,8 @@ import org.jclouds.http.HttpRequest;
|
|||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.rackspace.clouddns.v1.domain.Subdomain;
|
import org.jclouds.rackspace.clouddns.v1.domain.Subdomain;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.domain.PaginatedCollection;
|
|
||||||
import org.jclouds.rest.InvocationContext;
|
import org.jclouds.rest.InvocationContext;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -22,11 +22,11 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
import org.jclouds.rackspace.clouddns.v1.CloudDNSApi;
|
import org.jclouds.rackspace.clouddns.v1.CloudDNSApi;
|
||||||
import org.jclouds.rackspace.clouddns.v1.domain.RecordDetail;
|
import org.jclouds.rackspace.clouddns.v1.domain.RecordDetail;
|
||||||
import org.jclouds.rackspace.clouddns.v1.features.RecordApi;
|
import org.jclouds.rackspace.clouddns.v1.features.RecordApi;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.domain.PaginatedCollection;
|
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.options.PaginationOptions;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -22,11 +22,11 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
import org.jclouds.rackspace.clouddns.v1.CloudDNSApi;
|
import org.jclouds.rackspace.clouddns.v1.CloudDNSApi;
|
||||||
import org.jclouds.rackspace.clouddns.v1.domain.Subdomain;
|
import org.jclouds.rackspace.clouddns.v1.domain.Subdomain;
|
||||||
import org.jclouds.rackspace.clouddns.v1.features.DomainApi;
|
import org.jclouds.rackspace.clouddns.v1.features.DomainApi;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.domain.PaginatedCollection;
|
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.options.PaginationOptions;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.rackspace.cloudidentity.v2_0;
|
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Futures.immediateFuture;
|
|
||||||
import static org.jclouds.Fallbacks.valOnNotFoundOr404;
|
|
||||||
|
|
||||||
import org.jclouds.Fallback;
|
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.domain.PaginatedCollection;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
|
|
||||||
public final class CloudIdentityFallbacks {
|
|
||||||
private CloudIdentityFallbacks() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class EmptyPaginatedCollectionOnNotFoundOr404 implements Fallback<PaginatedCollection<Object>> {
|
|
||||||
private static final PaginatedCollection<Object> EMPTY = new PaginatedCollection<Object>(
|
|
||||||
ImmutableSet.<Object> of(), ImmutableSet.<Link> of(), 0) {
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ListenableFuture<PaginatedCollection<Object>> create(Throwable t) throws Exception {
|
|
||||||
return immediateFuture(createOrPropagate(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PaginatedCollection<Object> createOrPropagate(Throwable t) throws Exception {
|
|
||||||
return valOnNotFoundOr404(EMPTY, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.rackspace.cloudidentity.v2_0.options;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Options used to control paginated results (aka list commands).
|
|
||||||
*
|
|
||||||
* @author Everett Toews
|
|
||||||
*/
|
|
||||||
public class PaginationOptions extends BaseHttpRequestOptions {
|
|
||||||
public PaginationOptions queryParameters(Multimap<String, String> queryParams) {
|
|
||||||
checkNotNull(queryParams, "queryParams");
|
|
||||||
queryParameters.putAll(queryParams);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Offset is the starting point for the return data. Offset must be a multiple of the limit (or zero).
|
|
||||||
*/
|
|
||||||
public PaginationOptions offset(int offset) {
|
|
||||||
checkState(offset >= 0, "offset must be >= 0");
|
|
||||||
queryParameters.put("offset", String.valueOf(offset));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Limit is the restriction on the maximum number of items for that type that can be returned.
|
|
||||||
* <p/>
|
|
||||||
* Note that list operations never return itemNotFound (404) faults.
|
|
||||||
*/
|
|
||||||
public PaginationOptions 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Name is a filter on the result set.
|
|
||||||
*/
|
|
||||||
public PaginationOptions name(String nameFilter) {
|
|
||||||
queryParameters.put("name", nameFilter);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
public static PaginationOptions queryParameters(Multimap<String, String> queryParams) {
|
|
||||||
PaginationOptions options = new PaginationOptions();
|
|
||||||
return options.queryParameters(queryParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see PaginationOptions#offset(int)
|
|
||||||
*/
|
|
||||||
public static PaginationOptions offset(int offset) {
|
|
||||||
PaginationOptions options = new PaginationOptions();
|
|
||||||
return options.offset(offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see PaginationOptions#limit(int)
|
|
||||||
*/
|
|
||||||
public static PaginationOptions limit(int limit) {
|
|
||||||
PaginationOptions options = new PaginationOptions();
|
|
||||||
return options.limit(limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see PaginationOptions#name(String)
|
|
||||||
*/
|
|
||||||
public static PaginationOptions name(String name) {
|
|
||||||
PaginationOptions options = new PaginationOptions();
|
|
||||||
return options.name(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.rackspace.cloudidentity.v2_0.options;
|
|
||||||
|
|
||||||
import static org.jclouds.rackspace.cloudidentity.v2_0.options.PaginationOptions.Builder.limit;
|
|
||||||
import static org.jclouds.rackspace.cloudidentity.v2_0.options.PaginationOptions.Builder.name;
|
|
||||||
import static org.jclouds.rackspace.cloudidentity.v2_0.options.PaginationOptions.Builder.offset;
|
|
||||||
import static org.jclouds.rackspace.cloudidentity.v2_0.options.PaginationOptions.Builder.queryParameters;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ImmutableSetMultimap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Everett Toews
|
|
||||||
*/
|
|
||||||
@Test(groups = "unit", testName = "PaginationOptionsTest")
|
|
||||||
public class PaginationOptionsTest {
|
|
||||||
|
|
||||||
public void testQueryParameters() {
|
|
||||||
ImmutableSetMultimap<String, String> queryParameters = ImmutableSetMultimap.<String, String> of(
|
|
||||||
"limit", "1",
|
|
||||||
"offset", "1",
|
|
||||||
"name", "foo");
|
|
||||||
PaginationOptions options = new PaginationOptions().queryParameters(queryParameters);
|
|
||||||
assertEquals(queryParameters, options.buildQueryParameters());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testMaxResults() {
|
|
||||||
int limit = 1;
|
|
||||||
PaginationOptions options = new PaginationOptions().limit(limit);
|
|
||||||
assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("limit"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testOffset() {
|
|
||||||
int offset = 1;
|
|
||||||
PaginationOptions options = new PaginationOptions().offset(offset);
|
|
||||||
assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("offset"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testNameFilter() {
|
|
||||||
String nameFilter = "foo";
|
|
||||||
PaginationOptions options = new PaginationOptions().name(nameFilter);
|
|
||||||
assertEquals(ImmutableList.of("foo"), options.buildQueryParameters().get("name"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testMaxResultsStatic() {
|
|
||||||
int limit = 1;
|
|
||||||
PaginationOptions options = limit(limit);
|
|
||||||
assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("limit"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testOffsetStatic() {
|
|
||||||
int offset = 1;
|
|
||||||
PaginationOptions options = offset(offset);
|
|
||||||
assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("offset"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testNameFilterStatic() {
|
|
||||||
String nameFilter = "foo";
|
|
||||||
PaginationOptions options = name(nameFilter);
|
|
||||||
assertEquals(ImmutableList.of("foo"), options.buildQueryParameters().get("name"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testQueryParametersStatic() {
|
|
||||||
ImmutableSetMultimap<String, String> queryParameters = ImmutableSetMultimap.<String, String> of(
|
|
||||||
"limit", "1",
|
|
||||||
"offset", "1",
|
|
||||||
"name", "foo");
|
|
||||||
PaginationOptions options = queryParameters(queryParameters);
|
|
||||||
assertEquals(queryParameters, options.buildQueryParameters());
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,6 @@
|
|||||||
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
@ -28,8 +27,9 @@ import org.jclouds.collect.IterableWithMarker;
|
|||||||
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerUsage;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerUsage;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.features.ReportApi;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.features.ReportApi;
|
||||||
@ -71,14 +71,15 @@ public class ParseLoadBalancerUsages extends ParseJson<LoadBalancerUsages> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<LoadBalancerUsage>> markerToNextForArg0(Optional<Object> arg0) {
|
protected Function<Object, IterableWithMarker<LoadBalancerUsage>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
String zone = arg0.isPresent() ? arg0.get().toString() : null;
|
String zone = arg0.get().toString();
|
||||||
final ReportApi reportApi = api.getReportApiForZone(zone);
|
final ReportApi reportApi = api.getReportApiForZone(zone);
|
||||||
|
|
||||||
return new Function<Object, IterableWithMarker<LoadBalancerUsage>>() {
|
return new Function<Object, IterableWithMarker<LoadBalancerUsage>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<LoadBalancerUsage> apply(Object input) {
|
public IterableWithMarker<LoadBalancerUsage> apply(Object input) {
|
||||||
IterableWithMarker<LoadBalancerUsage> list = reportApi.listLoadBalancerUsage(marker(input.toString()));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
IterableWithMarker<LoadBalancerUsage> list = reportApi.listLoadBalancerUsage(paginationOptions);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -30,8 +29,9 @@ import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
|||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.features.LoadBalancerApi;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.features.LoadBalancerApi;
|
||||||
@ -106,14 +106,15 @@ public class ParseLoadBalancers implements Function<HttpResponse, IterableWithMa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<LoadBalancer>> markerToNextForArg0(Optional<Object> arg0) {
|
protected Function<Object, IterableWithMarker<LoadBalancer>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
String zone = arg0.isPresent() ? arg0.get().toString() : null;
|
String zone = arg0.get().toString();
|
||||||
final LoadBalancerApi loadBalancerApi = api.getLoadBalancerApiForZone(zone);
|
final LoadBalancerApi loadBalancerApi = api.getLoadBalancerApiForZone(zone);
|
||||||
|
|
||||||
return new Function<Object, IterableWithMarker<LoadBalancer>>() {
|
return new Function<Object, IterableWithMarker<LoadBalancer>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<LoadBalancer> apply(Object input) {
|
public IterableWithMarker<LoadBalancer> apply(Object input) {
|
||||||
IterableWithMarker<LoadBalancer> list = loadBalancerApi.list(marker(input.toString()));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
IterableWithMarker<LoadBalancer> list = loadBalancerApi.list(paginationOptions);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
@ -29,8 +28,9 @@ import org.jclouds.collect.internal.Arg0ToPagedIterable;
|
|||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.json.Json;
|
import org.jclouds.json.Json;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection;
|
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
|
||||||
import org.jclouds.openstack.v2_0.domain.Link;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi;
|
||||||
@ -86,14 +86,15 @@ public class ParseNodes extends ParseJson<Nodes> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<Object, IterableWithMarker<Node>> markerToNextForArg0(Optional<Object> arg0) {
|
protected Function<Object, IterableWithMarker<Node>> markerToNextForArg0(Optional<Object> arg0) {
|
||||||
String zone = arg0.isPresent() ? arg0.get().toString() : null;
|
String zone = arg0.get().toString();
|
||||||
final NodeApi nodeApi = api.getNodeApiForZoneAndLoadBalancer(zone, lbId);
|
final NodeApi nodeApi = api.getNodeApiForZoneAndLoadBalancer(zone, lbId);
|
||||||
|
|
||||||
return new Function<Object, IterableWithMarker<Node>>() {
|
return new Function<Object, IterableWithMarker<Node>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IterableWithMarker<Node> apply(Object input) {
|
public IterableWithMarker<Node> apply(Object input) {
|
||||||
IterableWithMarker<Node> list = nodeApi.list(marker(input.toString()));
|
PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
|
||||||
|
IterableWithMarker<Node> list = nodeApi.list(paginationOptions);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user