forked from andygrunwald/go-incident
-
Notifications
You must be signed in to change notification settings - Fork 1
/
severities.go
55 lines (45 loc) · 1.34 KB
/
severities.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
package incident
import (
"context"
"fmt"
)
// SeveritiesService handles communication with the severity related
// methods of the Incident.io API.
//
// API docs: https://api-docs.incident.io/#tag/Severities
type SeveritiesService service
// List list all incident severities for an organisation.
//
// API docs: https://api-docs.incident.io/#operation/Severities_List
func (s *SeveritiesService) List(ctx context.Context) (*SeveritiesList, *Response, error) {
u := "severities"
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
v := &SeveritiesList{}
resp, err := s.client.Do(ctx, req, v)
if err != nil {
return nil, resp, err
}
return v, resp, nil
}
// Get returns a single incident severity.
//
// id represents the unique identifier for the severity
//
// API docs: https://api-docs.incident.io/#operation/Severities_Show
func (s *SeveritiesService) Get(ctx context.Context, id string) (*SeverityResponse, *Response, error) {
u := fmt.Sprintf("severities/%s", id)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
// TODO Should we return the severity directly? Would be more userfriendly - Maybe talking to the Incident.io folks?
v := &SeverityResponse{}
resp, err := s.client.Do(ctx, req, v)
if err != nil {
return nil, resp, err
}
return v, resp, nil
}