add disable static nat

This commit is contained in:
Adrian Cole 2011-11-15 18:29:14 +02:00
parent 90dfed8583
commit 2d31d6db23
3 changed files with 41 additions and 3 deletions

View File

@ -38,6 +38,7 @@ import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.annotations.Unwrap; import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -129,4 +130,13 @@ public interface NATAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Long> deleteIPForwardingRule(@QueryParam("id") long id); ListenableFuture<Long> deleteIPForwardingRule(@QueryParam("id") long id);
/**
* @see NATClient#disableStaticNat
*/
@GET
@QueryParams(keys = "command", values = "disableStaticNat")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
ListenableFuture<Void> disableStaticNat(@QueryParam("ipaddressid") long IPAddressId);
} }

View File

@ -44,8 +44,8 @@ public interface NATClient {
* *
* @param options * @param options
* if present, how to constrain the list. * if present, how to constrain the list.
* @return IPForwardingRulees matching query, or empty set, if no * @return IPForwardingRules matching query, or empty set, if no
* IPForwardingRulees are found * IPForwardingRules are found
*/ */
Set<IPForwardingRule> listIPForwardingRules(ListIPForwardingRulesOptions... options); Set<IPForwardingRule> listIPForwardingRules(ListIPForwardingRulesOptions... options);
@ -100,4 +100,13 @@ public interface NATClient {
Long deleteIPForwardingRule(long id); Long deleteIPForwardingRule(long id);
AsyncCreateResponse enableStaticNATForVirtualMachine(long virtualMachineId, long IPAddressId); 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);
} }

View File

@ -25,11 +25,13 @@ import org.jclouds.cloudstack.options.CreateIPForwardingRuleOptions;
import org.jclouds.cloudstack.options.ListIPForwardingRulesOptions; import org.jclouds.cloudstack.options.ListIPForwardingRulesOptions;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue; import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -153,6 +155,23 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
} }
public void testDisableStaticNAT() throws SecurityException, NoSuchMethodException, IOException {
Method method = NATAsyncClient.class.getMethod("disableStaticNat", long.class);
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=disableStaticNat&ipaddressid=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
checkFilters(httpRequest);
}
public void testDeleteIPForwardingRule() throws SecurityException, NoSuchMethodException, IOException { public void testDeleteIPForwardingRule() throws SecurityException, NoSuchMethodException, IOException {
Method method = NATAsyncClient.class.getMethod("deleteIPForwardingRule", long.class); Method method = NATAsyncClient.class.getMethod("deleteIPForwardingRule", long.class);
HttpRequest httpRequest = processor.createRequest(method, 5); HttpRequest httpRequest = processor.createRequest(method, 5);