diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClient.java
index 8a1a499a48..cb6afd06df 100644
--- a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClient.java
+++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClient.java
@@ -35,17 +35,23 @@ import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
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;
+/**
+ * Provides asynchronous access to CloudStack SSHKeyPair features.
+ *
+ * @author Vijay Kiran
+ * @see
+ */
@RequestFilters(QuerySigner.class)
@QueryParams(keys = "response", values = "json")
-/**
- * @author Vijay Kiran
- */
public interface SSHKeyPairAsyncClient {
/**
- * @see org.jclouds.cloudstack.features.SSHKeyPairClient#listSSHKeyPairs
+ * @see SSHKeyPairClient#listSSHKeyPairs
*/
@GET
@QueryParams(keys = "command", values = "listSSHKeyPairs")
@@ -54,12 +60,18 @@ public interface SSHKeyPairAsyncClient {
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture> listSSHKeyPairs(ListSSHKeyPairsOptions... options);
+ /**
+ * @see SSHKeyPairClient#createSSHKeyPair
+ */
@GET
@QueryParams(keys = "command", values = "createSSHKeyPair")
@SelectJson("keypair")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture createSSHKeyPair(@QueryParam("name") String name);
+ /**
+ * @see SSHKeyPairClient#getSSHKeyPair
+ */
@GET
@QueryParams(keys = "command", values = "listSSHKeyPairs")
@SelectJson("keypair")
@@ -68,4 +80,12 @@ public interface SSHKeyPairAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture getSSHKeyPair(@QueryParam("name") String name);
+ /**
+ * @see SSHKeyPairClient#deleteSSHKeyPair
+ */
+ @GET
+ @QueryParams(keys = "command", values = "deleteSSHKeyPair")
+ @ExceptionParser(ReturnVoidOnNotFoundOr404.class)
+ ListenableFuture deleteSSHKeyPair(@QueryParam("name") String name);
+
}
diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairClient.java
index f3debaccee..88497c37c6 100644
--- a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairClient.java
+++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairClient.java
@@ -28,19 +28,49 @@ import org.jclouds.concurrent.Timeout;
/**
* Provides synchronous access to CloudStack SSHKeyPair features.
- *
*
- * @author Vijay Kiran
- * @see
+ * @author Vijay Kiran
*/
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
public interface SSHKeyPairClient {
-
+ /**
+ * Returns a list of {@link SshKeyPair}s registered by current user.
+ *
+ * @param options
+ * if present, how to constrain the list
+ * @return Set of {@link SshKeyPair}s matching the current constrains or
+ * empty set if no SshKeyPairs found.
+ */
Set listSSHKeyPairs(ListSSHKeyPairsOptions... options);
+ /**
+ * Creates a {@link SshKeyPair} with specified name.
+ *
+ * @param name
+ * of the SshKeyPair.
+ * @return Created SshKeyPair.
+ */
SshKeyPair createSSHKeyPair(String name);
+ /**
+ * Retrieves the {@link SSHKeyPairClient} with given name.
+ *
+ * @param name
+ * name of the key pair
+ * @return SSH Key pair or null if not found.
+ */
SshKeyPair getSSHKeyPair(String name);
+
+ /**
+ * Deletes the {@link SSHKeyPairClient} with given name.
+ *
+ * @param name
+ * name of the key pair
+ * @return
+ */
+ void deleteSSHKeyPair(String name);
+
}
\ No newline at end of file
diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java
index 09c060120d..68086bf13f 100644
--- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java
+++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java
@@ -25,8 +25,10 @@ import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
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;
@@ -93,6 +95,23 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest> createTypeLiteral() {
return new TypeLiteral>() {
diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientLiveTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientLiveTest.java
index 2bc58c21bf..ecefc9cccf 100644
--- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientLiveTest.java
+++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientLiveTest.java
@@ -33,6 +33,9 @@ import org.testng.annotations.Test;
@Test(groups = "live", singleThreaded = true, testName = "SSHKeyPairClientLiveTest")
public class SSHKeyPairClientLiveTest extends BaseCloudStackClientLiveTest {
+ protected String prefix = System.getProperty("user.name");
+ private SshKeyPair sshKeyPair;
+
public void testListSSHKeyPairs() {
final Set sshKeyPairs = client.getSSHKeyPairClient().listSSHKeyPairs();
for (SshKeyPair sshKeyPair : sshKeyPairs) {
@@ -40,9 +43,13 @@ public class SSHKeyPairClientLiveTest extends BaseCloudStackClientLiveTest {
}
}
- public void testCreateSSHKeyPair() {
- final SshKeyPair sshKeyPair = client.getSSHKeyPairClient().createSSHKeyPair("jclouds-keypair");
- System.out.println(sshKeyPair);
+ public void testCreateDeleteSSHKeyPair() {
+ sshKeyPair = client.getSSHKeyPairClient().createSSHKeyPair(prefix + "jclouds-keypair");
+ checkSSHKeyPair(sshKeyPair);
+ client.getSSHKeyPairClient().deleteSSHKeyPair(sshKeyPair.getName());
+ assertEquals(client.getSSHKeyPairClient().getSSHKeyPair(sshKeyPair.getName()), null);
+ // Set the keypair to null , if the delete test is passed.
+ sshKeyPair = null;
}
protected void checkSSHKeyPair(SshKeyPair pair) {