@Test public void testImportKey() { String keyName = "key-name"; String publicKeyMaterial = "public-key-material"; String keyNameResult = "key-name-result"; when(ec2Client.importKeyPair(new ImportKeyPairRequest(keyName, publicKeyMaterial))) .thenReturn(new ImportKeyPairResult().withKeyName(keyNameResult)); // invoke method under test String result = ec2Service.importKey(keyName, publicKeyMaterial); assertEquals(keyNameResult, result); }
@Override public KeyPair importKeyPair(ImportKeyPairRequest request, ResultCapture<ImportKeyPairResult> extractor) { ActionResult result = service.performAction("ImportKeyPair", request, extractor); if (result == null) return null; return new KeyPairImpl(result.getResource()); }
@Override public KeyPair importKeyPair(String publicKeyMaterial, String keyName, ResultCapture<ImportKeyPairResult> extractor) { ImportKeyPairRequest request = new ImportKeyPairRequest() .withPublicKeyMaterial(publicKeyMaterial) .withKeyName(keyName); return importKeyPair(request, extractor); }
@Override public ImportKeyPairResult importKeyPair(ImportKeyPairRequest importKeyPairRequest) throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException("Not supported in mock"); }
@Override public KeyPair importKeyPair(String publicKeyMaterial, String keyName) { return importKeyPair(publicKeyMaterial, keyName, (ResultCapture<ImportKeyPairResult>)null); }
private void importPoolPublicKeyPair(AmazonEC2 client, String keyName, String publicKey) { ImportKeyPairResult result = client.importKeyPair(new ImportKeyPairRequest() .withKeyName(keyName).withPublicKeyMaterial(publicKey)); LOG.info("<< Created remote key with fingerprint {}", result.getKeyFingerprint()); }
/** * Import a key pair to AWS EC2. * * @param keyName Friendly name for the key * @param publicKeyMaterial Public key * @return Key name */ public String importKey(final String keyName, final String publicKeyMaterial) { final ImportKeyPairRequest request = new ImportKeyPairRequest(keyName, publicKeyMaterial); final ImportKeyPairResult result = ec2Client.importKeyPair(request); return result.getKeyName(); }
/** * Performs the <code>ImportKeyPair</code> action and use a ResultCapture to * retrieve the low-level client response. * * <p> * * @return The <code>KeyPair</code> resource object associated with the * result of this action. * @see ImportKeyPairRequest */ com.amazonaws.resources.ec2.KeyPair importKeyPair(ImportKeyPairRequest request, ResultCapture<ImportKeyPairResult> extractor);
/** * The convenient method form for the <code>ImportKeyPair</code> action. * * @see #importKeyPair(ImportKeyPairRequest, ResultCapture) */ com.amazonaws.resources.ec2.KeyPair importKeyPair(String publicKeyMaterial, String keyName, ResultCapture<ImportKeyPairResult> extractor);