Vault SSH: Support OTP key type from CLI

This commit is contained in:
Vishal Nayak
2015-07-23 17:20:28 -04:00
parent 795d1a8d40
commit 3a1eaf1869
3 changed files with 28 additions and 47 deletions

View File

@@ -1,9 +1,6 @@
package api
import (
"encoding/json"
"fmt"
)
import "fmt"
// SSH is used to return a client to invoke operations on SSH backend.
type SSH struct {
@@ -40,32 +37,3 @@ func (c *SSH) KeyCreate(role string, data map[string]interface{}) (*Secret, erro
return ParseSecret(resp.Body)
}
// Invokes the SSH backend API to list the roles associated with given IP address.
func (c *SSH) Lookup(data map[string]interface{}) (*SSHRoles, error) {
r := c.c.NewRequest("PUT", "/v1/ssh/lookup")
if err := r.SetJSONBody(data); err != nil {
return nil, err
}
resp, err := c.c.RawRequest(r)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var roles SSHRoles
dec := json.NewDecoder(resp.Body)
if err := dec.Decode(&roles); err != nil {
return nil, err
}
return &roles, nil
}
// Structures for the requests/resposne are all down here. They aren't
// individually documentd because the map almost directly to the raw HTTP API
// documentation. Please refer to that documentation for more details.
type SSHRoles struct {
Data map[string]interface{} `json:"data"`
}