API to add SSH credentials
diff --git a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
index a6063e5..8250687 100644
--- a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
+++ b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
@@ -5,10 +5,7 @@
import org.apache.custos.credential.api.resources.SSHCredential;
import org.dozer.DozerBeanMapper;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
@RestController
public class SSHCredentialsController {
@@ -24,4 +21,11 @@
SSHCredentialEntity credentialEntity = vaultManager.getCredentialEntity(SSHCredentialEntity.class, token, gateway);
return mapper.map(credentialEntity, SSHCredential.class);
}
+
+ @RequestMapping(value = "/ssh/{gateway}", method = RequestMethod.POST)
+ public String createSSHCredential(@RequestBody SSHCredential sshCredential, @PathVariable("gateway") String gateway) throws Exception {
+ SSHCredentialEntity credentialEntity = mapper.map(sshCredential, SSHCredentialEntity.class);
+ String token = vaultManager.saveCredentialEntity(credentialEntity, gateway);
+ return token;
+ }
}