From 9966eb68c9ca7bfd8d78884fcd479ec8166bbc1f Mon Sep 17 00:00:00 2001 From: Jason King Date: Fri, 9 Sep 2011 10:36:25 +0100 Subject: [PATCH 1/3] Issue 158: Updated links to softlayer documentation as URLs have changed --- .../main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java | 2 +- .../src/main/java/org/jclouds/softlayer/SoftLayerClient.java | 2 +- .../src/main/java/org/jclouds/softlayer/domain/Datacenter.java | 2 +- .../main/java/org/jclouds/softlayer/domain/VirtualGuest.java | 2 +- .../org/jclouds/softlayer/features/DatacenterAsyncClient.java | 2 +- .../java/org/jclouds/softlayer/features/DatacenterClient.java | 2 +- .../jclouds/softlayer/features/ProductPackageAsyncClient.java | 2 +- .../org/jclouds/softlayer/features/ProductPackageClient.java | 2 +- .../org/jclouds/softlayer/features/VirtualGuestAsyncClient.java | 2 +- .../java/org/jclouds/softlayer/features/VirtualGuestClient.java | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java index b1e022b6a2..c301977b7a 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java @@ -29,7 +29,7 @@ import org.jclouds.softlayer.features.VirtualGuestAsyncClient; *

