forked from PagerDuty/go-pagerduty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
on_call.go
43 lines (38 loc) · 1.16 KB
/
on_call.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 (
"github.com/google/go-querystring/query"
)
type OnCall struct {
User APIObject
Schedule APIObject
EscalationPolicy APIObject
EscalationLevel uint
Start string
End string
}
type ListOnCallsResponse struct {
OnCalls []OnCall `json:"oncalls"`
}
type ListOnCallOptions struct {
APIListObject
TimeZone string `url:"time_zone,omitempty"`
Includes []string `url:"include,omitempty,brackets"`
UserIDs []string `url:"user_ids,omitempty,brackets"`
EscalationPolicyIDs []string `url:"escalation_policy_ids,omitempty,brackets"`
ScheduleIDs []string `url:"schedule_ids,omitempty,brackets"`
Since string `json:"since,omitempty"`
Until string `json:"until,omitempty"`
Earliest bool `json:"earliest,omitempty"`
}
func (c *Client) ListOnCalls(o ListOnCallOptions) (*ListOnCallsResponse, error) {
v, err := query.Values(o)
if err != nil {
return nil, err
}
resp, err := c.Get("/oncalls?" + v.Encode())
if err != nil {
return nil, err
}
var result ListOnCallsResponse
return &result, c.decodeJson(resp, &result)
}