diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java index 876dd7f3f4..c523274e30 100644 --- a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java @@ -31,8 +31,10 @@ import org.jclouds.cloudstack.filters.QuerySigner; import org.jclouds.cloudstack.options.CreateIPForwardingRuleOptions; import org.jclouds.cloudstack.options.ListIPForwardingRulesOptions; import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; @@ -56,7 +58,7 @@ public interface NATAsyncClient { */ @GET @QueryParams(keys = "command", values = "listIpForwardingRules") - @Unwrap(depth = 2) + @SelectJson("ipforwardingrule") @Consumes(MediaType.APPLICATION_JSON) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) ListenableFuture> listIPForwardingRules(ListIPForwardingRulesOptions... options); @@ -66,7 +68,8 @@ public interface NATAsyncClient { */ @GET @QueryParams(keys = "command", values = "listIpForwardingRules") - @Unwrap(depth = 3, edgeCollection = Set.class) + @SelectJson("ipforwardingrule") + @OnlyElement @Consumes(MediaType.APPLICATION_JSON) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture getIPForwardingRule(@QueryParam("id") long id); diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java index b7b8367497..415b9f7243 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java @@ -24,6 +24,7 @@ import java.lang.reflect.Method; import org.jclouds.cloudstack.options.CreateIPForwardingRuleOptions; import org.jclouds.cloudstack.options.ListIPForwardingRulesOptions; import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue; import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet; @@ -53,7 +54,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest { + + @Override + public String resource() { + return "/listipforwardingrulesresponse.json"; + } + + @Override + @SelectJson("ipforwardingrule") + public Set expected() { + return ImmutableSet. of( + IPForwardingRule.builder().id(66).protocol("tcp").startPort(22).endPort(22).virtualMachineId(58) + .virtualMachineDisplayName("i-4-58-VM").virtualMachineName("i-4-58-VM") + .IPAddressId(15).IPAddress("10.27.27.64").state("Active").build()); + } + +} diff --git a/sandbox-apis/cloudstack/src/test/resources/listipforwardingrulesresponse.json b/sandbox-apis/cloudstack/src/test/resources/listipforwardingrulesresponse.json new file mode 100644 index 0000000000..984f6ee4b6 --- /dev/null +++ b/sandbox-apis/cloudstack/src/test/resources/listipforwardingrulesresponse.json @@ -0,0 +1,17 @@ +{ + "listipforwardingrulesresponse": { + "count": 1, + "ipforwardingrule": [{ + "id": 66, + "protocol": "tcp", + "virtualmachineid": 58, + "virtualmachinename": "i-4-58-VM", + "virtualmachinedisplayname": "i-4-58-VM", + "ipaddressid": 15, + "ipaddress": "10.27.27.64", + "startport": 22, + "endport": 22, + "state": "Active" + }] + } +}