-
Notifications
You must be signed in to change notification settings - Fork 240
/
ability.go
43 lines (35 loc) · 1.23 KB
/
ability.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
package pagerduty
import "context"
// ListAbilityResponse is the response when calling the ListAbility API endpoint.
type ListAbilityResponse struct {
Abilities []string `json:"abilities"`
}
// ListAbilities lists all abilities on your account.
//
// Deprecated: Use ListAbilitiesWithContext instead.
func (c *Client) ListAbilities() (*ListAbilityResponse, error) {
return c.ListAbilitiesWithContext(context.Background())
}
// ListAbilitiesWithContext lists all abilities on your account.
func (c *Client) ListAbilitiesWithContext(ctx context.Context) (*ListAbilityResponse, error) {
resp, err := c.get(ctx, "/abilities", nil)
if err != nil {
return nil, err
}
var result ListAbilityResponse
if err := c.decodeJSON(resp, &result); err != nil {
return nil, err
}
return &result, nil
}
// TestAbility checks if your account has the given ability.
//
// Deprecated: Use TestAbilityWithContext instead.
func (c *Client) TestAbility(ability string) error {
return c.TestAbilityWithContext(context.Background(), ability)
}
// TestAbilityWithContext checks if your account has the given ability.
func (c *Client) TestAbilityWithContext(ctx context.Context, ability string) error {
_, err := c.get(ctx, "/abilities/"+ability, nil)
return err
}