-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
actions.go
59 lines (49 loc) · 1.37 KB
/
actions.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
package incident
import (
"context"
"fmt"
)
// ActionsService handles communication with the actions related
// methods of the Incident.io API.
//
// API docs: https://api-docs.incident.io/#tag/Actions
type ActionsService service
// List list all actions for an organisation.
//
// API docs: https://api-docs.incident.io/#operation/Actions_List
func (s *ActionsService) List(ctx context.Context, opts *ActionsListOptions) (*ActionsList, *Response, error) {
u := "actions"
u, err := addOptions(u, opts)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
v := &ActionsList{}
resp, err := s.client.Do(ctx, req, v)
if err != nil {
return nil, resp, err
}
return v, resp, nil
}
// Get returns a single action.
//
// id represents the unique identifier for the action
//
// API docs: https://api-docs.incident.io/#operation/Actions_Show
func (s *ActionsService) Get(ctx context.Context, id string) (*ActionResponse, *Response, error) {
u := fmt.Sprintf("actions/%s", id)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
// TODO Should we return the action directly? Would be more userfriendly - Maybe talking to the Incident.io folks?
v := &ActionResponse{}
resp, err := s.client.Do(ctx, req, v)
if err != nil {
return nil, resp, err
}
return v, resp, nil
}