You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2013/11/14 12:23:16 UTC
[13/13] git commit: JCLOUDS-291: Add pagination support to the
cloudsigma2 provider.
JCLOUDS-291: Add pagination support to the cloudsigma2 provider.
https://issues.apache.org/jira/browse/JCLOUDS-291
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/0bebb584
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/0bebb584
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/0bebb584
Branch: refs/heads/master
Commit: 0bebb584662d30fd7f9b772f787feeebdc9d9d0a
Parents: d9717a4
Author: Vladimir Shevchenko <sh...@gmail.com>
Authored: Sat Nov 9 20:18:25 2013 +0700
Committer: Ignasi Barrera <na...@apache.org>
Committed: Thu Nov 14 12:20:57 2013 +0100
----------------------------------------------------------------------
.../org/jclouds/cloudsigma2/CloudSigma2Api.java | 356 +++++++++--
.../cloudsigma2/domain/PaginatedCollection.java | 58 ++
.../functions/internal/ParseDiscounts.java | 73 +++
.../functions/internal/ParseDriveInfos.java | 74 +++
.../functions/internal/ParseDrives.java | 73 +++
.../internal/ParseFirewallPolicies.java | 94 +++
.../functions/internal/ParseIPInfos.java | 73 +++
.../functions/internal/ParseIPs.java | 73 +++
.../functions/internal/ParseLibraryDrives.java | 73 +++
.../functions/internal/ParseLicenses.java | 73 +++
.../functions/internal/ParseServerInfos.java | 74 +++
.../functions/internal/ParseServers.java | 74 +++
.../functions/internal/ParseSubscriptions.java | 95 +++
.../functions/internal/ParseTags.java | 94 +++
.../functions/internal/ParseTransactions.java | 73 +++
.../functions/internal/ParseVLANs.java | 94 +++
.../cloudsigma2/options/PaginationOptions.java | 117 ++++
.../cloudsigma2/CloudSigma2ApiExpectTest.java | 602 +++++++++++++++++--
.../cloudsigma2/CloudSigma2ApiLiveTest.java | 43 +-
.../src/test/resources/discount-last-page.json | 17 +
cloudsigma2/src/test/resources/discount.json | 10 +-
.../resources/drives-detail-first-page.json | 88 +++
.../test/resources/drives-detail-last-page.json | 31 +
.../src/test/resources/drives-last-page.json | 18 +
cloudsigma2/src/test/resources/drives.json | 11 +-
.../resources/fwpolicies-detail-first-page.json | 32 +
.../resources/fwpolicies-detail-last-page.json | 79 +++
.../src/test/resources/ips-last-page.json | 28 +
cloudsigma2/src/test/resources/ips.json | 21 +-
.../src/test/resources/ledger-last-page.json | 27 +
cloudsigma2/src/test/resources/ledger.json | 24 +-
.../src/test/resources/libdrives-last-page.json | 36 ++
cloudsigma2/src/test/resources/libdrives.json | 33 +-
.../src/test/resources/licences-last-page.json | 17 +
cloudsigma2/src/test/resources/licences.json | 12 +-
.../resources/server-detail-first-page.json | 96 +++
.../test/resources/server-detail-last-page.json | 34 ++
.../src/test/resources/servers-last-page.json | 20 +
cloudsigma2/src/test/resources/servers.json | 13 +-
.../resources/subscriptions-first-page.json | 47 ++
.../test/resources/subscriptions-last-page.json | 28 +
.../test/resources/tags-detail-first-page.json | 20 +
.../test/resources/tags-detail-last-page.json | 59 ++
.../src/test/resources/vlans-last-page.json | 21 +
cloudsigma2/src/test/resources/vlans.json | 14 +-
45 files changed, 2857 insertions(+), 265 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/CloudSigma2Api.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/CloudSigma2Api.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/CloudSigma2Api.java
index 31eafa2..b594169 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/CloudSigma2Api.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/CloudSigma2Api.java
@@ -46,6 +46,7 @@ import org.jclouds.cloudsigma2.domain.IP;
import org.jclouds.cloudsigma2.domain.IPInfo;
import org.jclouds.cloudsigma2.domain.LibraryDrive;
import org.jclouds.cloudsigma2.domain.License;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
import org.jclouds.cloudsigma2.domain.Pricing;
import org.jclouds.cloudsigma2.domain.ProfileInfo;
import org.jclouds.cloudsigma2.domain.Server;
@@ -55,14 +56,32 @@ import org.jclouds.cloudsigma2.domain.Subscription;
import org.jclouds.cloudsigma2.domain.Tag;
import org.jclouds.cloudsigma2.domain.Transaction;
import org.jclouds.cloudsigma2.domain.VLANInfo;
+import org.jclouds.cloudsigma2.functions.internal.ParseDiscounts;
+import org.jclouds.cloudsigma2.functions.internal.ParseDriveInfos;
+import org.jclouds.cloudsigma2.functions.internal.ParseDrives;
+import org.jclouds.cloudsigma2.functions.internal.ParseFirewallPolicies;
+import org.jclouds.cloudsigma2.functions.internal.ParseIPInfos;
+import org.jclouds.cloudsigma2.functions.internal.ParseIPs;
+import org.jclouds.cloudsigma2.functions.internal.ParseLibraryDrives;
+import org.jclouds.cloudsigma2.functions.internal.ParseLicenses;
+import org.jclouds.cloudsigma2.functions.internal.ParseServerInfos;
+import org.jclouds.cloudsigma2.functions.internal.ParseServers;
+import org.jclouds.cloudsigma2.functions.internal.ParseSubscriptions;
+import org.jclouds.cloudsigma2.functions.internal.ParseTags;
+import org.jclouds.cloudsigma2.functions.internal.ParseTransactions;
+import org.jclouds.cloudsigma2.functions.internal.ParseVLANs;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.PagedIterable;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -94,9 +113,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("drive:listDrives")
@GET
- @Path("/drives/?limit=0")
- @SelectJson("objects")
- List<Drive> listDrives();
+ @Path("/drives/")
+ @ResponseParser(ParseDrives.class)
+ @Transform(ParseDrives.ToPagedIterable.class)
+ PagedIterable<Drive> listDrives();
+
+ /**
+ * Gets the list of drives to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of drives
+ */
+ @Named("drive:listDrives")
+ @GET
+ @Path("/drives/")
+ @ResponseParser(ParseDrives.class)
+ PaginatedCollection<Drive> listDrives(PaginationOptions options);
/**
* Gets the list of drives to which the authenticated user has access.
@@ -107,7 +138,7 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("drive:listDrives")
@GET
- @Path("/drives/?limit=0")
+ @Path("/drives/")
@SelectJson("objects")
List<DriveInfo> listDrives(@QueryParam("fields") DrivesListRequestFieldsGroup fields
, @DefaultValue("0") @QueryParam("limit") int limit);
@@ -119,9 +150,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("drive:listDrivesInfo")
@GET
- @Path("/drives/detail/?limit=0")
- @SelectJson("objects")
- List<DriveInfo> listDrivesInfo();
+ @Path("/drives/detail/")
+ @ResponseParser(ParseDriveInfos.class)
+ @Transform(ParseDriveInfos.ToPagedIterable.class)
+ PagedIterable<DriveInfo> listDrivesInfo();
+
+ /**
+ * Gets the detailed list of drives with additional information to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of drives
+ */
+ @Named("drive:listDrivesInfo")
+ @GET
+ @Path("/drives/detail/")
+ @ResponseParser(ParseDriveInfos.class)
+ PaginatedCollection<DriveInfo> listDrivesInfo(PaginationOptions options);
/**
* Gets detailed information for drive identified by drive uuid
@@ -220,9 +263,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("libdrive:listLibraryDrives")
@GET
- @Path("/libdrives/?limit=0")
- @SelectJson("objects")
- List<LibraryDrive> listLibraryDrives();
+ @Path("/libdrives/")
+ @ResponseParser(ParseLibraryDrives.class)
+ @Transform(ParseLibraryDrives.ToPagedIterable.class)
+ PagedIterable<LibraryDrive> listLibraryDrives();
+
+ /**
+ * Gets the list of library drives to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of library drives
+ */
+ @Named("libdrive:listLibraryDrives")
+ @GET
+ @Path("/libdrives/")
+ @ResponseParser(ParseLibraryDrives.class)
+ PaginatedCollection<LibraryDrive> listLibraryDrives(PaginationOptions options);
/**
* Gets detailed information for library drive identified by uuid.
@@ -257,9 +312,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("server:listServers")
@GET
- @Path("/servers/?limit=0")
- @SelectJson("objects")
- List<Server> listServers();
+ @Path("/servers/")
+ @ResponseParser(ParseServers.class)
+ @Transform(ParseServers.ToPagedIterable.class)
+ PagedIterable<Server> listServers();
+
+ /**
+ * Gets the list of servers to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of servers
+ */
+ @Named("server:listServers")
+ @GET
+ @Path("/servers/")
+ @ResponseParser(ParseServers.class)
+ PaginatedCollection<Server> listServers(PaginationOptions options);
/**
* Gets the detailed list of servers to which the authenticated user has access.
@@ -268,9 +335,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("server:listServersInfo")
@GET
- @Path("/servers/detail/?limit=0")
- @SelectJson("objects")
- List<ServerInfo> listServersInfo();
+ @Path("/servers/detail/")
+ @ResponseParser(ParseServerInfos.class)
+ @Transform(ParseServerInfos.ToPagedIterable.class)
+ PagedIterable<ServerInfo> listServersInfo();
+
+ /**
+ * Gets the detailed list of servers to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of servers
+ */
+ @Named("server:listServersInfo")
+ @GET
+ @Path("/servers/detail/")
+ @ResponseParser(ParseServerInfos.class)
+ PaginatedCollection<ServerInfo> listServersInfo(PaginationOptions options);
/**
* Creates a new virtual server or multiple servers.
@@ -433,7 +512,7 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("server:listServerAvailabilityGroup")
@GET
- @Path("/servers/availability_groups/?limit=0")
+ @Path("/servers/availability_groups/")
List<List<String>> listServerAvailabilityGroup();
/**
@@ -456,9 +535,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("fwpolicy:listFirewallPolicies")
@GET
- @Path("/fwpolicies/?limit=0")
- @SelectJson("objects")
- List<FirewallPolicy> listFirewallPolicies();
+ @Path("/fwpolicies/")
+ @ResponseParser(ParseFirewallPolicies.class)
+ @Transform(ParseFirewallPolicies.ToPagedIterable.class)
+ PagedIterable<FirewallPolicy> listFirewallPolicies();
+
+ /**
+ * Gets the list of firewall policies to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of firewall policies
+ */
+ @Named("fwpolicy:listFirewallPolicies")
+ @GET
+ @Path("/fwpolicies/")
+ @ResponseParser(ParseFirewallPolicies.class)
+ PaginatedCollection<FirewallPolicy> listFirewallPolicies(PaginationOptions options);
/**
* Gets a detailed list of firewall policies to which the authenticated user has access.
@@ -467,9 +558,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("fwpolicy:listFirewallPoliciesInfo")
@GET
- @Path("/fwpolicies/detail/?limit=0")
- @SelectJson("objects")
- List<FirewallPolicy> listFirewallPoliciesInfo();
+ @Path("/fwpolicies/detail/")
+ @ResponseParser(ParseFirewallPolicies.class)
+ @Transform(ParseFirewallPolicies.ToPagedIterableInfo.class)
+ PagedIterable<FirewallPolicy> listFirewallPoliciesInfo();
+
+ /**
+ * Gets a detailed list of firewall policies to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of firewall policies
+ */
+ @Named("fwpolicy:listFirewallPoliciesInfo")
+ @GET
+ @Path("/fwpolicies/detail/")
+ @ResponseParser(ParseFirewallPolicies.class)
+ PaginatedCollection<FirewallPolicy> listFirewallPoliciesInfo(PaginationOptions options);
/**
* Creates firewall policies.
@@ -482,7 +585,7 @@ public interface CloudSigma2Api extends Closeable {
@Path("/fwpolicies/")
@SelectJson("objects")
List<FirewallPolicy> createFirewallPolicies(
- @BinderParam(BindFirewallPoliciesListToJsonRequest.class) List<FirewallPolicy> firewallPolicies);
+ @BinderParam(BindFirewallPoliciesListToJsonRequest.class) List< FirewallPolicy > firewallPolicies);
/**
* Creates a firewall policy.
@@ -530,9 +633,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("vlan:listVLANs")
@GET
- @Path("/vlans/?limit=0")
- @SelectJson("objects")
- List<VLANInfo> listVLANs();
+ @Path("/vlans/")
+ @ResponseParser(ParseVLANs.class)
+ @Transform(ParseVLANs.ToPagedIterable.class)
+ PagedIterable<VLANInfo> listVLANs();
+
+ /**
+ * Gets the list of VLANs to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of VLANs
+ */
+ @Named("vlan:listVLANs")
+ @GET
+ @Path("/vlans/")
+ @ResponseParser(ParseVLANs.class)
+ PaginatedCollection<VLANInfo> listVLANs(PaginationOptions options);
/**
* Gets the list of VLANs to which the authenticated user has access.
@@ -541,9 +656,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("vlan:listVLANInfo")
@GET
- @Path("/vlans/detail/?limit=0")
- @SelectJson("objects")
- List<VLANInfo> listVLANInfo();
+ @Path("/vlans/detail/")
+ @ResponseParser(ParseVLANs.class)
+ @Transform(ParseVLANs.ToPagedIterableInfo.class)
+ PagedIterable<VLANInfo> listVLANInfo();
+
+ /**
+ * Gets the list of VLANs to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of VLANs
+ */
+ @Named("vlan:listVLANInfo")
+ @GET
+ @Path("/vlans/detail/")
+ @ResponseParser(ParseVLANs.class)
+ PaginatedCollection<VLANInfo> listVLANInfo(PaginationOptions options);
/**
* Currently only VLAN meta field can be edited.
@@ -566,9 +693,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("ip:listIPs")
@GET
- @Path("/ips/?limit=0")
- @SelectJson("objects")
- List<IP> listIPs();
+ @Path("/ips/")
+ @ResponseParser(ParseIPs.class)
+ @Transform(ParseIPs.ToPagedIterable.class)
+ PagedIterable<IP> listIPs();
+
+ /**
+ * Gets the list of IPs to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of IPs
+ */
+ @Named("ip:listIPs")
+ @GET
+ @Path("/ips/")
+ @ResponseParser(ParseIPs.class)
+ PaginatedCollection<IP> listIPs(PaginationOptions options);
/**
* Gets the detailed list of IPs with additional information to which the authenticated user has access.
@@ -577,9 +716,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("ip:listIPInfo")
@GET
- @Path("/ips/detail/?limit=0")
- @SelectJson("objects")
- List<IPInfo> listIPInfo();
+ @Path("/ips/detail/")
+ @ResponseParser(ParseIPInfos.class)
+ @Transform(ParseIPInfos.ToPagedIterable.class)
+ PagedIterable<IPInfo> listIPInfo();
+
+ /**
+ * Gets the detailed list of IPs with additional information to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of IPs
+ */
+ @Named("ip:listIPInfo")
+ @GET
+ @Path("/ips/detail/")
+ @ResponseParser(ParseIPInfos.class)
+ PaginatedCollection<IPInfo> listIPInfo(PaginationOptions options);
/**
* Gets detailed information for IP identified by IP uuid.
@@ -614,9 +765,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("tag:listTags")
@GET
- @Path("/tags/?limit=0")
- @SelectJson("objects")
- List<Tag> listTags();
+ @Path("/tags/")
+ @ResponseParser(ParseTags.class)
+ @Transform(ParseTags.ToPagedIterable.class)
+ PagedIterable<Tag> listTags();
+
+ /**
+ * Gets the list of tags to which the authenticated user has access.
+ *
+ * @return PaginatedCollection of tags to which the authenticated user has access
+ */
+ @Named("tag:listTags")
+ @GET
+ @Path("/tags/")
+ @ResponseParser(ParseTags.class)
+ PaginatedCollection<Tag> listTags(PaginationOptions options);
/**
* Gets the detailed list of tags with additional information to which the authenticated user has access,
@@ -626,9 +789,22 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("tag:listTagsInfo")
@GET
- @Path("/tags/detail/?limit=0")
- @SelectJson("objects")
- List<Tag> listTagsInfo();
+ @Path("/tags/detail/")
+ @ResponseParser(ParseTags.class)
+ @Transform(ParseTags.ToPagedIterableInfo.class)
+ PagedIterable<Tag> listTagsInfo();
+
+ /**
+ * Gets the detailed list of tags with additional information to which the authenticated user has access,
+ * like the tagged resource
+ *
+ * @return PaginatedCollection of detailed tags
+ */
+ @Named("tag:listTagsInfo")
+ @GET
+ @Path("/tags/detail/")
+ @ResponseParser(ParseTags.class)
+ PaginatedCollection<Tag> listTagsInfo(PaginationOptions options);
/**
* Gets detailed information for tag identified by tag uuid.
@@ -740,9 +916,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("subscription:listSubscriptions")
@GET
- @Path("/subscriptions/?limit=0")
- @SelectJson("objects")
- List<Subscription> listSubscriptions();
+ @Path("/subscriptions/")
+ @ResponseParser(ParseSubscriptions.class)
+ @Transform(ParseSubscriptions.ToPagedIterable.class)
+ PagedIterable<Subscription> listSubscriptions();
+
+ /**
+ * Gets the list of subscriptions of the user.
+ *
+ * @return PaginatedCollection of subscriptions of the user.
+ */
+ @Named("subscription:listSubscriptions")
+ @GET
+ @Path("/subscriptions/")
+ @ResponseParser(ParseSubscriptions.class)
+ PaginatedCollection<Subscription> listSubscriptions(PaginationOptions options);
/**
* Returns requested subscription
@@ -762,9 +950,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("subscription:listSubscriptionsCalculator")
@GET
- @Path("/subscriptioncalculator/?limit=0")
- @SelectJson("objects")
- List<Subscription> listSubscriptionsCalculator();
+ @Path("/subscriptioncalculator/")
+ @ResponseParser(ParseSubscriptions.class)
+ @Transform(ParseSubscriptions.ToPagedIterableCalculator.class)
+ PagedIterable<Subscription> listSubscriptionsCalculator();
+
+ /**
+ * This is identical to the listSubscriptions(), except that subscriptions are not actually bought.
+ *
+ * @return PaginatedCollection of subscriptions that are not actually bought.
+ */
+ @Named("subscription:listSubscriptionsCalculator")
+ @GET
+ @Path("/subscriptioncalculator/")
+ @ResponseParser(ParseSubscriptions.class)
+ PaginatedCollection<Subscription> listSubscriptionsCalculator(PaginationOptions options);
/**
* Creates a new subscription.
@@ -849,9 +1049,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("discount:listDiscounts")
@GET
- @Path("/discount/?limit=0")
- @SelectJson("objects")
- List<Discount> listDiscounts();
+ @Path("/discount/")
+ @ResponseParser(ParseDiscounts.class)
+ @Transform(ParseDiscounts.ToPagedIterable.class)
+ PagedIterable<Discount> listDiscounts();
+
+ /**
+ * Get discount information.
+ *
+ * @return PaginatedCollection of discount information.
+ */
+ @Named("discount:listDiscounts")
+ @GET
+ @Path("/discount/")
+ @ResponseParser(ParseDiscounts.class)
+ PaginatedCollection<Discount> listDiscounts(PaginationOptions options);
/**
* Get the transactions for the account.
@@ -860,9 +1072,21 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("ledger:listTransactions")
@GET
- @Path("/ledger/?limit=0")
- @SelectJson("objects")
- List<Transaction> listTransactions();
+ @Path("/ledger/")
+ @ResponseParser(ParseTransactions.class)
+ @Transform(ParseTransactions.ToPagedIterable.class)
+ PagedIterable<Transaction> listTransactions();
+
+ /**
+ * Get the transactions for the account.
+ *
+ * @return PaginatedCollection of account's transactions.
+ */
+ @Named("ledger:listTransactions")
+ @GET
+ @Path("/ledger/")
+ @ResponseParser(ParseTransactions.class)
+ PaginatedCollection<Transaction> listTransactions(PaginationOptions options);
/**
* Get the licenses available on the cloud. The type of the license can be one of:
@@ -877,7 +1101,25 @@ public interface CloudSigma2Api extends Closeable {
*/
@Named("license:listLicenses")
@GET
- @Path("/licenses/?limit=0")
- @SelectJson("objects")
- List<License> listLicenses();
+ @Path("/licenses/")
+ @ResponseParser(ParseLicenses.class)
+ @Transform(ParseLicenses.ToPagedIterable.class)
+ PagedIterable<License> listLicenses();
+
+ /**
+ * Get the licenses available on the cloud. The type of the license can be one of:
+ * install - These licenses are billed per installation, regardless of whether it is attached to a running guests or not.
+ * instance - These licenses are billed per running instance of a guest. A license attached to a guest that’s stopped is not billed.
+ * stub - These licenses are billed per a metric specified by the customer (i.e. per number of users license)
+ *
+ * The user metric field specifies what attribute on the instance of the guest is used for determining the number of licenses.
+ * For example, “smp” will count one license for each CPU/core in the virtual machine.
+ *
+ * @return PaginatedCollection of licenses available on the cloud
+ */
+ @Named("license:listLicenses")
+ @GET
+ @Path("/licenses/")
+ @ResponseParser(ParseLicenses.class)
+ PaginatedCollection<License> listLicenses(PaginationOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/PaginatedCollection.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/PaginatedCollection.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/PaginatedCollection.java
new file mode 100644
index 0000000..ec4f718
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/PaginatedCollection.java
@@ -0,0 +1,58 @@
+/*
+ * 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.cloudsigma2.domain;
+
+import com.google.common.base.Optional;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+
+import java.util.Iterator;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+public class PaginatedCollection<T> extends IterableWithMarker<T> {
+
+ private Iterable<T> objects;
+ private PaginationOptions paginationOptions;
+
+ public PaginatedCollection(Iterable<T> objects, PaginationOptions paginationOptions) {
+ this.objects = objects;
+ this.paginationOptions = paginationOptions;
+ }
+
+ @Override
+ public Optional<Object> nextMarker() {
+ if(paginationOptions.getLimit() == 0){
+ return Optional.absent();
+ }
+
+ if(paginationOptions.getTotalCount() - paginationOptions.getOffset() > paginationOptions.getLimit()){
+ return Optional.of((Object) new PaginationOptions.Builder()
+ .limit(paginationOptions.getLimit())
+ .offset(paginationOptions.getOffset() + paginationOptions.getLimit())
+ .build());
+ }
+
+ return Optional.absent();
+ }
+
+ @Override
+ public Iterator<T> iterator() {
+ return objects.iterator();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDiscounts.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDiscounts.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDiscounts.java
new file mode 100644
index 0000000..8085563
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDiscounts.java
@@ -0,0 +1,73 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.Discount;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseDiscounts extends ParseJson<ParseDiscounts.Discounts>{
+ static class Discounts extends PaginatedCollection<Discount> {
+
+ @ConstructorProperties({"objects", "meta"})
+ public Discounts(Iterable<Discount> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseDiscounts(Json json) {
+ super(json, TypeLiteral.get(Discounts.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<Discount, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Discount>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<Discount>>() {
+ @Override
+ public IterableWithMarker<Discount> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listDiscounts(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDriveInfos.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDriveInfos.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDriveInfos.java
new file mode 100644
index 0000000..791d78c
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDriveInfos.java
@@ -0,0 +1,74 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.DriveInfo;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseDriveInfos extends ParseJson<ParseDriveInfos.DriveInfos> {
+
+ static class DriveInfos extends PaginatedCollection<DriveInfo>{
+
+ @ConstructorProperties({"objects", "meta"})
+ public DriveInfos(Iterable<DriveInfo> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseDriveInfos(Json json) {
+ super(json, TypeLiteral.get(DriveInfos.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<DriveInfo, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<DriveInfo>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<DriveInfo>>() {
+ @Override
+ public IterableWithMarker<DriveInfo> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listDrivesInfo(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDrives.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDrives.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDrives.java
new file mode 100644
index 0000000..0338a84
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseDrives.java
@@ -0,0 +1,73 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.Drive;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseDrives extends ParseJson<ParseDrives.Drives> {
+ static class Drives extends PaginatedCollection<Drive>{
+
+ @ConstructorProperties({"objects", "meta"})
+ public Drives(Iterable<Drive> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseDrives(Json json) {
+ super(json, TypeLiteral.get(Drives.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<Drive, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Drive>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<Drive>>() {
+ @Override
+ public IterableWithMarker<Drive> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listDrives(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseFirewallPolicies.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseFirewallPolicies.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseFirewallPolicies.java
new file mode 100644
index 0000000..f4d50bd
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseFirewallPolicies.java
@@ -0,0 +1,94 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.FirewallPolicy;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseFirewallPolicies extends ParseJson<ParseFirewallPolicies.FirewallPolicies>{
+ static class FirewallPolicies extends PaginatedCollection<FirewallPolicy>{
+
+ @ConstructorProperties({"objects", "meta"})
+ FirewallPolicies(Iterable<FirewallPolicy> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseFirewallPolicies(Json json) {
+ super(json, TypeLiteral.get(FirewallPolicies.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<FirewallPolicy, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<FirewallPolicy>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<FirewallPolicy>>() {
+ @Override
+ public IterableWithMarker<FirewallPolicy> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listFirewallPolicies(paginationOptions);
+ }
+ };
+ }
+ }
+
+ public static class ToPagedIterableInfo extends ArgsToPagedIterable<FirewallPolicy, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterableInfo(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<FirewallPolicy>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<FirewallPolicy>>() {
+ @Override
+ public IterableWithMarker<FirewallPolicy> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listFirewallPoliciesInfo(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseIPInfos.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseIPInfos.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseIPInfos.java
new file mode 100644
index 0000000..29f23c2
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseIPInfos.java
@@ -0,0 +1,73 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.IPInfo;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseIPInfos extends ParseJson<ParseIPInfos.IPInfos>{
+ static class IPInfos extends PaginatedCollection<IPInfo> {
+
+ @ConstructorProperties({"objects", "meta"})
+ public IPInfos(Iterable<IPInfo> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseIPInfos(Json json) {
+ super(json, TypeLiteral.get(IPInfos.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<IPInfo, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<IPInfo>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<IPInfo>>() {
+ @Override
+ public IterableWithMarker<IPInfo> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listIPInfo(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseIPs.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseIPs.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseIPs.java
new file mode 100644
index 0000000..d8bf6b9
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseIPs.java
@@ -0,0 +1,73 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.IP;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseIPs extends ParseJson<ParseIPs.IPs> {
+ static class IPs extends PaginatedCollection<IP> {
+
+ @ConstructorProperties({"objects", "meta"})
+ public IPs(Iterable<IP> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseIPs(Json json) {
+ super(json, TypeLiteral.get(IPs.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<IP, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<IP>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<IP>>() {
+ @Override
+ public IterableWithMarker<IP> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listIPs(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseLibraryDrives.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseLibraryDrives.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseLibraryDrives.java
new file mode 100644
index 0000000..457e855
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseLibraryDrives.java
@@ -0,0 +1,73 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.LibraryDrive;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseLibraryDrives extends ParseJson<ParseLibraryDrives.LibraryDrives> {
+ static class LibraryDrives extends PaginatedCollection<LibraryDrive>{
+
+ @ConstructorProperties({"objects", "meta"})
+ public LibraryDrives(Iterable<LibraryDrive> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseLibraryDrives(Json json) {
+ super(json, TypeLiteral.get(LibraryDrives.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<LibraryDrive, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<LibraryDrive>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<LibraryDrive>>() {
+ @Override
+ public IterableWithMarker<LibraryDrive> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listLibraryDrives(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseLicenses.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseLicenses.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseLicenses.java
new file mode 100644
index 0000000..0b9b6c6
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseLicenses.java
@@ -0,0 +1,73 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.License;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseLicenses extends ParseJson<ParseLicenses.Licenses> {
+ static class Licenses extends PaginatedCollection<License> {
+
+ @ConstructorProperties({"objects", "meta"})
+ public Licenses(Iterable<License> objects, PaginationOptions meta) {
+ super(objects, meta);
+ }
+ }
+
+ @Inject
+ public ParseLicenses(Json json) {
+ super(json, TypeLiteral.get(Licenses.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<License, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<License>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<License>>() {
+ @Override
+ public IterableWithMarker<License> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listLicenses(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseServerInfos.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseServerInfos.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseServerInfos.java
new file mode 100644
index 0000000..7dca37c
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseServerInfos.java
@@ -0,0 +1,74 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.domain.ServerInfo;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseServerInfos extends ParseJson<ParseServerInfos.ServerInfos> {
+
+ static class ServerInfos extends PaginatedCollection<ServerInfo> {
+
+ @ConstructorProperties({"objects", "meta"})
+ public ServerInfos(Iterable<ServerInfo> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseServerInfos(Json json) {
+ super(json, TypeLiteral.get(ServerInfos.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<ServerInfo, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<ServerInfo>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<ServerInfo>>() {
+ @Override
+ public IterableWithMarker<ServerInfo> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listServersInfo(paginationOptions);
+ }
+ };
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseServers.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseServers.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseServers.java
new file mode 100644
index 0000000..4de20fa
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseServers.java
@@ -0,0 +1,74 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.domain.Server;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseServers extends ParseJson<ParseServers.Servers> {
+
+ static class Servers extends PaginatedCollection<Server>{
+
+ @ConstructorProperties({"objects", "meta"})
+ public Servers(Iterable<Server> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseServers(Json json) {
+ super(json, TypeLiteral.get(Servers.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<Server, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Server>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<Server>>() {
+ @Override
+ public IterableWithMarker<Server> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listServers(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseSubscriptions.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseSubscriptions.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseSubscriptions.java
new file mode 100644
index 0000000..c8d4895
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseSubscriptions.java
@@ -0,0 +1,95 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.domain.Subscription;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.Json;
+
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseSubscriptions extends ParseJson<ParseSubscriptions.Subscriptions>{
+ static class Subscriptions extends PaginatedCollection<Subscription> {
+
+ @ConstructorProperties({"objects", "meta"})
+ public Subscriptions(Iterable<Subscription> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseSubscriptions(Json json) {
+ super(json, TypeLiteral.get(Subscriptions.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<Subscription, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Subscription>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<Subscription>>() {
+ @Override
+ public IterableWithMarker<Subscription> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listSubscriptions(paginationOptions);
+ }
+ };
+ }
+ }
+
+ public static class ToPagedIterableCalculator extends ArgsToPagedIterable<Subscription, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterableCalculator(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Subscription>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<Subscription>>() {
+ @Override
+ public IterableWithMarker<Subscription> apply(@Nullable Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listSubscriptionsCalculator(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseTags.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseTags.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseTags.java
new file mode 100644
index 0000000..5757fa1
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseTags.java
@@ -0,0 +1,94 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.domain.Tag;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseTags extends ParseJson<ParseTags.Tags> {
+ static class Tags extends PaginatedCollection<Tag> {
+
+ @ConstructorProperties({"objects", "meta"})
+ public Tags(Iterable<Tag> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseTags(Json json) {
+ super(json, TypeLiteral.get(Tags.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<Tag, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Tag>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<Tag>>() {
+ @Override
+ public IterableWithMarker<Tag> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listTags(paginationOptions);
+ }
+ };
+ }
+ }
+
+ public static class ToPagedIterableInfo extends ArgsToPagedIterable<Tag, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterableInfo(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Tag>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<Tag>>() {
+ @Override
+ public IterableWithMarker<Tag> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listTagsInfo(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseTransactions.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseTransactions.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseTransactions.java
new file mode 100644
index 0000000..4d51701
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseTransactions.java
@@ -0,0 +1,73 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.domain.Transaction;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseTransactions extends ParseJson<ParseTransactions.Transactions> {
+ static class Transactions extends PaginatedCollection<Transaction> {
+
+ @ConstructorProperties({"objects", "meta"})
+ public Transactions(Iterable<Transaction> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseTransactions(Json json) {
+ super(json, TypeLiteral.get(Transactions.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<Transaction, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Transaction>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<Transaction>>() {
+ @Override
+ public IterableWithMarker<Transaction> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listTransactions(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseVLANs.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseVLANs.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseVLANs.java
new file mode 100644
index 0000000..c04d22c
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseVLANs.java
@@ -0,0 +1,94 @@
+/*
+ * 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.cloudsigma2.functions.internal;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.cloudsigma2.CloudSigma2Api;
+import org.jclouds.cloudsigma2.domain.PaginatedCollection;
+import org.jclouds.cloudsigma2.domain.VLANInfo;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.ArgsToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+@Singleton
+public class ParseVLANs extends ParseJson<ParseVLANs.VLANs> {
+ static class VLANs extends PaginatedCollection<VLANInfo> {
+
+ @ConstructorProperties({"objects", "meta"})
+ public VLANs(Iterable<VLANInfo> objects, PaginationOptions paginationOptions) {
+ super(objects, paginationOptions);
+ }
+ }
+
+ @Inject
+ public ParseVLANs(Json json) {
+ super(json, TypeLiteral.get(VLANs.class));
+ }
+
+ public static class ToPagedIterable extends ArgsToPagedIterable<VLANInfo, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterable(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<VLANInfo>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<VLANInfo>>() {
+ @Override
+ public IterableWithMarker<VLANInfo> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listVLANs(paginationOptions);
+ }
+ };
+ }
+ }
+
+ public static class ToPagedIterableInfo extends ArgsToPagedIterable<VLANInfo, ToPagedIterable> {
+
+ private CloudSigma2Api api;
+
+ @Inject
+ public ToPagedIterableInfo(CloudSigma2Api api) {
+ this.api = api;
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<VLANInfo>> markerToNextForArgs(List<Object> args) {
+ return new Function<Object, IterableWithMarker<VLANInfo>>() {
+ @Override
+ public IterableWithMarker<VLANInfo> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return api.listVLANInfo(paginationOptions);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/0bebb584/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/options/PaginationOptions.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/options/PaginationOptions.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/options/PaginationOptions.java
new file mode 100644
index 0000000..13e4463
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/options/PaginationOptions.java
@@ -0,0 +1,117 @@
+/*
+ * 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.cloudsigma2.options;
+
+import org.jclouds.http.options.BaseHttpRequestOptions;
+
+import javax.inject.Named;
+import java.beans.ConstructorProperties;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+public class PaginationOptions extends BaseHttpRequestOptions {
+
+ public static class Builder{
+ private int limit = PaginationOptions.DEFAULT_LIMIT;
+ private int offset = 0;
+
+ public Builder limit(int limit){
+ this.limit = limit;
+ return this;
+ }
+
+ public Builder offset(int offset){
+ this.offset = offset;
+ return this;
+ }
+
+ public PaginationOptions build() {
+ if (limit < 0) {
+ limit = PaginationOptions.DEFAULT_LIMIT;
+ }
+
+ if (offset < 0) {
+ offset = 0;
+ }
+
+ PaginationOptions paginationOptions = new PaginationOptions(limit, offset, 0);
+ paginationOptions.queryParameters.put("limit", String.valueOf(limit));
+ paginationOptions.queryParameters.put("offset", String.valueOf(offset));
+ return paginationOptions;
+ }
+ }
+
+ public static final int DEFAULT_LIMIT = 20;
+
+ private final int limit;
+ private final int offset;
+ @Named("total_count")
+ private final int totalCount;
+
+ @ConstructorProperties({"limit", "offset", "total_count"})
+ public PaginationOptions(int limit, int offset, int totalCount) {
+ this.limit = limit;
+ this.offset = offset;
+ this.totalCount = totalCount;
+ }
+
+ public int getTotalCount() {
+ return totalCount;
+ }
+
+ public int getOffset() {
+ return offset;
+ }
+
+ public int getLimit() {
+ return limit;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof PaginationOptions)) return false;
+ if (!super.equals(o)) return false;
+
+ PaginationOptions that = (PaginationOptions) o;
+
+ if (limit != that.limit) return false;
+ if (offset != that.offset) return false;
+ if (totalCount != that.totalCount) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = super.hashCode();
+ result = 31 * result + limit;
+ result = 31 * result + offset;
+ result = 31 * result + totalCount;
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "PaginationOptions{" +
+ "limit=" + limit +
+ ", offset=" + offset +
+ ", totalCount=" + totalCount +
+ "} " + super.toString();
+ }
+}