This repository has been archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
key.go
80 lines (65 loc) · 1.92 KB
/
key.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// WARNING: This code is auto-generated from the Heroku Platform API JSON Schema
// by a Ruby script (gen/gen.rb). Changes should be made to the generation
// script rather than the generated files.
package heroku
import (
"time"
)
// Keys represent public SSH keys associated with an account and are used to
// authorize accounts as they are performing git operations.
type Key struct {
// comment on the key
Comment string `json:"comment"`
// when key was created
CreatedAt time.Time `json:"created_at"`
// deprecated. Please refer to 'comment' instead
Email string `json:"email"`
// a unique identifying string based on contents
Fingerprint string `json:"fingerprint"`
// unique identifier of this key
Id string `json:"id"`
// full public_key as uploaded
PublicKey string `json:"public_key"`
// when key was updated
UpdatedAt time.Time `json:"updated_at"`
}
// Create a new key.
//
// publicKey is the full public_key as uploaded.
func (c *Client) KeyCreate(publicKey string) (*Key, error) {
params := struct {
PublicKey string `json:"public_key"`
}{
PublicKey: publicKey,
}
var keyRes Key
return &keyRes, c.Post(&keyRes, "/account/keys", params)
}
// Delete an existing key
//
// keyIdentity is the unique identifier of the Key.
func (c *Client) KeyDelete(keyIdentity string) error {
return c.Delete("/account/keys/" + keyIdentity)
}
// Info for existing key.
//
// keyIdentity is the unique identifier of the Key.
func (c *Client) KeyInfo(keyIdentity string) (*Key, error) {
var key Key
return &key, c.Get(&key, "/account/keys/"+keyIdentity)
}
// List existing keys.
//
// lr is an optional ListRange that sets the Range options for the paginated
// list of results.
func (c *Client) KeyList(lr *ListRange) ([]Key, error) {
req, err := c.NewRequest("GET", "/account/keys", nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var keysRes []Key
return keysRes, c.DoReq(req, &keysRes)
}