From 2d31d6db2313bab4a372d10c4776a7462ab280be Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 15 Nov 2011 18:29:14 +0200 Subject: [PATCH] add disable static nat --- .../cloudstack/features/NATAsyncClient.java | 12 +++++++++++- .../cloudstack/features/NATClient.java | 13 +++++++++++-- .../features/NATAsyncClientTest.java | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java index 69a59334ac..23a96a5d30 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATAsyncClient.java @@ -38,6 +38,7 @@ import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.Unwrap; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -97,7 +98,7 @@ public interface NATAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture getIPForwardingRuleForVirtualMachine(@QueryParam("virtualmachineid") long id); - + /** * @see NATClient#createIPForwardingRule */ @@ -129,4 +130,13 @@ public interface NATAsyncClient { @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture deleteIPForwardingRule(@QueryParam("id") long id); + /** + * @see NATClient#disableStaticNat + */ + @GET + @QueryParams(keys = "command", values = "disableStaticNat") + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + ListenableFuture disableStaticNat(@QueryParam("ipaddressid") long IPAddressId); + } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATClient.java index b5ebe00e2b..42e7c1c5e6 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NATClient.java @@ -44,8 +44,8 @@ public interface NATClient { * * @param options * if present, how to constrain the list. - * @return IPForwardingRulees matching query, or empty set, if no - * IPForwardingRulees are found + * @return IPForwardingRules matching query, or empty set, if no + * IPForwardingRules are found */ Set listIPForwardingRules(ListIPForwardingRulesOptions... options); @@ -100,4 +100,13 @@ public interface NATClient { Long deleteIPForwardingRule(long id); AsyncCreateResponse enableStaticNATForVirtualMachine(long virtualMachineId, long IPAddressId); + + /** + * Disables static rule for given ip address + * + * @param IPAddressId + * the public IP address id for which static nat feature is being + * disableed + */ + void disableStaticNat(long IPAddressId); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java index 1c62c54a6a..900c706ff2 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java @@ -25,11 +25,13 @@ 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.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -153,6 +155,23 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest