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/12/09 23:24:25 UTC
[1/3] JCLOUDS-390. Update calculation of subscriptions according
recent changes in the cloudsigma2 provder API.
Updated Branches:
refs/heads/master 3d095e975 -> 237dcbed0
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/CloudSigma2ApiLiveTest.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/CloudSigma2ApiLiveTest.java b/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/CloudSigma2ApiLiveTest.java
index 92a077e..88475f3 100644
--- a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/CloudSigma2ApiLiveTest.java
+++ b/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/CloudSigma2ApiLiveTest.java
@@ -15,20 +15,12 @@
* limitations under the License.
*/
package org.jclouds.cloudsigma2;
-import static com.google.common.base.Predicates.in;
-import static com.google.common.collect.Iterables.any;
-import static com.google.common.collect.Iterables.transform;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-
-import java.math.BigInteger;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.google.common.base.Function;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.cloudsigma2.domain.CalcSubscription;
import org.jclouds.cloudsigma2.domain.DeviceEmulationType;
import org.jclouds.cloudsigma2.domain.Discount;
import org.jclouds.cloudsigma2.domain.Drive;
@@ -49,15 +41,28 @@ import org.jclouds.cloudsigma2.domain.Server;
import org.jclouds.cloudsigma2.domain.ServerDrive;
import org.jclouds.cloudsigma2.domain.ServerInfo;
import org.jclouds.cloudsigma2.domain.Subscription;
+import org.jclouds.cloudsigma2.domain.SubscriptionCalculator;
+import org.jclouds.cloudsigma2.domain.SubscriptionResource;
import org.jclouds.cloudsigma2.domain.Tag;
import org.jclouds.cloudsigma2.domain.TagResource;
import org.jclouds.cloudsigma2.domain.Transaction;
import org.jclouds.cloudsigma2.domain.VLANInfo;
+import org.jclouds.cloudsigma2.options.PaginationOptions;
import org.testng.annotations.Test;
-import com.google.common.base.Function;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableList;
+import java.math.BigInteger;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.google.common.base.Predicates.in;
+import static com.google.common.collect.Iterables.any;
+import static com.google.common.collect.Iterables.transform;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
/**
* @author Vladimir Shevchenko
@@ -107,16 +112,17 @@ public class CloudSigma2ApiLiveTest extends BaseApiLiveTest<CloudSigma2Api> {
@Test
public void testCreateDrives() throws Exception {
- List<DriveInfo> newDrives = ImmutableList.of(new DriveInfo.Builder()
- .name("New Drive")
- .size(new BigInteger("2073741824"))
- .media(MediaType.DISK)
- .build()
- , new DriveInfo.Builder()
- .name("Test Drive")
- .size(new BigInteger("6073741824"))
- .media(MediaType.DISK)
- .build());
+ List<DriveInfo> newDrives = ImmutableList.of(
+ new DriveInfo.Builder()
+ .name("New Drive")
+ .size(new BigInteger("2073741824"))
+ .media(MediaType.DISK)
+ .build(),
+ new DriveInfo.Builder()
+ .name("Test Drive")
+ .size(new BigInteger("6073741824"))
+ .media(MediaType.DISK)
+ .build());
createdDrives = api.createDrives(newDrives);
assertEquals(newDrives.size(), createdDrives.size());
@@ -202,13 +208,13 @@ public class CloudSigma2ApiLiveTest extends BaseApiLiveTest<CloudSigma2Api> {
.memory(new BigInteger("5368709120"))
.cpu(3000)
.vncPassword("new_password")
- .build()
- , new ServerInfo.Builder()
- .name("Test Server")
- .memory(new BigInteger("5368709120"))
- .cpu(3000)
- .vncPassword("test_password")
- .build());
+ .build(),
+ new ServerInfo.Builder()
+ .name("Test Server")
+ .memory(new BigInteger("5368709120"))
+ .cpu(3000)
+ .vncPassword("test_password")
+ .build());
createdServers = api.createServers(newServerList);
assertEquals(newServerList.size(), createdServers.size());
@@ -279,42 +285,40 @@ public class CloudSigma2ApiLiveTest extends BaseApiLiveTest<CloudSigma2Api> {
.comment("Drop traffic from the VM to IP address 23.0.0.0/32")
.direction(FirewallDirection.OUT)
.destinationIp("23.0.0.0/32")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.ACCEPT)
- .comment("Allow SSH traffic to the VM from our office in Dubai")
- .direction(FirewallDirection.IN)
- .destinationPort("22")
- .ipProtocol(FirewallIpProtocol.TCP)
- .sourceIp("172.66.32.0/24")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop all other SSH traffic to the VM")
- .direction(FirewallDirection.IN)
- .destinationPort("22")
- .ipProtocol(FirewallIpProtocol.TCP)
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop all UDP traffic to the VM, not originating from 172.66.32.55")
- .direction(FirewallDirection.IN)
- .ipProtocol(FirewallIpProtocol.UDP)
- .sourceIp("!172.66.32.55/32")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop any traffic, to the VM with destination port not between 1-1024")
- .direction(FirewallDirection.IN)
- .destinationPort("!1:1024")
- .ipProtocol(FirewallIpProtocol.TCP)
- .build()
- ))
- .build()
- , new FirewallPolicy.Builder()
- .name("New policy")
- .rules(ImmutableList.of(
- new FirewallRule.Builder()
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.ACCEPT)
+ .comment("Allow SSH traffic to the VM from our office in Dubai")
+ .direction(FirewallDirection.IN)
+ .destinationPort("22")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .sourceIp("172.66.32.0/24")
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop all other SSH traffic to the VM")
+ .direction(FirewallDirection.IN)
+ .destinationPort("22")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop all UDP traffic to the VM, not originating from 172.66.32.55")
+ .direction(FirewallDirection.IN)
+ .ipProtocol(FirewallIpProtocol.UDP)
+ .sourceIp("!172.66.32.55/32")
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop any traffic, to the VM with destination port not between 1-1024")
+ .direction(FirewallDirection.IN)
+ .destinationPort("!1:1024")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .build()))
+ .build(),
+ new FirewallPolicy.Builder()
+ .name("New policy")
+ .rules(ImmutableList.of(new FirewallRule.Builder()
.action(FirewallAction.ACCEPT)
.comment("Test comment")
.direction(FirewallDirection.IN)
@@ -323,9 +327,8 @@ public class CloudSigma2ApiLiveTest extends BaseApiLiveTest<CloudSigma2Api> {
.ipProtocol(FirewallIpProtocol.TCP)
.sourceIp("255.255.255.12/32")
.sourcePort("321")
- .build()
- ))
- .build());
+ .build()))
+ .build());
List<FirewallPolicy> createdFirewallPolicies = api.createFirewallPolicies(newFirewallPolicies);
assertEquals(newFirewallPolicies.size(), createdFirewallPolicies.size());
@@ -345,37 +348,36 @@ public class CloudSigma2ApiLiveTest extends BaseApiLiveTest<CloudSigma2Api> {
.comment("Drop traffic from the VM to IP address 23.0.0.0/32")
.direction(FirewallDirection.OUT)
.destinationIp("23.0.0.0/32")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.ACCEPT)
- .comment("Allow SSH traffic to the VM from our office in Dubai")
- .direction(FirewallDirection.IN)
- .destinationPort("22")
- .ipProtocol(FirewallIpProtocol.TCP)
- .sourceIp("172.66.32.0/24")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop all other SSH traffic to the VM")
- .direction(FirewallDirection.IN)
- .destinationPort("22")
- .ipProtocol(FirewallIpProtocol.TCP)
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop all UDP traffic to the VM, not originating from 172.66.32.55")
- .direction(FirewallDirection.IN)
- .ipProtocol(FirewallIpProtocol.UDP)
- .sourceIp("!172.66.32.55/32")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop any traffic, to the VM with destination port not between 1-1024")
- .direction(FirewallDirection.IN)
- .destinationPort("!1:1024")
- .ipProtocol(FirewallIpProtocol.TCP)
- .build()
- ))
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.ACCEPT)
+ .comment("Allow SSH traffic to the VM from our office in Dubai")
+ .direction(FirewallDirection.IN)
+ .destinationPort("22")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .sourceIp("172.66.32.0/24")
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop all other SSH traffic to the VM")
+ .direction(FirewallDirection.IN)
+ .destinationPort("22")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop all UDP traffic to the VM, not originating from 172.66.32.55")
+ .direction(FirewallDirection.IN)
+ .ipProtocol(FirewallIpProtocol.UDP)
+ .sourceIp("!172.66.32.55/32")
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop any traffic, to the VM with destination port not between 1-1024")
+ .direction(FirewallDirection.IN)
+ .destinationPort("!1:1024")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .build()))
.build();
createdFirewallPolicy = api.createFirewallPolicy(newFirewallPolicy);
@@ -396,8 +398,7 @@ public class CloudSigma2ApiLiveTest extends BaseApiLiveTest<CloudSigma2Api> {
.ipProtocol(FirewallIpProtocol.TCP)
.sourceIp("255.255.255.12/32")
.sourcePort("321")
- .build()
- ))
+ .build()))
.build();
checkFirewallPolicy(editedPolicy, api.editFirewallPolicy(createdFirewallPolicy.getUuid(), editedPolicy));
@@ -487,8 +488,16 @@ public class CloudSigma2ApiLiveTest extends BaseApiLiveTest<CloudSigma2Api> {
Map<String, String> meta = new HashMap<String, String>();
meta.put("description", "Test tag");
- Tag newTag = new Tag.Builder().meta(meta).name("Cloudsigma2 Test tag").meta(new HashMap<String, String>())
- .resources(ImmutableList.of(new TagResource.Builder().uuid(createdDrive.getUuid()).build())).build();
+ Tag newTag = new Tag.Builder()
+ .meta(meta)
+ .name("Cloudsigma2 Test tag")
+ .meta(new HashMap<String, String>())
+ .resources(ImmutableList.of(
+ new TagResource.Builder()
+ .uuid(createdDrive.getUuid())
+ .build()))
+ .build();
+
createdTag = api.createTag(newTag);
checkTag(newTag, createdTag);
}
@@ -587,9 +596,29 @@ public class CloudSigma2ApiLiveTest extends BaseApiLiveTest<CloudSigma2Api> {
}
@Test
- public void testListSubscriptionsCalculator() throws Exception {
- for (Subscription subscription : api.listSubscriptionsCalculator().concat()) {
- assertNotNull(subscription);
+ public void testCalculateSubscriptions() throws Exception {
+ long monthInMilliseconds = (long) 30 * 24 * 3600 * 1000;
+ Date startTime = new Date();
+ Date endTime = new Date(startTime.getTime() + monthInMilliseconds);
+
+ List<CalcSubscription> subscriptionsToCalculate = ImmutableList.of(
+ new CalcSubscription.Builder()
+ .startTime(startTime)
+ .resource(SubscriptionResource.IP)
+ .endTime(endTime)
+ .build(),
+ new CalcSubscription.Builder()
+ .startTime(startTime)
+ .endTime(endTime)
+ .resource(SubscriptionResource.VLAN)
+ .discountAmount(10.5d)
+ .build()
+ );
+ SubscriptionCalculator subscriptionCalculator = api.calculateSubscriptions(subscriptionsToCalculate);
+ List<CalcSubscription> calculatedSubscriptions = subscriptionCalculator.getSubscriptions();
+ assertEquals(calculatedSubscriptions.size(), subscriptionsToCalculate.size());
+ for (int i = 0; i < calculatedSubscriptions.size(); i++) {
+ assertEquals(calculatedSubscriptions.get(i).getResource(), subscriptionsToCalculate.get(i).getResource());
}
}
@@ -607,7 +636,7 @@ public class CloudSigma2ApiLiveTest extends BaseApiLiveTest<CloudSigma2Api> {
@Test
public void testListTransactions() throws Exception {
- for (Transaction transaction : api.listTransactions().concat()) {
+ for (Transaction transaction : api.listTransactions(new PaginationOptions.Builder().build())) {
assertNotNull(transaction);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/test/resources/subscriptioncalculator-request.json
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/test/resources/subscriptioncalculator-request.json b/cloudsigma2/src/test/resources/subscriptioncalculator-request.json
new file mode 100644
index 0000000..3f1d214
--- /dev/null
+++ b/cloudsigma2/src/test/resources/subscriptioncalculator-request.json
@@ -0,0 +1 @@
+[{"amount":1.0,"price":5.5,"resource":"ip","start_time":"2013-11-27T10:16:01.440Z","end_time":"2013-12-27T12:00:00.000Z"},{"amount":1.0,"price":11.0,"resource":"vlan","start_time":"2013-11-27T10:16:01.440Z","end_time":"2013-12-27T12:00:00.000Z"},{"amount":250.0,"price":3.366,"resource":"cpu","start_time":"2013-11-27T10:16:01.440Z","end_time":"2013-12-27T12:00:00.000Z"}]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/test/resources/subscriptioncalculator.json
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/test/resources/subscriptioncalculator.json b/cloudsigma2/src/test/resources/subscriptioncalculator.json
new file mode 100644
index 0000000..3804fcb
--- /dev/null
+++ b/cloudsigma2/src/test/resources/subscriptioncalculator.json
@@ -0,0 +1,35 @@
+{
+ "objects": [
+ {
+ "amount": "1",
+ "discount_amount": "0",
+ "discount_percent": "0",
+ "end_time": "2013-12-27T12:00:00+00:00",
+ "period": "30 days, 1:43:58.559688",
+ "price": "5.50000000000000000000",
+ "resource": "ip",
+ "start_time": "2013-11-27T10:16:01.440312+00:00"
+ },
+ {
+ "amount": "1",
+ "discount_amount": "0",
+ "discount_percent": "0",
+ "end_time": "2013-12-27T12:00:00+00:00",
+ "period": "30 days, 1:43:58.528053",
+ "price": "11.00000000000000000000",
+ "resource": "vlan",
+ "start_time": "2013-11-27T10:16:01.440312+00:00"
+ },
+ {
+ "amount": "250",
+ "discount_amount": "0",
+ "discount_percent": "0",
+ "end_time": "2013-12-27T12:00:00+00:00",
+ "period": "30 days, 1:43:58.510201",
+ "price": "3.36600000000000000000",
+ "resource": "cpu",
+ "start_time": "2013-11-27T10:16:01.440312+00:00"
+ }
+ ],
+ "price": "19.86600000000000000000"
+}
\ No newline at end of file
[3/3] git commit: JCLOUDS-390. Update calculation of subscriptions
according recent changes in the cloudsigma2 provder API.
Posted by na...@apache.org.
JCLOUDS-390. Update calculation of subscriptions according recent changes in the cloudsigma2 provder API.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/237dcbed
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/237dcbed
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/237dcbed
Branch: refs/heads/master
Commit: 237dcbed094cf837190c35229d285c2f38469cb7
Parents: 3d095e9
Author: Vladimir Shevchenko <sh...@gmail.com>
Authored: Wed Nov 27 17:06:45 2013 +0700
Committer: Ignasi Barrera <na...@apache.org>
Committed: Mon Dec 9 23:16:16 2013 +0100
----------------------------------------------------------------------
.../org/jclouds/cloudsigma2/CloudSigma2Api.java | 44 +-
.../binders/BindCreateSubscriptionRequest.java | 4 +-
.../BindCreateSubscriptionRequestList.java | 4 +-
.../cloudsigma2/domain/AccountUsage.java | 9 +-
.../jclouds/cloudsigma2/domain/BurstLevel.java | 7 +-
.../cloudsigma2/domain/CalcSubscription.java | 259 ++++
.../org/jclouds/cloudsigma2/domain/Drive.java | 4 +-
.../jclouds/cloudsigma2/domain/DriveInfo.java | 4 +-
.../cloudsigma2/domain/FirewallPolicy.java | 4 +-
.../cloudsigma2/domain/FirewallRule.java | 8 +-
.../org/jclouds/cloudsigma2/domain/IPInfo.java | 4 +-
.../cloudsigma2/domain/LibraryDrive.java | 18 +-
.../org/jclouds/cloudsigma2/domain/NIC.java | 4 +-
.../org/jclouds/cloudsigma2/domain/Price.java | 4 +-
.../jclouds/cloudsigma2/domain/ProfileInfo.java | 30 +-
.../org/jclouds/cloudsigma2/domain/Server.java | 4 +-
.../jclouds/cloudsigma2/domain/ServerInfo.java | 12 +-
.../cloudsigma2/domain/Subscription.java | 55 +-
.../domain/SubscriptionCalculator.java | 83 ++
.../org/jclouds/cloudsigma2/domain/Tag.java | 4 +-
.../jclouds/cloudsigma2/domain/Transaction.java | 4 +-
.../jclouds/cloudsigma2/domain/VLANInfo.java | 4 +-
.../functions/internal/ParseSubscriptions.java | 22 -
.../cloudsigma2/CloudSigma2ApiExpectTest.java | 1372 +++++++++---------
.../cloudsigma2/CloudSigma2ApiLiveTest.java | 249 ++--
.../subscriptioncalculator-request.json | 1 +
.../test/resources/subscriptioncalculator.json | 35 +
27 files changed, 1325 insertions(+), 927 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/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 e34945f..424e031 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/CloudSigma2Api.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/CloudSigma2Api.java
@@ -35,6 +35,7 @@ import org.jclouds.cloudsigma2.binders.BindTagToJsonRequest;
import org.jclouds.cloudsigma2.binders.BindUuidStringsToJsonArray;
import org.jclouds.cloudsigma2.binders.BindVLANToJsonRequest;
import org.jclouds.cloudsigma2.domain.AccountBalance;
+import org.jclouds.cloudsigma2.domain.CalcSubscription;
import org.jclouds.cloudsigma2.domain.CreateSubscriptionRequest;
import org.jclouds.cloudsigma2.domain.CurrentUsage;
import org.jclouds.cloudsigma2.domain.Discount;
@@ -53,6 +54,7 @@ import org.jclouds.cloudsigma2.domain.Server;
import org.jclouds.cloudsigma2.domain.ServerAvailabilityGroup;
import org.jclouds.cloudsigma2.domain.ServerInfo;
import org.jclouds.cloudsigma2.domain.Subscription;
+import org.jclouds.cloudsigma2.domain.SubscriptionCalculator;
import org.jclouds.cloudsigma2.domain.Tag;
import org.jclouds.cloudsigma2.domain.Transaction;
import org.jclouds.cloudsigma2.domain.VLANInfo;
@@ -82,6 +84,7 @@ 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 org.jclouds.rest.binders.BindToJsonPayload;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -140,8 +143,8 @@ public interface CloudSigma2Api extends Closeable {
@GET
@Path("/drives/")
@SelectJson("objects")
- List<DriveInfo> listDrives(@QueryParam("fields") DrivesListRequestFieldsGroup fields
- , @DefaultValue("0") @QueryParam("limit") int limit);
+ List<DriveInfo> listDrives(@QueryParam("fields") DrivesListRequestFieldsGroup fields,
+ @DefaultValue("0") @QueryParam("limit") int limit);
/**
* Gets the detailed list of drives with additional information to which the authenticated user has access.
@@ -238,8 +241,7 @@ public interface CloudSigma2Api extends Closeable {
@PUT
@Path("/drives/{uuid}/")
@Fallback(Fallbacks.VoidOnNotFoundOr404.class)
- DriveInfo editDrive(@PathParam("uuid") String sourceUuid
- , @BinderParam(BindDriveToJson.class) DriveInfo driveInfo);
+ DriveInfo editDrive(@PathParam("uuid") String sourceUuid, @BinderParam(BindDriveToJson.class) DriveInfo driveInfo);
/**
@@ -253,8 +255,8 @@ public interface CloudSigma2Api extends Closeable {
@POST
@Path("/drives/{uuid}/action/?do=clone")
@Fallback(Fallbacks.VoidOnNotFoundOr404.class)
- DriveInfo cloneDrive(@PathParam("uuid") String sourceUuid
- , @Nullable @BinderParam(BindDriveToJson.class) DriveInfo driveInfo);
+ DriveInfo cloneDrive(@PathParam("uuid") String sourceUuid,
+ @Nullable @BinderParam(BindDriveToJson.class) DriveInfo driveInfo);
/**
* Gets the list of library drives to which the authenticated user has access.
@@ -481,8 +483,8 @@ public interface CloudSigma2Api extends Closeable {
@POST
@Path("/servers/{uuid}/action/?do=start")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
- void startServerInSeparateAvailabilityGroup(@PathParam("uuid") String uuid
- , @QueryParam("avoid") List<String> uuidGroup);
+ void startServerInSeparateAvailabilityGroup(@PathParam("uuid") String uuid,
+ @QueryParam("avoid") List<String> uuidGroup);
/**
* Opens a VNC tunnel to a server with specific UUID.
@@ -753,8 +755,8 @@ public interface CloudSigma2Api extends Closeable {
@PUT
@Path("/ips/{uuid}/")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
- IPInfo editIP(@PathParam("uuid") String uuid
- , @BinderParam(BindIPInfoToJsonRequest.class) IPInfo ipInfo);
+ IPInfo editIP(@PathParam("uuid") String uuid,
+ @BinderParam(BindIPInfoToJsonRequest.class) IPInfo ipInfo);
/**
* Gets the list of tags to which the authenticated user has access.
@@ -944,25 +946,13 @@ public interface CloudSigma2Api extends Closeable {
/**
* This is identical to the listSubscriptions(), except that subscriptions are not actually bought.
*
- * @return list of subscriptions that are not actually bought.
+ * @return SubscriptionCalculator with subscriptions that are not actually bought.
*/
- @Named("subscription:listSubscriptionsCalculator")
- @GET
- @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
+ @Named("subscription:calculateSubscriptions")
+ @POST
@Path("/subscriptioncalculator/")
- @ResponseParser(ParseSubscriptions.class)
- PaginatedCollection<Subscription> listSubscriptionsCalculator(PaginationOptions options);
+ SubscriptionCalculator calculateSubscriptions(@BinderParam(BindToJsonPayload.class)
+ Iterable<CalcSubscription> subscriptions);
/**
* Creates a new subscription.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/binders/BindCreateSubscriptionRequest.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/binders/BindCreateSubscriptionRequest.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/binders/BindCreateSubscriptionRequest.java
index 5a857f0..d95546d 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/binders/BindCreateSubscriptionRequest.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/binders/BindCreateSubscriptionRequest.java
@@ -43,8 +43,8 @@ public class BindCreateSubscriptionRequest implements Binder {
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
- checkArgument(input instanceof CreateSubscriptionRequest
- , "this binder is only valid for CreateSubscriptionRequest!");
+ checkArgument(input instanceof CreateSubscriptionRequest,
+ "this binder is only valid for CreateSubscriptionRequest!");
CreateSubscriptionRequest create = CreateSubscriptionRequest.class.cast(input);
JsonObject subscriptionObject = subscriptionRequestJsonObjectFunction.apply(create);
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/binders/BindCreateSubscriptionRequestList.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/binders/BindCreateSubscriptionRequestList.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/binders/BindCreateSubscriptionRequestList.java
index 706bf9c..89bc79c 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/binders/BindCreateSubscriptionRequestList.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/binders/BindCreateSubscriptionRequestList.java
@@ -48,8 +48,8 @@ public class BindCreateSubscriptionRequestList implements Binder {
checkArgument(input instanceof List, "this binder is only valid for List<CreateSubscriptionRequest>!");
List list = List.class.cast(input);
for (Object o : list) {
- checkArgument(o instanceof CreateSubscriptionRequest
- , "this binder is only valid for List<CreateSubscriptionRequest>!");
+ checkArgument(o instanceof CreateSubscriptionRequest,
+ "this binder is only valid for List<CreateSubscriptionRequest>!");
}
List<CreateSubscriptionRequest> createSubscriptionRequests = (List<CreateSubscriptionRequest>) input;
JsonArray subscriptionsJsonArray = new JsonArray();
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/AccountUsage.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/AccountUsage.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/AccountUsage.java
index 08b1182..b7e641d 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/AccountUsage.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/AccountUsage.java
@@ -94,8 +94,8 @@ public class AccountUsage {
}
public AccountUsage build() {
- return new AccountUsage(cpu, dssd, ip, mem, windowsWebServer2008, windowsServer2008Standard
- , sqlServerStandard2008, sms, ssd, tx, vlan);
+ return new AccountUsage(cpu, dssd, ip, mem, windowsWebServer2008, windowsServer2008Standard,
+ sqlServerStandard2008, sms, ssd, tx, vlan);
}
}
@@ -117,8 +117,9 @@ public class AccountUsage {
@ConstructorProperties({
"cpu", "dssd", "ip", "mem", "msft_lwa_00135", "msft_p37_04837", "msft_tfa_00009", "sms", "ssd", "tx", "vlan"
})
- public AccountUsage(Usage cpu, Usage dssd, Usage ip, Usage mem, Usage windowsWebServer2008
- , Usage windowsServer2008Standard, Usage sqlServerStandard2008, Usage sms, Usage ssd, Usage tx, Usage vlan) {
+ public AccountUsage(Usage cpu, Usage dssd, Usage ip, Usage mem, Usage windowsWebServer2008,
+ Usage windowsServer2008Standard, Usage sqlServerStandard2008, Usage sms, Usage ssd, Usage tx,
+ Usage vlan) {
this.cpu = cpu;
this.dssd = dssd;
this.ip = ip;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/BurstLevel.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/BurstLevel.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/BurstLevel.java
index 03f8703..3c116b1 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/BurstLevel.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/BurstLevel.java
@@ -94,7 +94,8 @@ public class BurstLevel {
}
public BurstLevel build() {
- return new BurstLevel(cpu, dssd, ip, mem, windowsWebServer2008, windowsServer2008Standard, sqlServerStandard2008, sms, ssd, tx, vlan);
+ return new BurstLevel(cpu, dssd, ip, mem, windowsWebServer2008, windowsServer2008Standard,
+ sqlServerStandard2008, sms, ssd, tx, vlan);
}
}
@@ -116,8 +117,8 @@ public class BurstLevel {
@ConstructorProperties({
"cpu", "dssd", "ip", "mem", "msft_lwa_00135", "msft_p37_04837", "msft_tfa_00009", "sms", "ssd", "tx", "vlan"
})
- public BurstLevel(int cpu, int dssd, int ip, int mem, int windowsWebServer2008
- , int windowsServer2008Standard, int sqlServerStandard2008, int sms, int ssd, int tx, int vlan) {
+ public BurstLevel(int cpu, int dssd, int ip, int mem, int windowsWebServer2008, int windowsServer2008Standard,
+ int sqlServerStandard2008, int sms, int ssd, int tx, int vlan) {
this.cpu = cpu;
this.dssd = dssd;
this.ip = ip;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/CalcSubscription.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/CalcSubscription.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/CalcSubscription.java
new file mode 100644
index 0000000..4cbf9f0
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/CalcSubscription.java
@@ -0,0 +1,259 @@
+/*
+ * 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 org.jclouds.javax.annotation.Nullable;
+
+import javax.inject.Named;
+import java.beans.ConstructorProperties;
+import java.util.Date;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+public class CalcSubscription {
+
+ public static class Builder {
+ private Double amount;
+ private Double discountAmount;
+ private Double discountPercent;
+ private String period;
+ private Double price;
+ private SubscriptionResource resource;
+ private Date startTime;
+ private Date endTime;
+
+ /**
+ * @param amount
+ * @return CalcSubscription Builder
+ */
+ public Builder amount(double amount) {
+ this.amount = amount;
+ return this;
+ }
+
+ /**
+ * @param discountAmount Amount of discount
+ * @return CalcSubscription Builder
+ */
+ public Builder discountAmount(double discountAmount) {
+ this.discountAmount = discountAmount;
+ return this;
+ }
+
+ /**
+ * @param discountPercent Percent of discount
+ * @return CalcSubscription Builder
+ */
+ public Builder discountPercent(double discountPercent) {
+ this.discountPercent = discountPercent;
+ return this;
+ }
+
+ /**
+ * @param period Duration of the subscription
+ * @return CalcSubscription Builder
+ */
+ public Builder period(String period) {
+ this.period = period;
+ return this;
+ }
+
+ /**
+ * @param price Subscription price
+ * @return CalcSubscription Builder
+ */
+ public Builder price(double price) {
+ this.price = price;
+ return this;
+ }
+
+ /**
+ * @param resource Name of resource associated with the subscription
+ * @return CalcSubscription Builder
+ */
+ public Builder resource(SubscriptionResource resource) {
+ this.resource = resource;
+ return this;
+ }
+
+ /**
+ * @param startTime Start time of subscription
+ * @return CalcSubscription Builder
+ */
+ public Builder startTime(Date startTime) {
+ this.startTime = startTime;
+ return this;
+ }
+
+ /**
+ * @param endTime End time of subscription
+ * @return CalcSubscription Builder
+ */
+ public Builder endTime(Date endTime) {
+ this.endTime = endTime;
+ return this;
+ }
+
+ public CalcSubscription build() {
+ return new CalcSubscription(amount, discountAmount, discountPercent, period, price, resource,
+ startTime, endTime);
+ }
+ }
+
+ private final Double amount;
+ @Named("discount_amount")
+ private final Double discountAmount;
+ @Named("discount_percent")
+ private final Double discountPercent;
+ private final String period;
+ private final Double price;
+ private final SubscriptionResource resource;
+ @Named("start_time")
+ private final Date startTime;
+ @Named("end_time")
+ private final Date endTime;
+
+ @ConstructorProperties({
+ "amount", "discount_amount", "discount_percent", "period", "price", "resource", "start_time", "end_time"
+ })
+ public CalcSubscription(@Nullable Double amount, @Nullable Double discountAmount, @Nullable Double discountPercent,
+ @Nullable String period, @Nullable Double price, SubscriptionResource resource,
+ @Nullable Date startTime, @Nullable Date endTime) {
+ checkArgument(!(endTime == null && period == null),
+ "Subscription period should be configured with endTime or period");
+ this.amount = amount;
+ this.discountAmount = discountAmount;
+ this.discountPercent = discountPercent;
+ this.period = period;
+ this.price = price;
+ this.resource = checkNotNull(resource, "resource");
+ this.startTime = startTime;
+ this.endTime = endTime;
+ }
+
+ /**
+ * @return Subscription amount
+ */
+ public double getAmount() {
+ return amount;
+ }
+ /**
+ * @return Amount of discount
+ */
+ public double getDiscountAmount() {
+ return discountAmount;
+ }
+
+ /**
+ * @return Percent of discount
+ */
+ public double getDiscountPercent() {
+ return discountPercent;
+ }
+
+ /**
+ * @return Duration of the subscription
+ */
+ public String getPeriod() {
+ return period;
+ }
+
+ /**
+ * @return Subscription price
+ */
+ public double getPrice() {
+ return price;
+ }
+ /**
+ * @return Name of resource associated with the subscription
+ */
+ public SubscriptionResource getResource() {
+ return resource;
+ }
+
+ /**
+ * @return Start time of subscription
+ */
+ public Date getStartTime() {
+ return startTime;
+ }
+
+ /**
+ * @return End time of subscription
+ */
+ public Date getEndTime() {
+ return endTime;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof CalcSubscription)) return false;
+
+ CalcSubscription that = (CalcSubscription) o;
+
+ if (amount != null ? !amount.equals(that.amount) : that.amount != null) return false;
+ if (discountAmount != null ? !discountAmount.equals(that.discountAmount) : that.discountAmount != null)
+ return false;
+ if (discountPercent != null ? !discountPercent.equals(that.discountPercent) : that.discountPercent != null)
+ return false;
+ if (price != null ? !price.equals(that.price) : that.price != null) return false;
+ if (endTime != null ? !endTime.equals(that.endTime) : that.endTime != null) return false;
+ if (period != null ? !period.equals(that.period) : that.period != null) return false;
+ if (resource != that.resource) return false;
+ if (startTime != null ? !startTime.equals(that.startTime) : that.startTime != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result;
+ long temp;
+ temp = Double.doubleToLongBits(amount);
+ result = (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(discountAmount);
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(discountPercent);
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
+ result = 31 * result + (endTime != null ? endTime.hashCode() : 0);
+ result = 31 * result + (period != null ? period.hashCode() : 0);
+ temp = Double.doubleToLongBits(price);
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
+ result = 31 * result + (resource != null ? resource.hashCode() : 0);
+ result = 31 * result + (startTime != null ? startTime.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "CalcSubscription{" +
+ "amount='" + amount + '\'' +
+ ", discountAmount=" + discountAmount +
+ ", discountPercent=" + discountPercent +
+ ", endTime=" + endTime +
+ ", period='" + period + '\'' +
+ ", price=" + price +
+ ", resource=" + resource +
+ ", startTime=" + startTime +
+ "}";
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Drive.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Drive.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Drive.java
index 744949a..2913f5f 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Drive.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Drive.java
@@ -113,8 +113,8 @@ public class Drive extends Item {
@ConstructorProperties({
"uuid", "name", "resource_uri", "owner", "status"
})
- public Drive(@Nullable String uuid, String name, @Nullable URI resourceUri, @Nullable Owner owner
- , DriveStatus status) {
+ public Drive(@Nullable String uuid, String name, @Nullable URI resourceUri, @Nullable Owner owner,
+ DriveStatus status) {
super(uuid, name, resourceUri);
this.owner = owner;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/DriveInfo.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/DriveInfo.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/DriveInfo.java
index ba45c3c..6ef3cf4 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/DriveInfo.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/DriveInfo.java
@@ -197,8 +197,8 @@ public class DriveInfo extends Drive {
*/
@Override
public DriveInfo build() {
- return new DriveInfo(uuid, name, resourceUri, size, owner, status, allowMultimount, affinities, jobs, licenses
- , media, meta, mountedOn, tags);
+ return new DriveInfo(uuid, name, resourceUri, size, owner, status, allowMultimount, affinities, jobs, licenses,
+ media, meta, mountedOn, tags);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/FirewallPolicy.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/FirewallPolicy.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/FirewallPolicy.java
index e3caba6..56af42a 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/FirewallPolicy.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/FirewallPolicy.java
@@ -114,8 +114,8 @@ public class FirewallPolicy extends Item {
@ConstructorProperties({
"meta", "name", "owner", "resource_uri", "rules", "servers", "uuid"
})
- public FirewallPolicy(Map<String, String> meta, String name, Owner owner, URI resourceUri, List<FirewallRule> rules
- , List<Server> servers, String uuid) {
+ public FirewallPolicy(Map<String, String> meta, String name, Owner owner, URI resourceUri, List<FirewallRule> rules,
+ List<Server> servers, String uuid) {
super(uuid, name, resourceUri);
this.meta = meta;
this.owner = owner;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/FirewallRule.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/FirewallRule.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/FirewallRule.java
index f948ec7..9ad5a56 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/FirewallRule.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/FirewallRule.java
@@ -107,8 +107,8 @@ public class FirewallRule {
}
public FirewallRule build() {
- return new FirewallRule(action, comment, direction, destinationIp, destinationPort, ipProtocol, sourceIp
- , sourcePort);
+ return new FirewallRule(action, comment, direction, destinationIp, destinationPort, ipProtocol, sourceIp,
+ sourcePort);
}
}
@@ -130,8 +130,8 @@ public class FirewallRule {
"action", "comment", "direction", "dst_ip",
"dst_port", "ip_proto", "src_ip", "src_port"
})
- public FirewallRule(FirewallAction action, String comment, FirewallDirection direction, String destinationIp
- , String destinationPort, FirewallIpProtocol ipProtocol, String sourceIp, String sourcePort) {
+ public FirewallRule(FirewallAction action, String comment, FirewallDirection direction, String destinationIp,
+ String destinationPort, FirewallIpProtocol ipProtocol, String sourceIp, String sourcePort) {
this.action = action;
this.comment = comment;
this.direction = direction;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/IPInfo.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/IPInfo.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/IPInfo.java
index 796303c..ef388c2 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/IPInfo.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/IPInfo.java
@@ -153,8 +153,8 @@ public class IPInfo extends IP {
"uuid", "owner", "server", "resource_uri", "meta", "subscription",
"tags", "nameservers", "netmask", "gateway"
})
- public IPInfo(String uuid, Owner owner, Server server, URI resourceUri, Map<String, String> meta
- , Subscription subscription, List<Tag> tags, List<String> nameservers, int netmask, String gateway) {
+ public IPInfo(String uuid, Owner owner, Server server, URI resourceUri, Map<String, String> meta,
+ Subscription subscription, List<Tag> tags, List<String> nameservers, int netmask, String gateway) {
super(uuid, owner, server, resourceUri);
this.meta = meta;
this.subscription = subscription;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/LibraryDrive.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/LibraryDrive.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/LibraryDrive.java
index 90f1864..2c06b06 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/LibraryDrive.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/LibraryDrive.java
@@ -226,9 +226,9 @@ public class LibraryDrive extends DriveInfo {
}
public LibraryDrive build() {
- return new LibraryDrive(uuid, name, resourceUri, size, owner, status, allowMultimount, affinities, jobs
- , licenses, media, meta, mountedOn, tags, arch, category, description, isFavorite, imageType
- , installNotes, os, isPaid, url);
+ return new LibraryDrive(uuid, name, resourceUri, size, owner, status, allowMultimount, affinities, jobs,
+ licenses, media, meta, mountedOn, tags, arch, category, description, isFavorite, imageType, installNotes,
+ os, isPaid, url);
}
}
@@ -252,11 +252,13 @@ public class LibraryDrive extends DriveInfo {
"media", "meta", "mounted_on", "tags", "arch", "category",
"description", "favourite", "image_type", "install_notes", "os", "paid", "url"
})
- public LibraryDrive(String uuid, String name, URI resourceUri, BigInteger size, Owner owner, DriveStatus status
- , boolean allowMultimount, List<String> affinities, List<String> jobs, List<DriveLicense> licenses
- , MediaType media, Map<String, String> meta, List<Server> mountedOn, List<String> tags, String arch, List<String> category
- , String description, boolean favorite, String imageType, String installNotes, String os, boolean paid, String url) {
- super(uuid, name, resourceUri, size, owner, status, allowMultimount, affinities, jobs, licenses, media, meta, mountedOn, tags);
+ public LibraryDrive(String uuid, String name, URI resourceUri, BigInteger size, Owner owner, DriveStatus status,
+ boolean allowMultimount, List<String> affinities, List<String> jobs, List<DriveLicense> licenses,
+ MediaType media, Map<String, String> meta, List<Server> mountedOn, List<String> tags,
+ String arch, List<String> category, String description, boolean favorite, String imageType,
+ String installNotes, String os, boolean paid, String url) {
+ super(uuid, name, resourceUri, size, owner, status, allowMultimount, affinities, jobs, licenses, media, meta,
+ mountedOn, tags);
this.arch = arch;
this.category = category;
this.description = description;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/NIC.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/NIC.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/NIC.java
index 3a6846d..085f6fb 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/NIC.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/NIC.java
@@ -107,8 +107,8 @@ public class NIC {
"boot_order", "firewall_policy", "ip_v4_conf", "ip_v6_conf",
"mac", "model", "runtime", "vlan"
})
- public NIC(int bootOrder, FirewallPolicy firewallPolicy, IPConfiguration ipV4Configuration
- , IPConfiguration ipV6Configuration, String mac, Model model, NICStats runtime, VLANInfo vlan) {
+ public NIC(int bootOrder, FirewallPolicy firewallPolicy, IPConfiguration ipV4Configuration,
+ IPConfiguration ipV6Configuration, String mac, Model model, NICStats runtime, VLANInfo vlan) {
this.bootOrder = bootOrder;
this.firewallPolicy = firewallPolicy;
this.ipV4Configuration = ipV4Configuration;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Price.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Price.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Price.java
index 4e19a21..e56ced4 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Price.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Price.java
@@ -112,8 +112,8 @@ public class Price {
@ConstructorProperties({
"currency", "id", "level", "multiplier", "price", "resource", "unit"
})
- public Price(String currency, String id, Integer level, BigInteger multiplier, double price
- , SubscriptionResource resource, String unit) {
+ public Price(String currency, String id, Integer level, BigInteger multiplier, double price,
+ SubscriptionResource resource, String unit) {
this.currency = currency;
this.id = id;
this.level = level;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/ProfileInfo.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/ProfileInfo.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/ProfileInfo.java
index 9060ef2..b0392d2 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/ProfileInfo.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/ProfileInfo.java
@@ -209,10 +209,10 @@ public class ProfileInfo {
}
public ProfileInfo build() {
- return new ProfileInfo(address, isApiHttpsOnly, autotopupAmount, autotopupThreshold, bankReference, company
- , country, currency, email, firstName, hasAutotopup, invoicing, isKeyAuth, language, lastName
- , isMailingListEnabled, meta, myNotes, nickname, phone, postcode, reseller, signupTime, state
- , taxName, taxRate, title, town, uuid, vat);
+ return new ProfileInfo(address, isApiHttpsOnly, autotopupAmount, autotopupThreshold, bankReference, company,
+ country, currency, email, firstName, hasAutotopup, invoicing, isKeyAuth, language, lastName,
+ isMailingListEnabled, meta, myNotes, nickname, phone, postcode, reseller, signupTime, state,
+ taxName, taxRate, title, town, uuid, vat);
}
}
@@ -262,19 +262,17 @@ public class ProfileInfo {
private final String vat;
@ConstructorProperties({
- "address", "api_https_only", "autopopup_amount", "autopopup_threshold"
- , "bank_reference", "company", "country", "currency", "email", "first_name"
- , "has_autotopup", "invoicing", "key_auth", "language", "last_name"
- , "mailing_list", "meta", "my_notes", "nickname", "phone"
- , "postcode", "reseller", "signup_time", "state", "tax_name", "tax_rate"
- , "title", "town", "uuid", "vat"
+ "address", "api_https_only", "autopopup_amount", "autopopup_threshold", "bank_reference", "company", "country",
+ "currency", "email", "first_name", "has_autotopup", "invoicing", "key_auth", "language", "last_name",
+ "mailing_list", "meta", "my_notes", "nickname", "phone", "postcode", "reseller", "signup_time", "state",
+ "tax_name", "tax_rate", "title", "town", "uuid", "vat"
})
- public ProfileInfo(String address, boolean apiHttpsOnly, String autotopupAmount, String autotopupThreshold
- , String bankReference, String company, String country, String currency, String email, String firstName
- , boolean hasAutotopup, boolean invoicing, boolean keyAuth, String language, String lastName
- , boolean mailingListEnabled, Map<String, String> meta, String myNotes, String nickname, String phone
- , String postcode, String reseller, Date signupTime, String state, String taxName, double taxRate
- , String title, String town, String uuid, String vat) {
+ public ProfileInfo(String address, boolean apiHttpsOnly, String autotopupAmount, String autotopupThreshold,
+ String bankReference, String company, String country, String currency, String email,
+ String firstName, boolean hasAutotopup, boolean invoicing, boolean keyAuth, String language,
+ String lastName, boolean mailingListEnabled, Map<String, String> meta, String myNotes,
+ String nickname, String phone, String postcode, String reseller, Date signupTime, String state,
+ String taxName, double taxRate, String title, String town, String uuid, String vat) {
this.address = address;
isApiHttpsOnly = apiHttpsOnly;
this.autotopupAmount = autotopupAmount;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Server.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Server.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Server.java
index 8c9f901..c7e1469 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Server.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Server.java
@@ -110,8 +110,8 @@ public class Server extends Item {
@ConstructorProperties({
"uuid", "name", "resource_uri", "owner", "status", "runtime"
})
- public Server(@Nullable String uuid, String name, URI resourceUri, Owner owner, ServerStatus status
- , ServerRuntime runtime) {
+ public Server(@Nullable String uuid, String name, URI resourceUri, Owner owner, ServerStatus status,
+ ServerRuntime runtime) {
super(uuid, name, resourceUri);
this.owner = owner;
this.status = status;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/ServerInfo.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/ServerInfo.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/ServerInfo.java
index ba079e7..ee2ffb1 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/ServerInfo.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/ServerInfo.java
@@ -261,8 +261,8 @@ public class ServerInfo extends Server {
* @return server with details
*/
public ServerInfo build() {
- return new ServerInfo(uuid, name, resourceUri, owner, status, runtime, cpu, cpusInsteadOfCores, drives
- , enableNuma, hvRelaxed, hvTsc, memory, meta, nics, requirements, tags, vncPassword, smp);
+ return new ServerInfo(uuid, name, resourceUri, owner, status, runtime, cpu, cpusInsteadOfCores, drives,
+ enableNuma, hvRelaxed, hvTsc, memory, meta, nics, requirements, tags, vncPassword, smp);
}
}
@@ -292,10 +292,10 @@ public class ServerInfo extends Server {
"hv_relaxed", "hv_tsc", "mem", "meta", "nics",
"requirements", "tags", "vnc_password", "smp"
})
- public ServerInfo(String uuid, String name, URI resourceUri, Owner owner, ServerStatus status, ServerRuntime runtime
- , int cpu, boolean cpusInsteadOfCores, List<ServerDrive> drives, boolean enableNuma
- , boolean hvRelaxed, boolean hvTsc, BigInteger memory, Map<String, String> meta, List<NIC> nics
- , List<String> requirements, List<String> tags, String vncPassword, int smp) {
+ public ServerInfo(String uuid, String name, URI resourceUri, Owner owner, ServerStatus status, ServerRuntime runtime,
+ int cpu, boolean cpusInsteadOfCores, List<ServerDrive> drives, boolean enableNuma,
+ boolean hvRelaxed, boolean hvTsc, BigInteger memory, Map<String, String> meta, List<NIC> nics,
+ List<String> requirements, List<String> tags, String vncPassword, int smp) {
super(uuid, name, resourceUri, owner, status, runtime);
this.cpu = cpu;
this.cpusInsteadOfCores = cpusInsteadOfCores;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Subscription.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Subscription.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Subscription.java
index 1d0495f..a096392 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Subscription.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Subscription.java
@@ -50,7 +50,7 @@ public class Subscription {
/**
* @param amount
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder amount(String amount) {
this.amount = amount;
@@ -59,7 +59,7 @@ public class Subscription {
/**
* @param isAutoRenewEnabled States if the subscription will auto renew on expire
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder isAutoRenewEnabled(boolean isAutoRenewEnabled) {
this.isAutoRenewEnabled = isAutoRenewEnabled;
@@ -68,7 +68,7 @@ public class Subscription {
/**
* @param descendants Subscriptions that have been extended from the current one
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder descendants(List<URI> descendants) {
this.descendants = ImmutableList.copyOf(descendants);
@@ -77,7 +77,7 @@ public class Subscription {
/**
* @param discountAmount Amount of discount
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder discountAmount(double discountAmount) {
this.discountAmount = discountAmount;
@@ -86,7 +86,7 @@ public class Subscription {
/**
* @param discountPercent Percent of discount
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder discountPercent(double discountPercent) {
this.discountPercent = discountPercent;
@@ -95,7 +95,7 @@ public class Subscription {
/**
* @param endTime End time of subscription
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder endTime(Date endTime) {
this.endTime = endTime;
@@ -104,7 +104,7 @@ public class Subscription {
/**
* @param id unique id
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder id(String id) {
this.id = id;
@@ -113,7 +113,7 @@ public class Subscription {
/**
* @param lastNotification A date & time of last notification
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder lastNotification(Date lastNotification) {
this.lastNotification = lastNotification;
@@ -122,7 +122,7 @@ public class Subscription {
/**
* @param period Duration of the subscription
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder period(String period) {
this.period = period;
@@ -131,7 +131,7 @@ public class Subscription {
/**
* @param price Subscription price
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder price(double price) {
this.price = price;
@@ -140,7 +140,7 @@ public class Subscription {
/**
* @param remaining Amount remaining
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder remaining(String remaining) {
this.remaining = remaining;
@@ -149,7 +149,7 @@ public class Subscription {
/**
* @param resource Name of resource associated with the subscription
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder resource(SubscriptionResource resource) {
this.resource = resource;
@@ -158,7 +158,7 @@ public class Subscription {
/**
* @param resourceUri Resource URI
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder resourceUri(URI resourceUri) {
this.resourceUri = resourceUri;
@@ -167,7 +167,7 @@ public class Subscription {
/**
* @param startTime Start time of subscription
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder startTime(Date startTime) {
this.startTime = startTime;
@@ -176,7 +176,7 @@ public class Subscription {
/**
* @param status Status of the subscription
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder status(String status) {
this.status = status;
@@ -185,7 +185,7 @@ public class Subscription {
/**
* @param subscribedObject Subscribed object - the target of this subscription, if applicable
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder subscribedObject(String subscribedObject) {
this.subscribedObject = subscribedObject;
@@ -194,7 +194,7 @@ public class Subscription {
/**
* @param uuid Subscription uuid
- * @return Subscription Binder
+ * @return Subscription Builder
*/
public Builder uuid(String uuid) {
this.uuid = uuid;
@@ -202,9 +202,9 @@ public class Subscription {
}
public Subscription build() {
- return new Subscription(amount, isAutoRenewEnabled, descendants, discountAmount, discountPercent, endTime
- , id, lastNotification, period, price, remaining, resource, resourceUri, startTime, status
- , subscribedObject, uuid);
+ return new Subscription(amount, isAutoRenewEnabled, descendants, discountAmount, discountPercent, endTime, id,
+ lastNotification, period, price, remaining, resource, resourceUri, startTime, status, subscribedObject,
+ uuid);
}
}
@@ -235,15 +235,14 @@ public class Subscription {
private final String uuid;
@ConstructorProperties({
- "amount", "auto_renew", "descendants", "discount_amount"
- , "discount_percent", "end_time", "id", "last_notification", "period", "price"
- , "remaining", "resource", "resource_uri", "start_time", "status"
- , "subscribed_object", "uuid"
+ "amount", "auto_renew", "descendants", "discount_amount", "discount_percent", "end_time", "id",
+ "last_notification", "period", "price", "remaining", "resource", "resource_uri", "start_time", "status",
+ "subscribed_object", "uuid"
})
- public Subscription(String amount, boolean autoRenewEnabled, List<URI> descendants, double discountAmount
- , double discountPercent, Date endTime, String id, Date lastNotification, String period, double price
- , String remaining, SubscriptionResource resource, URI resourceUri, Date startTime, String status
- , String subscribedObject, String uuid) {
+ public Subscription(String amount, boolean autoRenewEnabled, List<URI> descendants, double discountAmount,
+ double discountPercent, Date endTime, String id, Date lastNotification, String period,
+ double price, String remaining, SubscriptionResource resource, URI resourceUri, Date startTime,
+ String status, String subscribedObject, String uuid) {
this.amount = amount;
isAutoRenewEnabled = autoRenewEnabled;
this.descendants = descendants;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/SubscriptionCalculator.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/SubscriptionCalculator.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/SubscriptionCalculator.java
new file mode 100644
index 0000000..addd82a
--- /dev/null
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/SubscriptionCalculator.java
@@ -0,0 +1,83 @@
+/*
+ * 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 javax.inject.Named;
+import java.beans.ConstructorProperties;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * @author Vladimir Shevchenko
+ */
+public class SubscriptionCalculator {
+ private final double price;
+ @Named("objects")
+ private final List<CalcSubscription> subscriptions;
+
+ @ConstructorProperties({"price", "objects"})
+ public SubscriptionCalculator(double price, List<CalcSubscription> subscriptions) {
+ this.price = checkNotNull(price, "price");
+ this.subscriptions = checkNotNull(subscriptions, "subscriptions");
+ }
+
+ /**
+ * @return total price for all requested subscriptions
+ */
+ public double getPrice() {
+ return price;
+ }
+
+ /**
+ * @return list of all subscriptions requested for calculation
+ */
+ public List<CalcSubscription> getSubscriptions() {
+ return subscriptions;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof SubscriptionCalculator)) return false;
+
+ SubscriptionCalculator that = (SubscriptionCalculator) o;
+
+ if (Double.compare(that.price, price) != 0) return false;
+ if (subscriptions != null ? !subscriptions.equals(that.subscriptions) : that.subscriptions != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result;
+ long temp;
+ temp = Double.doubleToLongBits(price);
+ result = (int) (temp ^ (temp >>> 32));
+ result = 31 * result + (subscriptions != null ? subscriptions.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "SubscriptionCalculator{" +
+ "price=" + price +
+ ", subscriptions=" + subscriptions +
+ "}";
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Tag.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Tag.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Tag.java
index 0fe76fa..1196a3b 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Tag.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Tag.java
@@ -85,8 +85,8 @@ public class Tag extends Item {
@ConstructorProperties({
"uuid", "name", "resource_uri", "meta", "owner", "resources"
})
- public Tag(String uuid, String name, URI resourceUri, Map<String, String> meta, Owner owner
- , List<TagResource> resources) {
+ public Tag(String uuid, String name, URI resourceUri, Map<String, String> meta, Owner owner,
+ List<TagResource> resources) {
super(uuid, name, resourceUri);
this.meta = meta;
this.owner = owner;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Transaction.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Transaction.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Transaction.java
index 70f186d..a0084c4 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Transaction.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/Transaction.java
@@ -86,8 +86,8 @@ public class Transaction {
@ConstructorProperties({
"amount", "billing_cycle", "end", "id", "initial", "reason", "time"
})
- public Transaction(double amount, long billingCycle, double end, String id, double initial, String reason
- , Date time) {
+ public Transaction(double amount, long billingCycle, double end, String id, double initial, String reason,
+ Date time) {
this.amount = amount;
this.billingCycle = billingCycle;
this.end = end;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/VLANInfo.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/VLANInfo.java b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/VLANInfo.java
index d0c67f4..fb62b4e 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/VLANInfo.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/domain/VLANInfo.java
@@ -118,8 +118,8 @@ public class VLANInfo {
@ConstructorProperties({
"meta", "uuid", "owner", "resource_uri", "servers", "subscription", "tags"
})
- public VLANInfo(Map<String, String> meta, String uuid, Owner owner, URI resourceUri, List<Server> servers
- , Subscription subscription, List<Tag> tags) {
+ public VLANInfo(Map<String, String> meta, String uuid, Owner owner, URI resourceUri, List<Server> servers,
+ Subscription subscription, List<Tag> tags) {
this.meta = meta;
this.uuid = uuid;
this.owner = owner;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/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
index 847f281..014935e 100644
--- a/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseSubscriptions.java
+++ b/cloudsigma2/src/main/java/org/jclouds/cloudsigma2/functions/internal/ParseSubscriptions.java
@@ -26,7 +26,6 @@ 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;
@@ -71,25 +70,4 @@ public class ParseSubscriptions extends ParseJson<ParseSubscriptions.Subscriptio
};
}
}
-
- 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);
- }
- };
- }
- }
}
[2/3] JCLOUDS-390. Update calculation of subscriptions according
recent changes in the cloudsigma2 provder API.
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/237dcbed/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/CloudSigma2ApiExpectTest.java
----------------------------------------------------------------------
diff --git a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/CloudSigma2ApiExpectTest.java b/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/CloudSigma2ApiExpectTest.java
index 65f6623..3941910 100644
--- a/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/CloudSigma2ApiExpectTest.java
+++ b/cloudsigma2/src/test/java/org/jclouds/cloudsigma2/CloudSigma2ApiExpectTest.java
@@ -18,6 +18,7 @@ package org.jclouds.cloudsigma2;
import com.google.common.collect.ImmutableList;
import org.jclouds.cloudsigma2.domain.AccountBalance;
+import org.jclouds.cloudsigma2.domain.CalcSubscription;
import org.jclouds.cloudsigma2.domain.CreateSubscriptionRequest;
import org.jclouds.cloudsigma2.domain.CurrentUsage;
import org.jclouds.cloudsigma2.domain.Discount;
@@ -37,6 +38,7 @@ import org.jclouds.cloudsigma2.domain.ProfileInfo;
import org.jclouds.cloudsigma2.domain.Server;
import org.jclouds.cloudsigma2.domain.ServerInfo;
import org.jclouds.cloudsigma2.domain.Subscription;
+import org.jclouds.cloudsigma2.domain.SubscriptionCalculator;
import org.jclouds.cloudsigma2.domain.SubscriptionResource;
import org.jclouds.cloudsigma2.domain.Tag;
import org.jclouds.cloudsigma2.domain.TagResource;
@@ -52,6 +54,7 @@ import org.testng.annotations.Test;
import javax.ws.rs.core.MediaType;
import java.math.BigInteger;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -110,18 +113,18 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "drives/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "drives/")
- .addQueryParam("limit", "2")
- .addQueryParam("offset", "2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives.json", MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "drives/")
+ .addQueryParam("limit", "2")
+ .addQueryParam("offset", "2")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives-last-page.json", MediaType.APPLICATION_JSON))
+ .build());
List<Drive> drives = api.listDrives().concat().toList();
@@ -136,10 +139,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "drives/?limit=3&offset=3")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives.json", MediaType.APPLICATION_JSON))
+ .build());
for (Drive drive : api.listDrives(new PaginationOptions.Builder().limit(3).offset(3).build())) {
assertNotNull(drive);
@@ -151,18 +154,20 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "drives/detail/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives-detail-first-page.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "drives/detail/")
- .addQueryParam("limit", "2")
- .addQueryParam("offset", "2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives-detail-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives-detail-first-page.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "drives/detail/")
+ .addQueryParam("limit", "2")
+ .addQueryParam("offset", "2")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives-detail-last-page.json",
+ MediaType.APPLICATION_JSON))
+ .build());
List<DriveInfo> drives = api.listDrivesInfo().concat().toList();
@@ -177,10 +182,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "drives/detail/?limit=3&offset=3")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON))
+ .build());
for (DriveInfo driveInfo : api.listDrivesInfo(new PaginationOptions.Builder().limit(3).offset(3).build())) {
assertNotNull(driveInfo);
@@ -193,10 +198,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "drives/" + uuid + "/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON))
+ .build());
DriveInfo result = api.getDriveInfo(uuid);
assertNotNull(result);
@@ -206,13 +211,13 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
public void testCreateDrive() throws Exception {
CloudSigma2Api api = requestSendsResponse(
postBuilder()
- .payload(payloadFromResourceWithContentType("/drives-create-request.json"
- , MediaType.APPLICATION_JSON))
+ .payload(payloadFromResourceWithContentType("/drives-create-request.json",
+ MediaType.APPLICATION_JSON))
.endpoint(endpoint + "drives/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives-single.json", MediaType.APPLICATION_JSON))
+ .build());
DriveInfo result = api.createDrive(new DriveInfo.Builder()
.media(org.jclouds.cloudsigma2.domain.MediaType.DISK)
@@ -227,13 +232,13 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
public void testCreateDrives() throws Exception {
CloudSigma2Api api = requestSendsResponse(
postBuilder()
- .payload(payloadFromResourceWithContentType("/drives-create-multiple-request.json"
- , MediaType.APPLICATION_JSON))
+ .payload(payloadFromResourceWithContentType("/drives-create-multiple-request.json",
+ MediaType.APPLICATION_JSON))
.endpoint(endpoint + "drives/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON))
+ .build());
List<DriveInfo> result = api.createDrives(ImmutableList.of(
new DriveInfo.Builder()
@@ -241,19 +246,19 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
.name("test_drive_0")
.size(new BigInteger("1024000000"))
.allowMultimount(false)
- .build()
- , new DriveInfo.Builder()
- .media(org.jclouds.cloudsigma2.domain.MediaType.DISK)
- .name("test_drive_1")
- .size(new BigInteger("1024000000"))
- .allowMultimount(false)
- .build()
- , new DriveInfo.Builder()
- .media(org.jclouds.cloudsigma2.domain.MediaType.DISK)
- .name("test_drive_2")
- .size(new BigInteger("1024000000"))
- .allowMultimount(false)
- .build()));
+ .build(),
+ new DriveInfo.Builder()
+ .media(org.jclouds.cloudsigma2.domain.MediaType.DISK)
+ .name("test_drive_1")
+ .size(new BigInteger("1024000000"))
+ .allowMultimount(false)
+ .build(),
+ new DriveInfo.Builder()
+ .media(org.jclouds.cloudsigma2.domain.MediaType.DISK)
+ .name("test_drive_2")
+ .size(new BigInteger("1024000000"))
+ .allowMultimount(false)
+ .build()));
assertNotNull(result);
assertEquals(result.size(), 3);
}
@@ -264,9 +269,9 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
deleteBuilder()
.endpoint(endpoint + "drives/" + uuid + "/")
- .build()
- , responseBuilder()
- .build());
+ .build(),
+ responseBuilder()
+ .build());
api.deleteDrive(uuid);
}
@@ -281,11 +286,11 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
deleteBuilder()
.endpoint(endpoint + "drives/")
- .payload(payloadFromResourceWithContentType("/drives-delete-multiple.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .build());
+ .payload(payloadFromResourceWithContentType("/drives-delete-multiple.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ responseBuilder()
+ .build());
api.deleteDrives(deleteList);
}
@@ -295,13 +300,13 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
String uuid = "e96f3c63-6f50-47eb-9401-a56c5ccf6b32";
CloudSigma2Api api = requestSendsResponse(
putBuilder()
- .payload(payloadFromResourceWithContentType("/drives-create-request.json"
- , MediaType.APPLICATION_JSON))
+ .payload(payloadFromResourceWithContentType("/drives-create-request.json",
+ MediaType.APPLICATION_JSON))
.endpoint(endpoint + "drives/" + uuid + "/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON))
+ .build());
DriveInfo result = api.editDrive(uuid, new DriveInfo.Builder()
.media(org.jclouds.cloudsigma2.domain.MediaType.DISK)
@@ -317,13 +322,13 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
String uuid = "e96f3c63-6f50-47eb-9401-a56c5ccf6b32";
CloudSigma2Api api = requestSendsResponse(
postBuilder()
- .payload(payloadFromResourceWithContentType("/drives-create-request.json"
- , MediaType.APPLICATION_JSON))
+ .payload(payloadFromResourceWithContentType("/drives-create-request.json",
+ MediaType.APPLICATION_JSON))
.endpoint(endpoint + "drives/" + uuid + "/action/?do=clone")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/drives-detail.json", MediaType.APPLICATION_JSON))
+ .build());
DriveInfo result = api.cloneDrive(uuid, new DriveInfo.Builder()
.media(org.jclouds.cloudsigma2.domain.MediaType.DISK)
@@ -339,18 +344,18 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "libdrives/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/libdrives.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "libdrives/")
- .addQueryParam("limit", "2")
- .addQueryParam("offset", "2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/libdrives-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/libdrives.json", MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "libdrives/")
+ .addQueryParam("limit", "2")
+ .addQueryParam("offset", "2")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/libdrives-last-page.json", MediaType.APPLICATION_JSON))
+ .build());
List<LibraryDrive> drives = api.listLibraryDrives().concat().toList();
@@ -365,10 +370,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "libdrives/?limit=3&offset=3")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/libdrives.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/libdrives.json", MediaType.APPLICATION_JSON))
+ .build());
for (LibraryDrive libraryDrive : api.listLibraryDrives(new PaginationOptions.Builder()
.limit(3)
@@ -384,10 +389,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "libdrives/" + uuid + "/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/libdrives-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/libdrives-single.json", MediaType.APPLICATION_JSON))
+ .build());
LibraryDrive result = api.getLibraryDrive(uuid);
assertNotNull(result);
@@ -398,13 +403,13 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
String uuid = "e96f3c63-6f50-47eb-9401-a56c5ccf6b32";
CloudSigma2Api api = requestSendsResponse(
postBuilder()
- .payload(payloadFromResourceWithContentType("/libdrives-create-request.json"
- , MediaType.APPLICATION_JSON))
+ .payload(payloadFromResourceWithContentType("/libdrives-create-request.json",
+ MediaType.APPLICATION_JSON))
.endpoint(endpoint + "libdrives/" + uuid + "/action/?do=clone")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/libdrives-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/libdrives-single.json", MediaType.APPLICATION_JSON))
+ .build());
DriveInfo result = api.cloneLibraryDrive(uuid, new LibraryDrive.Builder()
.media(org.jclouds.cloudsigma2.domain.MediaType.DISK)
@@ -420,18 +425,18 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "servers/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/servers.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "servers/")
- .addQueryParam("limit", "2")
- .addQueryParam("offset", "2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/servers-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/servers.json", MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "servers/")
+ .addQueryParam("limit", "2")
+ .addQueryParam("offset", "2")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/servers-last-page.json", MediaType.APPLICATION_JSON))
+ .build());
List<Server> servers = api.listServers().concat().toList();
@@ -446,10 +451,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "servers/?limit=3&offset=3")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/servers.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/servers.json", MediaType.APPLICATION_JSON))
+ .build());
for (Server sever : api.listServers(new PaginationOptions.Builder().limit(3).offset(3).build())) {
assertNotNull(sever);
@@ -461,18 +466,20 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "servers/detail/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/server-detail-first-page.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "servers/detail/")
- .addQueryParam("limit", "2")
- .addQueryParam("offset", "2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/server-detail-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/server-detail-first-page.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "servers/detail/")
+ .addQueryParam("limit", "2")
+ .addQueryParam("offset", "2")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/server-detail-last-page.json",
+ MediaType.APPLICATION_JSON))
+ .build());
List<ServerInfo> serverInfos = api.listServersInfo().concat().toList();
@@ -487,10 +494,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "servers/detail/?limit=3&offset=3")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/server-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/server-detail.json", MediaType.APPLICATION_JSON))
+ .build());
for (ServerInfo serverInfo : api.listServersInfo(new PaginationOptions.Builder().limit(3).offset(3).build())) {
assertNotNull(serverInfo);
@@ -504,10 +511,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
.endpoint(endpoint + "servers/")
.payload(payloadFromResourceWithContentType("/servers-create-request.json"
, MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/servers-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/servers-single.json", MediaType.APPLICATION_JSON))
+ .build());
ServerInfo result = api.createServer(new ServerInfo.Builder()
.cpu(100)
@@ -523,31 +530,32 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "servers/")
- .payload(payloadFromResourceWithContentType("/servers-create-multiple-request.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/server-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .payload(payloadFromResourceWithContentType("/servers-create-multiple-request.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/server-detail.json", MediaType.APPLICATION_JSON))
+ .build());
+
List<ServerInfo> result = api.createServers(ImmutableList.of(
new ServerInfo.Builder()
.cpu(100)
.memory(new BigInteger("536870912"))
.name("test_server_0")
.vncPassword("testserver")
- .build()
- , new ServerInfo.Builder()
- .cpu(100)
- .memory(new BigInteger("536870912"))
- .name("test_server_1")
- .vncPassword("testserver")
- .build()
- , new ServerInfo.Builder()
- .cpu(100)
- .memory(new BigInteger("536870912"))
- .name("test_server_2")
- .vncPassword("testserver")
- .build()));
+ .build(),
+ new ServerInfo.Builder()
+ .cpu(100)
+ .memory(new BigInteger("536870912"))
+ .name("test_server_1")
+ .vncPassword("testserver")
+ .build(),
+ new ServerInfo.Builder()
+ .cpu(100)
+ .memory(new BigInteger("536870912"))
+ .name("test_server_2")
+ .vncPassword("testserver")
+ .build()));
assertNotNull(result);
}
@@ -558,12 +566,12 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
putBuilder()
.endpoint(endpoint + "servers/" + uuid + "/")
- .payload(payloadFromResourceWithContentType("/servers-create-request.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/servers-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .payload(payloadFromResourceWithContentType("/servers-create-request.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/servers-single.json", MediaType.APPLICATION_JSON))
+ .build());
ServerInfo result = api.editServer(uuid, new ServerInfo.Builder()
.name("testServerAcc")
@@ -580,9 +588,9 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
deleteBuilder()
.endpoint(endpoint + "servers/" + uuid + "/")
- .build()
- , responseBuilder()
- .build());
+ .build(),
+ responseBuilder()
+ .build());
api.deleteServer(uuid);
}
@@ -590,18 +598,18 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
@Test
public void testDeleteServers() throws Exception {
List<String> deleteUuids = ImmutableList.of(
- "33e71c37-0d0a-4a3a-a1ea-dc7265c9a154"
- , "61d61337-884b-4c87-b4de-f7f48f9cfc84"
- , "a19a425f-9e92-42f6-89fb-6361203071bb"
+ "33e71c37-0d0a-4a3a-a1ea-dc7265c9a154",
+ "61d61337-884b-4c87-b4de-f7f48f9cfc84",
+ "a19a425f-9e92-42f6-89fb-6361203071bb"
);
CloudSigma2Api api = requestSendsResponse(
deleteBuilder()
.endpoint(endpoint + "servers/")
- .payload(payloadFromResourceWithContentType("/servers-delete-multiple-request.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .build());
+ .payload(payloadFromResourceWithContentType("/servers-delete-multiple-request.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ responseBuilder()
+ .build());
api.deleteServers(deleteUuids);
}
@@ -617,10 +625,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "servers/" + uuid + "/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/servers-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/servers-single.json", MediaType.APPLICATION_JSON))
+ .build());
api.getServerInfo(uuid);
}
@@ -631,9 +639,9 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "servers/" + uuid + "/action/?do=start")
- .build()
- , responseBuilder()
- .build());
+ .build(),
+ responseBuilder()
+ .build());
api.startServer(uuid);
}
@@ -644,9 +652,9 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "servers/" + uuid + "/action/?do=stop")
- .build()
- , responseBuilder()
- .build());
+ .build(),
+ responseBuilder()
+ .build());
api.stopServer(uuid);
}
@@ -665,9 +673,9 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
+ uuidGroup.get(0)
+ "&avoid="
+ uuidGroup.get(1))
- .build()
- , responseBuilder()
- .build());
+ .build(),
+ responseBuilder()
+ .build());
api.startServerInSeparateAvailabilityGroup(uuid, uuidGroup);
}
@@ -678,9 +686,9 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "servers/" + uuid + "/action/?do=open_vnc")
- .build()
- , responseBuilder()
- .build());
+ .build(),
+ responseBuilder()
+ .build());
api.openServerVNCTunnel(uuid);
}
@@ -691,9 +699,9 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "servers/" + uuid + "/action/?do=close_vnc")
- .build()
- , responseBuilder()
- .build());
+ .build(),
+ responseBuilder()
+ .build());
api.closeServerVCNTunnel(uuid);
}
@@ -703,11 +711,11 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "servers/availability_groups/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/servers-availability-groups.json"
- , MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/servers-availability-groups.json",
+ MediaType.APPLICATION_JSON))
+ .build());
for (List<String> availabilityGroup : api.listServerAvailabilityGroup()) {
assertNotNull(availabilityGroup);
@@ -719,20 +727,20 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "fwpolicies/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/fwpolicies-detail-first-page.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "fwpolicies/")
- .addQueryParam("limit", "1")
- .addQueryParam("offset", "1")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/fwpolicies-detail-last-page.json"
- , MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/fwpolicies-detail-first-page.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "fwpolicies/")
+ .addQueryParam("limit", "1")
+ .addQueryParam("offset", "1")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/fwpolicies-detail-last-page.json",
+ MediaType.APPLICATION_JSON))
+ .build());
List<FirewallPolicy> firewallPolicies = api.listFirewallPolicies().concat().toList();
@@ -746,10 +754,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "fwpolicies/?limit=2&offset=2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/fwpolicies-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/fwpolicies-detail.json", MediaType.APPLICATION_JSON))
+ .build());
for (FirewallPolicy firewallPolicy : api.listFirewallPolicies(new PaginationOptions.Builder()
.limit(2)
@@ -764,20 +772,20 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "fwpolicies/detail/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/fwpolicies-detail-first-page.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "fwpolicies/detail/")
- .addQueryParam("limit", "1")
- .addQueryParam("offset", "1")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/fwpolicies-detail-last-page.json"
- , MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/fwpolicies-detail-first-page.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "fwpolicies/detail/")
+ .addQueryParam("limit", "1")
+ .addQueryParam("offset", "1")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/fwpolicies-detail-last-page.json",
+ MediaType.APPLICATION_JSON))
+ .build());
List<FirewallPolicy> firewallPolicies = api.listFirewallPoliciesInfo().concat().toList();
@@ -791,10 +799,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "fwpolicies/detail/?limit=2&offset=2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/fwpolicies-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/fwpolicies-detail.json", MediaType.APPLICATION_JSON))
+ .build());
for (FirewallPolicy firewallPolicy : api.listFirewallPoliciesInfo(new PaginationOptions.Builder()
.limit(2)
@@ -809,12 +817,12 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "fwpolicies/")
- .payload(payloadFromResourceWithContentType("/fwpolicies-create-multiple-request.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/fwpolicies-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .payload(payloadFromResourceWithContentType("/fwpolicies-create-multiple-request.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/fwpolicies-detail.json", MediaType.APPLICATION_JSON))
+ .build());
List<FirewallPolicy> result = api.createFirewallPolicies(ImmutableList.of(
new FirewallPolicy.Builder()
@@ -831,46 +839,47 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
.sourcePort("321")
.build()
))
- .build()
- , new FirewallPolicy.Builder()
- .name("My awesome policy")
- .rules(ImmutableList.of(
- new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop traffic from the VM to IP address 23.0.0.0/32")
- .direction(FirewallDirection.OUT)
- .destinationIp("23.0.0.0/32")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.ACCEPT)
- .comment("Allow SSH traffic to the VM from our office in Dubai")
- .direction(FirewallDirection.IN)
- .destinationPort("22")
- .ipProtocol(FirewallIpProtocol.TCP)
- .sourceIp("172.66.32.0/24")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop all other SSH traffic to the VM")
- .direction(FirewallDirection.IN)
- .destinationPort("22")
- .ipProtocol(FirewallIpProtocol.TCP)
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop all UDP traffic to the VM, not originating from 172.66.32.55")
- .direction(FirewallDirection.IN)
- .ipProtocol(FirewallIpProtocol.UDP)
- .sourceIp("!172.66.32.55/32")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop any traffic, to the VM with destination port not between 1-1024")
- .direction(FirewallDirection.IN)
- .destinationPort("!1:1024")
- .ipProtocol(FirewallIpProtocol.TCP)
- .build()))
- .build()));
+ .build(),
+ new FirewallPolicy.Builder()
+ .name("My awesome policy")
+ .rules(ImmutableList.of(
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop traffic from the VM to IP address 23.0.0.0/32")
+ .direction(FirewallDirection.OUT)
+ .destinationIp("23.0.0.0/32")
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.ACCEPT)
+ .comment("Allow SSH traffic to the VM from our office in Dubai")
+ .direction(FirewallDirection.IN)
+ .destinationPort("22")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .sourceIp("172.66.32.0/24")
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop all other SSH traffic to the VM")
+ .direction(FirewallDirection.IN)
+ .destinationPort("22")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop all UDP traffic to the VM, not originating from 172.66.32.55")
+ .direction(FirewallDirection.IN)
+ .ipProtocol(FirewallIpProtocol.UDP)
+ .sourceIp("!172.66.32.55/32")
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop any traffic, to the VM with destination port not between 1-1024")
+ .direction(FirewallDirection.IN)
+ .destinationPort("!1:1024")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .build()))
+ .build()));
+
assertNotNull(result);
}
@@ -879,12 +888,12 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "fwpolicies/")
- .payload(payloadFromResourceWithContentType("/fwpolicies-create-request.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/fwpolicies-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .payload(payloadFromResourceWithContentType("/fwpolicies-create-request.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/fwpolicies-single.json", MediaType.APPLICATION_JSON))
+ .build());
FirewallPolicy result = api.createFirewallPolicy(new FirewallPolicy.Builder()
.name("My awesome policy")
@@ -894,93 +903,95 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
.comment("Drop traffic from the VM to IP address 23.0.0.0/32")
.direction(FirewallDirection.OUT)
.destinationIp("23.0.0.0/32")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.ACCEPT)
- .comment("Allow SSH traffic to the VM from our office in Dubai")
- .direction(FirewallDirection.IN)
- .destinationPort("22")
- .ipProtocol(FirewallIpProtocol.TCP)
- .sourceIp("172.66.32.0/24")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop all other SSH traffic to the VM")
- .direction(FirewallDirection.IN)
- .destinationPort("22")
- .ipProtocol(FirewallIpProtocol.TCP)
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop all UDP traffic to the VM, not originating from 172.66.32.55")
- .direction(FirewallDirection.IN)
- .ipProtocol(FirewallIpProtocol.UDP)
- .sourceIp("!172.66.32.55/32")
- .build()
- , new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop any traffic, to the VM with destination port not between 1-1024")
- .direction(FirewallDirection.IN)
- .destinationPort("!1:1024")
- .ipProtocol(FirewallIpProtocol.TCP)
- .build()))
- .build());
- assertNotNull(result);
- }
-
- @Test
- public void testEditFirewallPolicy() throws Exception {
- String uuid = "cf8479b4-c98b-46c8-ab9c-108bb00c8218";
- CloudSigma2Api api = requestSendsResponse(
- putBuilder()
- .endpoint(endpoint + "fwpolicies/" + uuid + "/")
- .payload(payloadFromResourceWithContentType("/fwpolicies-create-request.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/fwpolicies-single.json", MediaType.APPLICATION_JSON))
- .build());
-
- FirewallPolicy result = api.editFirewallPolicy(uuid,
- new FirewallPolicy.Builder()
- .name("My awesome policy")
- .rules(ImmutableList.of(
- new FirewallRule.Builder()
- .action(FirewallAction.DROP)
- .comment("Drop traffic from the VM to IP address 23.0.0.0/32")
- .direction(FirewallDirection.OUT)
- .destinationIp("23.0.0.0/32")
- .build()
- , new FirewallRule.Builder()
+ .build(),
+ new FirewallRule.Builder()
.action(FirewallAction.ACCEPT)
.comment("Allow SSH traffic to the VM from our office in Dubai")
.direction(FirewallDirection.IN)
.destinationPort("22")
.ipProtocol(FirewallIpProtocol.TCP)
.sourceIp("172.66.32.0/24")
- .build()
- , new FirewallRule.Builder()
+ .build(),
+ new FirewallRule.Builder()
.action(FirewallAction.DROP)
.comment("Drop all other SSH traffic to the VM")
.direction(FirewallDirection.IN)
.destinationPort("22")
.ipProtocol(FirewallIpProtocol.TCP)
- .build()
- , new FirewallRule.Builder()
+ .build(),
+ new FirewallRule.Builder()
.action(FirewallAction.DROP)
.comment("Drop all UDP traffic to the VM, not originating from 172.66.32.55")
.direction(FirewallDirection.IN)
.ipProtocol(FirewallIpProtocol.UDP)
.sourceIp("!172.66.32.55/32")
- .build()
- , new FirewallRule.Builder()
+ .build(),
+ new FirewallRule.Builder()
.action(FirewallAction.DROP)
.comment("Drop any traffic, to the VM with destination port not between 1-1024")
.direction(FirewallDirection.IN)
.destinationPort("!1:1024")
.ipProtocol(FirewallIpProtocol.TCP)
.build()))
+ .build());
+
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testEditFirewallPolicy() throws Exception {
+ String uuid = "cf8479b4-c98b-46c8-ab9c-108bb00c8218";
+ CloudSigma2Api api = requestSendsResponse(
+ putBuilder()
+ .endpoint(endpoint + "fwpolicies/" + uuid + "/")
+ .payload(payloadFromResourceWithContentType("/fwpolicies-create-request.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/fwpolicies-single.json", MediaType.APPLICATION_JSON))
+ .build());
+
+ FirewallPolicy result = api.editFirewallPolicy(uuid,
+ new FirewallPolicy.Builder()
+ .name("My awesome policy")
+ .rules(ImmutableList.of(
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop traffic from the VM to IP address 23.0.0.0/32")
+ .direction(FirewallDirection.OUT)
+ .destinationIp("23.0.0.0/32")
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.ACCEPT)
+ .comment("Allow SSH traffic to the VM from our office in Dubai")
+ .direction(FirewallDirection.IN)
+ .destinationPort("22")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .sourceIp("172.66.32.0/24")
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop all other SSH traffic to the VM")
+ .direction(FirewallDirection.IN)
+ .destinationPort("22")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop all UDP traffic to the VM, not originating from 172.66.32.55")
+ .direction(FirewallDirection.IN)
+ .ipProtocol(FirewallIpProtocol.UDP)
+ .sourceIp("!172.66.32.55/32")
+ .build(),
+ new FirewallRule.Builder()
+ .action(FirewallAction.DROP)
+ .comment("Drop any traffic, to the VM with destination port not between 1-1024")
+ .direction(FirewallDirection.IN)
+ .destinationPort("!1:1024")
+ .ipProtocol(FirewallIpProtocol.TCP)
+ .build()))
.build());
+
assertNotNull(result);
}
@@ -990,10 +1001,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "vlans/" + uuid + "/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/vlan-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/vlan-single.json", MediaType.APPLICATION_JSON))
+ .build());
VLANInfo result = api.getVLANInfo(uuid);
assertNotNull(result);
@@ -1004,18 +1015,18 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "vlans/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/vlans.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "vlans/")
- .addQueryParam("limit", "1")
- .addQueryParam("offset", "1")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/vlans-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/vlans.json", MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "vlans/")
+ .addQueryParam("limit", "1")
+ .addQueryParam("offset", "1")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/vlans-last-page.json", MediaType.APPLICATION_JSON))
+ .build());
List<VLANInfo> vlans = api.listVLANs().concat().toList();
@@ -1029,10 +1040,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "vlans/?limit=2&offset=2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/vlans.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/vlans.json", MediaType.APPLICATION_JSON))
+ .build());
for (VLANInfo vlanInfo : api.listVLANs(new PaginationOptions.Builder().limit(2).offset(2).build())) {
assertNotNull(vlanInfo);
@@ -1044,18 +1055,18 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "vlans/detail/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/vlans.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "vlans/detail/")
- .addQueryParam("limit", "1")
- .addQueryParam("offset", "1")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/vlans-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/vlans.json", MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "vlans/detail/")
+ .addQueryParam("limit", "1")
+ .addQueryParam("offset", "1")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/vlans-last-page.json", MediaType.APPLICATION_JSON))
+ .build());
List<VLANInfo> vlanInfos = api.listVLANInfo().concat().toList();
@@ -1069,10 +1080,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "vlans/detail/?limit=2&offset=2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/vlans.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/vlans.json", MediaType.APPLICATION_JSON))
+ .build());
for (VLANInfo vlanInfo : api.listVLANInfo(new PaginationOptions.Builder().limit(2).offset(2).build())) {
assertNotNull(vlanInfo);
@@ -1091,15 +1102,12 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
putBuilder()
.endpoint(endpoint + "vlans/" + uuid + "/")
.payload(payloadFromResourceWithContentType("/vlans-edit-request.json", MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/vlan-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/vlan-single.json", MediaType.APPLICATION_JSON))
+ .build());
- VLANInfo result = api.editVLAN(uuid
- , new VLANInfo.Builder()
- .meta(meta)
- .build());
+ VLANInfo result = api.editVLAN(uuid, new VLANInfo.Builder().meta(meta).build());
assertNotNull(result);
}
@@ -1108,18 +1116,18 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "ips/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/ips.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "ips/")
- .addQueryParam("limit", "1")
- .addQueryParam("offset", "1")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/ips-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/ips.json", MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "ips/")
+ .addQueryParam("limit", "1")
+ .addQueryParam("offset", "1")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/ips-last-page.json", MediaType.APPLICATION_JSON))
+ .build());
List<IP> ips = api.listIPs().concat().toList();
@@ -1133,10 +1141,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "ips/?limit=2&offset=2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/ips.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/ips.json", MediaType.APPLICATION_JSON))
+ .build());
for (IP ip : api.listIPs(new PaginationOptions.Builder().limit(2).offset(2).build())) {
assertNotNull(ip);
@@ -1148,18 +1156,18 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "ips/detail/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/ips.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "ips/detail/")
- .addQueryParam("limit", "1")
- .addQueryParam("offset", "1")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/ips-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/ips.json", MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "ips/detail/")
+ .addQueryParam("limit", "1")
+ .addQueryParam("offset", "1")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/ips-last-page.json", MediaType.APPLICATION_JSON))
+ .build());
List<IPInfo> ipInfos = api.listIPInfo().concat().toList();
@@ -1173,10 +1181,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "ips/detail/?limit=2&offset=2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/ips.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/ips.json", MediaType.APPLICATION_JSON))
+ .build());
for (IPInfo ipInfo : api.listIPInfo(new PaginationOptions.Builder().limit(2).offset(2).build())) {
assertNotNull(ipInfo);
@@ -1189,10 +1197,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "ips/" + uuid + "/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/ips-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/ips-single.json", MediaType.APPLICATION_JSON))
+ .build());
IPInfo result = api.getIPInfo(uuid);
assertNotNull(result);
@@ -1210,15 +1218,12 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
putBuilder()
.endpoint(endpoint + "ips/" + uuid + "/")
.payload(payloadFromResourceWithContentType("/ips-edit-request.json", MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/ips-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/ips-single.json", MediaType.APPLICATION_JSON))
+ .build());
- IPInfo result = api.editIP(uuid
- , new IPInfo.Builder()
- .meta(meta)
- .build());
+ IPInfo result = api.editIP(uuid, new IPInfo.Builder().meta(meta).build());
assertNotNull(result);
}
@@ -1227,18 +1232,20 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "tags/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/tags-detail-first-page.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "tags/")
- .addQueryParam("limit", "1")
- .addQueryParam("offset", "1")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/tags-detail-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/tags-detail-first-page.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "tags/")
+ .addQueryParam("limit", "1")
+ .addQueryParam("offset", "1")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/tags-detail-last-page.json",
+ MediaType.APPLICATION_JSON))
+ .build());
List<Tag> tags = api.listTags().concat().toList();
@@ -1252,10 +1259,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "tags/?limit=2&offset=2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/tags-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/tags-detail.json", MediaType.APPLICATION_JSON))
+ .build());
for (Tag tag : api.listTags(new PaginationOptions.Builder().limit(2).offset(2).build())) {
assertNotNull(tag);
@@ -1267,18 +1274,21 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "tags/detail/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/tags-detail-first-page.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "tags/detail/")
- .addQueryParam("limit", "1")
- .addQueryParam("offset", "1")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/tags-detail-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/tags-detail-first-page.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "tags/detail/")
+ .addQueryParam("limit", "1")
+ .addQueryParam("offset", "1")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/tags-detail-last-page.json",
+ MediaType.APPLICATION_JSON))
+ .build());
+
List<Tag> tags = api.listTagsInfo().concat().toList();
@@ -1293,10 +1303,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "tags/detail/?limit=2&offset=2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/tags-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/tags-detail.json", MediaType.APPLICATION_JSON))
+ .build());
for (Tag tag : api.listTagsInfo(new PaginationOptions.Builder().limit(2).offset(2).build())) {
assertNotNull(tag);
@@ -1309,10 +1319,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "tags/" + uuid + "/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/tags-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/tags-single.json", MediaType.APPLICATION_JSON))
+ .build());
Tag result = api.getTagInfo(uuid);
assertNotNull(result);
@@ -1325,10 +1335,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
putBuilder()
.endpoint(endpoint + "tags/" + uuid + "/")
.payload(payloadFromResourceWithContentType("/tags-create-request.json", MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/tags-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/tags-single.json", MediaType.APPLICATION_JSON))
+ .build());
Tag result = api.editTag(uuid,
new Tag.Builder()
@@ -1350,19 +1360,19 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
postBuilder()
.endpoint(endpoint + "tags/")
.payload(payloadFromResourceWithContentType("/tags-create-request.json", MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/tags-create-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/tags-create-single.json", MediaType.APPLICATION_JSON))
+ .build());
Tag result = api.createTag(new Tag.Builder()
.name("TagCreatedWithResource")
.resources(ImmutableList.of(
- new TagResource.Builder().uuid("61bcc398-c034-42f1-81c9-f6d7f62c4ea0").build()
- , new TagResource.Builder().uuid("8ac6ac13-a55e-4b01-bcf4-5eed7b60a3ed").build()
- , new TagResource.Builder().uuid("3610d935-514a-4552-acf3-a40dd0a5f961").build()
- , new TagResource.Builder().uuid("185.12.6.183").build()
- , new TagResource.Builder().uuid("96537817-f4b6-496b-a861-e74192d3ccb0").build()
+ new TagResource.Builder().uuid("61bcc398-c034-42f1-81c9-f6d7f62c4ea0").build(),
+ new TagResource.Builder().uuid("8ac6ac13-a55e-4b01-bcf4-5eed7b60a3ed").build(),
+ new TagResource.Builder().uuid("3610d935-514a-4552-acf3-a40dd0a5f961").build(),
+ new TagResource.Builder().uuid("185.12.6.183").build(),
+ new TagResource.Builder().uuid("96537817-f4b6-496b-a861-e74192d3ccb0").build()
))
.build());
assertNotNull(result);
@@ -1375,9 +1385,9 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
deleteBuilder()
.endpoint(endpoint + "tags/" + uuid + "/")
- .build()
- , responseBuilder()
- .build());
+ .build(),
+ responseBuilder()
+ .build());
api.deleteTag(uuid);
}
@@ -1387,28 +1397,28 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "tags/")
- .payload(payloadFromResourceWithContentType("/tags-create-multiple-request.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/tags-detail.json", MediaType.APPLICATION_JSON))
- .build());
+ .payload(payloadFromResourceWithContentType("/tags-create-multiple-request.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/tags-detail.json", MediaType.APPLICATION_JSON))
+ .build());
List<Tag> result = api.createTags(ImmutableList.of(
new Tag.Builder()
.name("new tag")
.resources(ImmutableList.of(new TagResource.Builder().uuid("185.12.6.183").build()))
- .build()
- , new Tag.Builder()
- .name("TagCreatedWithResource")
- .resources(ImmutableList.of(
- new TagResource.Builder().uuid("61bcc398-c034-42f1-81c9-f6d7f62c4ea0").build()
- , new TagResource.Builder().uuid("8ac6ac13-a55e-4b01-bcf4-5eed7b60a3ed").build()
- , new TagResource.Builder().uuid("3610d935-514a-4552-acf3-a40dd0a5f961").build()
- , new TagResource.Builder().uuid("185.12.6.183").build()
- , new TagResource.Builder().uuid("96537817-f4b6-496b-a861-e74192d3ccb0").build()
- ))
- .build()));
+ .build(),
+ new Tag.Builder()
+ .name("TagCreatedWithResource")
+ .resources(ImmutableList.of(
+ new TagResource.Builder().uuid("61bcc398-c034-42f1-81c9-f6d7f62c4ea0").build(),
+ new TagResource.Builder().uuid("8ac6ac13-a55e-4b01-bcf4-5eed7b60a3ed").build(),
+ new TagResource.Builder().uuid("3610d935-514a-4552-acf3-a40dd0a5f961").build(),
+ new TagResource.Builder().uuid("185.12.6.183").build(),
+ new TagResource.Builder().uuid("96537817-f4b6-496b-a861-e74192d3ccb0").build()))
+ .build()));
+
assertNotNull(result);
}
@@ -1417,10 +1427,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "profile/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/profile.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/profile.json", MediaType.APPLICATION_JSON))
+ .build());
ProfileInfo result = api.getProfileInfo();
assertNotNull(result);
@@ -1432,10 +1442,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
putBuilder()
.endpoint(endpoint + "profile/")
.payload(payloadFromResourceWithContentType("/profile-edit-request.json", MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/profile.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/profile.json", MediaType.APPLICATION_JSON))
+ .build());
Map<String, String> meta = new HashMap<String, String>();
meta.put("description", "profile info");
@@ -1481,10 +1491,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "balance/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/balance.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/balance.json", MediaType.APPLICATION_JSON))
+ .build());
AccountBalance result = api.getAccountBalance();
assertNotNull(result);
@@ -1495,10 +1505,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "currentusage/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/currentusage.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/currentusage.json", MediaType.APPLICATION_JSON))
+ .build());
CurrentUsage result = api.getCurrentUsage();
assertNotNull(result);
@@ -1509,18 +1519,20 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestsSendResponses(
getBuilder()
.endpoint(endpoint + "subscriptions/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/subscriptions-first-page.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "subscriptions/")
- .addQueryParam("limit", "2")
- .addQueryParam("offset", "2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/subscriptions-last-page.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/subscriptions-first-page.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ getBuilder()
+ .endpoint(endpoint + "subscriptions/")
+ .addQueryParam("limit", "2")
+ .addQueryParam("offset", "2")
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/subscriptions-last-page.json",
+ MediaType.APPLICATION_JSON))
+ .build());
List<Subscription> subscriptions = api.listSubscriptions().concat().toList();
@@ -1535,10 +1547,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "subscriptions/?limit=3&offset=3")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/subscriptions.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/subscriptions.json", MediaType.APPLICATION_JSON))
+ .build());
for (Subscription subscription : api.listSubscriptions(new PaginationOptions.Builder()
.limit(3)
@@ -1549,58 +1561,15 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
}
@Test
- public void testListSubscriptionsCalculator() throws Exception {
- CloudSigma2Api api = requestsSendResponses(
- getBuilder()
- .endpoint(endpoint + "subscriptioncalculator/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/subscriptions-first-page.json", MediaType.APPLICATION_JSON))
- .build()
- , getBuilder()
- .endpoint(endpoint + "subscriptioncalculator/")
- .addQueryParam("limit", "2")
- .addQueryParam("offset", "2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/subscriptions-last-page.json", MediaType.APPLICATION_JSON))
- .build());
-
- List<Subscription> subscriptions = api.listSubscriptionsCalculator().concat().toList();
-
- Assert.assertEquals(subscriptions.size(), 3);
- Assert.assertEquals(subscriptions.get(0).getUuid(), "509f8e27-1e64-49bb-aa5a-baec074b0210");
- Assert.assertEquals(subscriptions.get(1).getUuid(), "c2423c1a-8768-462c-bdc3-4ca09c1e650b");
- Assert.assertEquals(subscriptions.get(2).getUuid(), "9bb117d3-4bc5-4e2d-a907-b20abd48eaf9");
- }
-
- @Test
- public void testListSubscriptionsCalculatorPaginatedCollection() throws Exception {
- CloudSigma2Api api = requestSendsResponse(
- getBuilder()
- .endpoint(endpoint + "subscriptioncalculator/?limit=2&offset=2")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/subscriptions.json", MediaType.APPLICATION_JSON))
- .build());
-
- for (Subscription subscription : api.listSubscriptionsCalculator(new PaginationOptions.Builder()
- .limit(2)
- .offset(2)
- .build())) {
- assertNotNull(subscription);
- }
- }
-
- @Test
public void testGetSubscription() throws Exception {
CloudSigma2Api api = requestSendsResponse(
getBuilder()
.endpoint(endpoint + "subscriptions/5551/")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/subscriptions-single-get.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/subscriptions-single-get.json",
+ MediaType.APPLICATION_JSON))
+ .build());
Subscription result = api.getSubscription("5551");
assertNotNull(result);
@@ -1611,12 +1580,12 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "subscriptions/")
- .payload(payloadFromResourceWithContentType("/subscriptions-create-request.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/subscriptions-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .payload(payloadFromResourceWithContentType("/subscriptions-create-request.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/subscriptions-single.json", MediaType.APPLICATION_JSON))
+ .build());
Subscription result = api.createSubscription(new CreateSubscriptionRequest.Builder()
.resource(SubscriptionResource.DSSD)
@@ -1631,29 +1600,30 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "subscriptions/")
- .payload(payloadFromResourceWithContentType("/subscriptions-create-multiple-request.json"
- , MediaType.APPLICATION_JSON))
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/subscriptions.json", MediaType.APPLICATION_JSON))
- .build());
+ .payload(payloadFromResourceWithContentType("/subscriptions-create-multiple-request.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/subscriptions.json", MediaType.APPLICATION_JSON))
+ .build());
List<Subscription> result = api.createSubscriptions(ImmutableList.of(
new CreateSubscriptionRequest.Builder()
.resource(SubscriptionResource.DSSD)
.period("1 month")
.amount("30000")
- .build()
- , new CreateSubscriptionRequest.Builder()
- .resource(SubscriptionResource.MEM)
- .period("3 months")
- .amount("30000")
- .build()
- , new CreateSubscriptionRequest.Builder()
- .resource(SubscriptionResource.IP)
- .period("1 year")
- .amount("30000")
- .build()));
+ .build(),
+ new CreateSubscriptionRequest.Builder()
+ .resource(SubscriptionResource.MEM)
+ .period("3 months")
+ .amount("30000")
+ .build(),
+ new CreateSubscriptionRequest.Builder()
+ .resource(SubscriptionResource.IP)
+ .period("1 year")
+ .amount("30000")
+ .build()));
+
assertNotNull(result);
}
@@ -1663,10 +1633,10 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "subscriptions/" + uuid + "/action/?do=extend")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/subscriptions-single.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/subscriptions-single.json", MediaType.APPLICATION_JSON))
+ .build());
api.extendSubscription(uuid);
}
@@ -1677,23 +1647,67 @@ public class CloudSigma2ApiExpectTest extends BaseRestApiExpectTest<CloudSigma2A
CloudSigma2Api api = requestSendsResponse(
postBuilder()
.endpoint(endpoint + "subscriptions/" + uuid + "/action/?do=auto_renew")
- .build()
- , responseBuilder()
- .payload(payloadFromResourceWithContentType("/pricing.json", MediaType.APPLICATION_JSON))
- .build());
+ .build(),
+ responseBuilder()
+ .payload(payloadFromResourceWithContentType("/pricing.json", MediaType.APPLICATION_JSON))
+ .build());
api.enableSubscriptionAutorenew(uuid);
}
@Test
+ public void testCalculateSubscriptions() throws Exception {
+ List<CalcSubscription> subscriptionsToCalculate = ImmutableList.of(
+ new CalcSubscription.Builder()
+ .amount(1)
+ .resource(SubscriptionResource.IP)
+ .endTime(new Date(1388145600000l))
+ .price(5.5)
+ .startTime(new Date(1385547361440l))
+ .build(),
+ new CalcSubscription.Builder()
+ .amount(1)
+ .resource(SubscriptionResource.VLAN)
+ .endTime(new Date(1388145600000l))
+ .price(11)
+ .startTime(new Date(1385547361440l))
+ .build(),
+ new CalcSubscription.Builder()
+ .amount(250)
+ .resource(SubscriptionResource.CPU)
+ .endTime(new Date(1388145600000l))
+ .price(3.366)
+ .startTime(new Date(1385547361440l))
+ .build());
+
+ CloudSigma2Api api = requestSendsResponse(
+ postBuilder()
+ .endpoint(endpoint + "subscriptioncalculator/")
+ .payload(payloadFromResourceWithContentType("/subscriptioncalculator-request.json",
+ MediaType.APPLICATION_JSON))
+ .build(),
+
<TRUNCATED>