-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathssh_keys.go
More file actions
33 lines (29 loc) · 856 Bytes
/
ssh_keys.go
File metadata and controls
33 lines (29 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package cloud66
import (
"encoding/base64"
)
type AccessPublicKey struct {
Key string `json:"public_key"`
}
// GetAccessPublicKey gets the access public key for the currently authenticated user
func (c *Client) GetAccessPublicKey() (*AccessPublicKey, error) {
req, err := c.NewRequest("GET", "/ssh_keys/access.json", nil, nil)
if err != nil {
return nil, err
}
var key *AccessPublicKey
return key, c.DoReq(req, &key, nil)
}
// SetAccessPublicKey sets the access public key for the currently authenticated user
func (c *Client) SetAccessPublicKey(publicKey string) error {
params := struct {
PublicKey string `json:"public_key"`
}{
PublicKey: base64.StdEncoding.EncodeToString([]byte(publicKey)),
}
req, err := c.NewRequest("POST", "/ssh_keys/access.json", params, nil)
if err != nil {
return err
}
return c.DoReq(req, nil, nil)
}