* * @see SoftLayerClient - * @see + * @see * @author Adrian Cole */ public interface SoftLayerAsyncClient { diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java index adc64ec552..1656ff1c8e 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java @@ -32,7 +32,7 @@ import org.jclouds.softlayer.features.VirtualGuestClient; *

* * @see SoftLayerAsyncClient - * @see + * @see * @author Adrian Cole */ @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java index fe105fc989..846f47e209 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java @@ -21,7 +21,7 @@ package org.jclouds.softlayer.domain; /** * * @author Adrian Cole - * @see */ public class Datacenter implements Comparable { diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java index 8c080da7be..7823d95f0a 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java @@ -34,7 +34,7 @@ import com.google.gson.annotations.SerializedName; * * @author Adrian Cole * @see */ public class VirtualGuest implements Comparable { diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java index 5abb61e874..37efa6a48f 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java @@ -41,7 +41,7 @@ import com.google.common.util.concurrent.ListenableFuture; *

* * @see DatacenterClient - * @see + * @see * @author Adrian Cole */ @RequestFilters(BasicAuthentication.class) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java index b8ca23ac25..33fbf75111 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java @@ -29,7 +29,7 @@ import org.jclouds.softlayer.domain.Datacenter; *

* * @see DatacenterAsyncClient - * @see + * @see * @author Adrian Cole */ @Timeout(duration = 4, timeUnit = TimeUnit.SECONDS) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java index e7805cda98..da7b7bcd95 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java @@ -38,7 +38,7 @@ import com.google.common.util.concurrent.ListenableFuture; *

* * @see ProductPackageClient - * @see + * @see * @author Adrian Cole */ @RequestFilters(BasicAuthentication.class) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java index dbc6af02a3..09339ba18b 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java @@ -28,7 +28,7 @@ import org.jclouds.softlayer.domain.ProductPackage; *

* * @see ProductPackageAsyncClient - * @see + * @see * @author Adrian Cole */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java index c7d7ded984..78f327b97b 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java @@ -42,7 +42,7 @@ import com.google.common.util.concurrent.ListenableFuture; *

* * @see VirtualGuestClient - * @see + * @see * @author Adrian Cole */ @RequestFilters(BasicAuthentication.class) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java index 8d969355c6..7554e40984 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java @@ -29,7 +29,7 @@ import org.jclouds.softlayer.domain.VirtualGuest; *

* * @see VirtualGuestAsyncClient - * @see + * @see * @author Adrian Cole */ @Timeout(duration = 4, timeUnit = TimeUnit.SECONDS) From bf3674263911e6acefa8890b7f97691030e195ab Mon Sep 17 00:00:00 2001 From: Jason King Date: Fri, 9 Sep 2011 10:37:39 +0100 Subject: [PATCH 2/3] Issue 158: Removed unused method from ProductPackage --- .../java/org/jclouds/softlayer/domain/ProductPackage.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java index cb9ce12223..a6cd14ad6a 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java @@ -65,11 +65,6 @@ public class ProductPackage implements Comparable { return this; } - public Builder productItem(ProductItem items) { - this.items.add(checkNotNull(items, "items")); - return this; - } - public Builder items(Iterable items) { this.items = ImmutableSet. copyOf(checkNotNull(items, "items")); return this; From cd70eefc6d9d4afecf7b35b670e1ad2c195cebd8 Mon Sep 17 00:00:00 2001 From: Jason King Date: Fri, 9 Sep 2011 10:54:49 +0100 Subject: [PATCH 3/3] Issue 158 Return Datacenter (location) information with ProductPackage --- .../jclouds/softlayer/domain/Datacenter.java | 2 +- .../softlayer/domain/ProductPackage.java | 39 ++++++++++++++----- .../features/ProductPackageAsyncClient.java | 17 ++++---- .../ProductPackageAsyncClientTest.java | 2 +- .../ProductPackageClientLiveTest.java | 12 ++++++ 5 files changed, 51 insertions(+), 21 deletions(-) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java index 846f47e209..be58688ac3 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java @@ -21,7 +21,7 @@ package org.jclouds.softlayer.domain; /** * * @author Adrian Cole - * @see */ public class Datacenter implements Comparable { diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java index a6cd14ad6a..c8c43ab0cc 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java @@ -18,19 +18,19 @@ */ package org.jclouds.softlayer.domain; -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; import java.util.Set; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; +import static com.google.common.base.Preconditions.checkNotNull; /** * The SoftLayer_Product_Package data type contains information about packages * from which orders can be generated. Packages contain general information * regarding what is in them, where they are currently sold, availability, and * pricing. - * + * * @author Adrian Cole * @see { private String name; private String description; private Set items = Sets.newLinkedHashSet(); + private Set datacenters = Sets.newLinkedHashSet(); public Builder id(long id) { this.id = id; @@ -70,13 +71,21 @@ public class ProductPackage implements Comparable { return this; } + public Builder datacenters(Iterable datacenters) { + this.datacenters = ImmutableSet. copyOf(checkNotNull(datacenters, "datacenters")); + return this; + } + public ProductPackage build() { - return new ProductPackage(id, name, description, items); + return new ProductPackage(id, name, description, items, datacenters); } public static Builder fromProductPackage(ProductPackage in) { - return ProductPackage.builder().id(in.getId()).name(in.getName()).description(in.getDescription()) - .items(in.getItems()); + return ProductPackage.builder().id(in.getId()) + .name(in.getName()) + .description(in.getDescription()) + .items(in.getItems()) + .datacenters(in.getDatacenters()); } } @@ -84,17 +93,19 @@ public class ProductPackage implements Comparable { private String name; private String description; private Set items = Sets.newLinkedHashSet(); + private Set locations = Sets.newLinkedHashSet(); // for deserializer ProductPackage() { } - public ProductPackage(long id, String name, String description, Iterable items) { + public ProductPackage(long id, String name, String description, Iterable items, Iterable datacenters) { this.id = id; this.name = name; this.description = description; this.items = ImmutableSet. copyOf(checkNotNull(items, "items")); + this.locations = ImmutableSet. copyOf(checkNotNull(datacenters, "datacenters")); } @Override @@ -128,7 +139,7 @@ public class ProductPackage implements Comparable { } /** - * + * * @return A collection of valid items available for purchase in this * package. */ @@ -136,6 +147,14 @@ public class ProductPackage implements Comparable { return items; } + /** + * + * @return A collection of valid locations for this package. + */ + public Set getDatacenters() { + return locations; + } + public Builder toBuilder() { return Builder.fromProductPackage(this); } @@ -164,6 +183,6 @@ public class ProductPackage implements Comparable { @Override public String toString() { - return "ProductPackage [id=" + id + ", name=" + name + ", description=" + description + ", items=" + items + "]"; + return "ProductPackage [id=" + id + ", name=" + name + ", description=" + description + ", items=" + items + ", datacenters=" + locations + "]"; } } diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java index da7b7bcd95..f060993a5c 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java @@ -18,12 +18,7 @@ */ package org.jclouds.softlayer.features; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - +import com.google.common.util.concurrent.ListenableFuture; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.QueryParams; @@ -31,12 +26,16 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.softlayer.domain.ProductPackage; -import com.google.common.util.concurrent.ListenableFuture; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; /** * Provides asynchronous access to ProductPackage via their REST API. *

- * + * * @see ProductPackageClient * @see * @author Adrian Cole @@ -44,7 +43,7 @@ import com.google.common.util.concurrent.ListenableFuture; @RequestFilters(BasicAuthentication.class) @Path("/v{jclouds.api-version}") public interface ProductPackageAsyncClient { - public static String PRODUCT_MASK = "items"; + public static String PRODUCT_MASK = "items;locations"; /** * @see ProductPackageClient#getProductPackage diff --git a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java index 90dd1fa6a7..faae225fba 100644 --- a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java +++ b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java @@ -43,7 +43,7 @@ public class ProductPackageAsyncClientTest extends BaseSoftLayerAsyncClientTest< assertRequestLineEquals( httpRequest, - "GET https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/1234.json?objectMask=items HTTP/1.1"); + "GET https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/1234.json?objectMask=items%3Blocations HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertPayloadEquals(httpRequest, null, null, false); diff --git a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java index 353d479b13..32ded9be2c 100644 --- a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java +++ b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java @@ -20,6 +20,7 @@ package org.jclouds.softlayer.features; import static org.testng.Assert.assertTrue; +import org.jclouds.softlayer.domain.Datacenter; import org.jclouds.softlayer.domain.ProductItem; import org.jclouds.softlayer.domain.ProductItemPrice; import org.jclouds.softlayer.domain.ProductPackage; @@ -57,6 +58,11 @@ public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest { // assertEquals(item.getId(), newDetails.getId()); checkProductItem(item); } + + assertTrue(response.getDatacenters().size() > 0); + for (Datacenter datacenter : response.getDatacenters()) { + checkDatacenter(datacenter); + } } } @@ -81,4 +87,10 @@ public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest { assert price.getRecurringFee() != null || price.getHourlyRecurringFee() != null : price; } + private void checkDatacenter(Datacenter datacenter) { + assert datacenter.getId() > 0 : datacenter; + assert datacenter.getName() != null : datacenter; + assert datacenter.getLongName() != null : datacenter; + } + }