-
Notifications
You must be signed in to change notification settings - Fork 3
/
resource_tokens.go
60 lines (51 loc) · 1.04 KB
/
resource_tokens.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
package fly
import (
"context"
)
func (c *Client) GetAppLimitedAccessTokens(ctx context.Context, appName string) ([]LimitedAccessToken, error) {
query := `
query ($appName: String!) {
app(name: $appName) {
limitedAccessTokens {
nodes {
id
name
token
expiresAt
revokedAt
user {
email
}
}
}
}
}
`
req := c.NewRequest(query)
req.Var("appName", appName)
ctx = ctxWithAction(ctx, "get_app_limited_access_tokens")
data, err := c.RunWithContext(ctx, req)
if err != nil {
return nil, err
}
return data.App.LimitedAccessTokens.Nodes, nil
}
func (c *Client) RevokeLimitedAccessToken(ctx context.Context, id string) error {
query := `
mutation($input:DeleteLimitedAccessTokenInput!) {
deleteLimitedAccessToken(input: $input) {
token
}
}
`
req := c.NewRequest(query)
req.Var("input", map[string]interface{}{
"id": id,
})
ctx = ctxWithAction(ctx, "revoke_limited_access_token")
_, err := c.RunWithContext(ctx, req)
if err != nil {
return err
}
return nil
}