1package pagerduty 2 3import ( 4 "github.com/google/go-querystring/query" 5) 6 7// OnCall represents a contiguous unit of time for which a user will be on call for a given escalation policy and escalation rule. 8type OnCall struct { 9 User APIObject `json:"user,omitempty"` 10 Schedule APIObject `json:"schedule,omitempty"` 11 EscalationPolicy APIObject `json:"escalation_policy,omitempty"` 12 EscalationLevel uint `json:"escalation_level,omitempty"` 13 Start string `json:"start,omitempty"` 14 End string `json:"end,omitempty"` 15} 16 17// ListOnCallsResponse is the data structure returned from calling the ListOnCalls API endpoint. 18type ListOnCallsResponse struct { 19 APIListObject 20 OnCalls []OnCall `json:"oncalls"` 21} 22 23// ListOnCallOptions is the data structure used when calling the ListOnCalls API endpoint. 24type ListOnCallOptions struct { 25 APIListObject 26 TimeZone string `url:"time_zone,omitempty"` 27 Includes []string `url:"include,omitempty,brackets"` 28 UserIDs []string `url:"user_ids,omitempty,brackets"` 29 EscalationPolicyIDs []string `url:"escalation_policy_ids,omitempty,brackets"` 30 ScheduleIDs []string `url:"schedule_ids,omitempty,brackets"` 31 Since string `url:"since,omitempty"` 32 Until string `url:"until,omitempty"` 33 Earliest bool `url:"earliest,omitempty"` 34} 35 36// ListOnCalls list the on-call entries during a given time range. 37func (c *Client) ListOnCalls(o ListOnCallOptions) (*ListOnCallsResponse, error) { 38 v, err := query.Values(o) 39 if err != nil { 40 return nil, err 41 } 42 resp, err := c.get("/oncalls?" + v.Encode()) 43 if err != nil { 44 return nil, err 45 } 46 var result ListOnCallsResponse 47 return &result, c.decodeJSON(resp, &result) 48} 49