forked from heimweh/go-pagerduty
/
oncall.go
52 lines (45 loc) · 1.92 KB
/
oncall.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
package pagerduty
// OnCallService handles the communication with team
// related methods of the PagerDuty API.
type OnCallService service
// OnCall represents an oncall.
type OnCall struct {
User *UserReference `json:"user,omitempty"`
Schedule *ScheduleReference `json:"schedule,omitempty"`
EscalationPolicy *EscalationPolicyReference `json:"escalation_policy,omitempty"`
EscalationLevel int `json:"escalation_level"`
Start *string `json:"start"`
End *string `json:"end"`
}
// ListOnCallOptions represents options when listing oncalls.
type ListOnCallOptions struct {
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
Total bool `url:"total,omitempty"`
Earliest bool `url:"earliest,omitempty"`
EscalationPolicyIds []string `url:"escalation_policy_ids,omitempty"`
Includes []string `url:"include,omitempty"`
ScheduleIds []string `url:"schedule_ids,omitempty"`
UserIds []string `url:"user_ids,brackets,omitempty"`
Since string `url:"since,omitempty"`
TimeZone string `url:"time_zone,omitempty"`
Until string `url:"until,omitempty"`
}
// ListOnCallResponse represents a list response of oncalls.
type ListOnCallResponse struct {
Oncalls []*OnCall `json:"oncalls,omitempty"`
Limit int `json:"limit,omitempty"`
More bool `json:"more,omitempty"`
Offset int `json:"offset,omitempty"`
Total int `json:"total,omitempty"`
}
// List lists existing oncalls.
func (s *OnCallService) List(o *ListOnCallOptions) (*ListOnCallResponse, *Response, error) {
u := "/oncalls"
v := new(ListOnCallResponse)
resp, err := s.client.newRequestDo("GET", u, o, nil, &v)
if err != nil {
return nil, nil, err
}
return v, resp, nil
}