-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathssh.go
41 lines (37 loc) · 884 Bytes
/
ssh.go
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
34
35
36
37
38
39
40
41
package ker
import (
"encoding/json"
"strconv"
)
// ListSshKey returns all sshKey
func (u *User) ListSshKey() (data ApiResponse) {
ret, err := request("listSshKey", nil, u)
if err != nil {
panic(err)
}
json.Unmarshal([]byte(ret), &data)
return data
}
// CreateSshKey creates a sshkey
func (u *User) CreateSshKey(name string, key string) (data ApiResponse) {
b := make(map[string]string)
b["name"] = name
b["key"] = key
ret, err := request("createSshKey", b, u)
if err != nil {
panic(err)
}
json.Unmarshal([]byte(ret), &data)
return data
}
// DeleteSshkey deletes a sshKey by ID
func (u *User) DeleteSshKey(id int) (data ApiResponse) {
d := make(map[string]string)
d["id"] = strconv.Itoa(id)
ret, err := request("createSshKey", d, u)
if err != nil {
panic(err)
}
json.Unmarshal([]byte(ret), &data)
return data
}