mirror of https://github.com/apache/jclouds.git
Refactor domain object SSHKeyPair to SshKeyPair
This commit is contained in:
parent
f7799c22ad
commit
e1d41bd8b6
|
@ -25,7 +25,7 @@ import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.SSHKeyPair;
|
import org.jclouds.cloudstack.domain.SshKeyPair;
|
||||||
import org.jclouds.cloudstack.filters.QuerySigner;
|
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions;
|
import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
@ -52,13 +52,13 @@ public interface SSHKeyPairAsyncClient {
|
||||||
@SelectJson("keypair")
|
@SelectJson("keypair")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
ListenableFuture<Set<SSHKeyPair>> listSSHKeyPairs(ListSSHKeyPairsOptions... options);
|
ListenableFuture<Set<SshKeyPair>> listSSHKeyPairs(ListSSHKeyPairsOptions... options);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@QueryParams(keys = "command", values = "createSSHKeyPair")
|
@QueryParams(keys = "command", values = "createSSHKeyPair")
|
||||||
@SelectJson("keypair")
|
@SelectJson("keypair")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
ListenableFuture<SSHKeyPair> createSSHKeyPair(@QueryParam("name") String name);
|
ListenableFuture<SshKeyPair> createSSHKeyPair(@QueryParam("name") String name);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@QueryParams(keys = "command", values = "listSSHKeyPairs")
|
@QueryParams(keys = "command", values = "listSSHKeyPairs")
|
||||||
|
@ -66,6 +66,6 @@ public interface SSHKeyPairAsyncClient {
|
||||||
@OnlyElement()
|
@OnlyElement()
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<SSHKeyPair> getSSHKeyPair(@QueryParam("name") String name);
|
ListenableFuture<SshKeyPair> getSSHKeyPair(@QueryParam("name") String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.jclouds.cloudstack.features;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.SSHKeyPair;
|
import org.jclouds.cloudstack.domain.SshKeyPair;
|
||||||
import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions;
|
import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ import org.jclouds.concurrent.Timeout;
|
||||||
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface SSHKeyPairClient {
|
public interface SSHKeyPairClient {
|
||||||
|
|
||||||
Set<SSHKeyPair> listSSHKeyPairs(ListSSHKeyPairsOptions... options);
|
Set<SshKeyPair> listSSHKeyPairs(ListSSHKeyPairsOptions... options);
|
||||||
|
|
||||||
SSHKeyPair createSSHKeyPair(String name);
|
SshKeyPair createSSHKeyPair(String name);
|
||||||
|
|
||||||
SSHKeyPair getSSHKeyPair(String name);
|
SshKeyPair getSSHKeyPair(String name);
|
||||||
}
|
}
|
|
@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.SSHKeyPair;
|
import org.jclouds.cloudstack.domain.SshKeyPair;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,18 +34,18 @@ import org.testng.annotations.Test;
|
||||||
public class SSHKeyPairClientLiveTest extends BaseCloudStackClientLiveTest {
|
public class SSHKeyPairClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
public void testListSSHKeyPairs() {
|
public void testListSSHKeyPairs() {
|
||||||
final Set<SSHKeyPair> sshKeyPairs = client.getSSHKeyPairClient().listSSHKeyPairs();
|
final Set<SshKeyPair> sshKeyPairs = client.getSSHKeyPairClient().listSSHKeyPairs();
|
||||||
for (SSHKeyPair sshKeyPair : sshKeyPairs) {
|
for (SshKeyPair sshKeyPair : sshKeyPairs) {
|
||||||
checkSSHKeyPair(sshKeyPair);
|
checkSSHKeyPair(sshKeyPair);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateSSHKeyPair() {
|
public void testCreateSSHKeyPair() {
|
||||||
final SSHKeyPair sshKeyPair = client.getSSHKeyPairClient().createSSHKeyPair("jclouds-keypair");
|
final SshKeyPair sshKeyPair = client.getSSHKeyPairClient().createSSHKeyPair("jclouds-keypair");
|
||||||
System.out.println(sshKeyPair);
|
System.out.println(sshKeyPair);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkSSHKeyPair(SSHKeyPair pair) {
|
protected void checkSSHKeyPair(SshKeyPair pair) {
|
||||||
assert pair.getName() != null : pair;
|
assert pair.getName() != null : pair;
|
||||||
assertEquals(pair.toString(), client.getSSHKeyPairClient().getSSHKeyPair(pair.getName()).toString());
|
assertEquals(pair.toString(), client.getSSHKeyPairClient().getSSHKeyPair(pair.getName()).toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.jclouds.cloudstack.parse;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.config.CloudStackParserModule;
|
import org.jclouds.cloudstack.config.CloudStackParserModule;
|
||||||
import org.jclouds.cloudstack.domain.SSHKeyPair;
|
import org.jclouds.cloudstack.domain.SshKeyPair;
|
||||||
import org.jclouds.json.BaseSetParserTest;
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
@ -35,7 +35,7 @@ import com.google.inject.Injector;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit")
|
||||||
public class ListSSHKeyPairsResponseTest extends BaseSetParserTest<SSHKeyPair> {
|
public class ListSSHKeyPairsResponseTest extends BaseSetParserTest<SshKeyPair> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Injector injector() {
|
protected Injector injector() {
|
||||||
|
@ -58,8 +58,8 @@ public class ListSSHKeyPairsResponseTest extends BaseSetParserTest<SSHKeyPair> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SelectJson("keypair")
|
@SelectJson("keypair")
|
||||||
public Set<SSHKeyPair> expected() {
|
public Set<SshKeyPair> expected() {
|
||||||
return ImmutableSet.<SSHKeyPair> of(SSHKeyPair.builder().name("jclouds-keypair")
|
return ImmutableSet.<SshKeyPair> of(SshKeyPair.builder().name("jclouds-keypair")
|
||||||
.fingerprint("43:6a:bd:46:e0:3d:3a:8d:ab:69:25:bb:b9:ca:9d:17").build());
|
.fingerprint("43:6a:bd:46:e0:3d:3a:8d:ab:69:25:bb:b9:ca:9d:17").build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue