-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreds.go
36 lines (30 loc) · 969 Bytes
/
creds.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
package ngrok
import (
"context"
"net/url"
"time"
)
type CredService struct {
client *Client
}
// https://ngrok.com/docs/ngrok-link#list-credentials
type Cred struct {
// Only present on the response from a Create request, otherwise empty
Token string `json:"token"`
Description string `json:"description"`
ACL []string `json:"acl"`
CreatedAt time.Time `json:"created_at"`
ID string `json:"id"`
Metadata string `json:"metadata"`
URI string `json:"uri"`
}
const credPathPart = "/credentials"
// Create a new Credential. https://ngrok.com/docs/ngrok-link#create-credential
func (c *CredService) Create(ctx context.Context, data url.Values) (*Cred, error) {
cred := new(Cred)
err := c.client.CreateResource(ctx, credPathPart, data, cred)
return cred, err
}
func (c *CredService) Delete(ctx context.Context, id string) error {
return c.client.DeleteResource(ctx, credPathPart, url.PathEscape(id))
}