-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathwho_is_oncall_request.go
122 lines (97 loc) · 2.53 KB
/
who_is_oncall_request.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package schedule
import (
"net/http"
"time"
"github.com/opsgenie/opsgenie-go-sdk-v2/client"
)
type GetOnCallsRequest struct {
client.BaseRequest
Flat *bool
Date *time.Time
ScheduleIdentifierType Identifier
ScheduleIdentifier string
}
func (r *GetOnCallsRequest) Validate() error {
err := validateIdentifiers(r.ScheduleIdentifier, "Schedule identifier cannot be empty.")
if err != nil {
return err
}
return nil
}
func (r *GetOnCallsRequest) Method() string {
return http.MethodGet
}
func (r *GetOnCallsRequest) ResourcePath() string {
return "/v2/schedules/" + r.ScheduleIdentifier + "/on-calls"
}
func (r *GetOnCallsRequest) RequestParams() map[string]string {
params := make(map[string]string)
if r.ScheduleIdentifierType == Name {
params["scheduleIdentifierType"] = "name"
} else {
params["scheduleIdentifierType"] = "id"
}
if *r.Flat {
params["flat"] = "true"
}
if r.Date != nil {
params["date"] = r.Date.Format("2006-01-02T15:04:05.000Z")
}
return params
}
type GetNextOnCallsRequest struct {
client.BaseRequest
Flat *bool
Date *time.Time
ScheduleIdentifierType Identifier
ScheduleIdentifier string
}
func (r *GetNextOnCallsRequest) Validate() error {
err := validateIdentifiers(r.ScheduleIdentifier, "Schedule identifier cannot be empty.")
if err != nil {
return err
}
return nil
}
func (r *GetNextOnCallsRequest) Method() string {
return http.MethodGet
}
func (r *GetNextOnCallsRequest) ResourcePath() string {
return "/v2/schedules/" + r.ScheduleIdentifier + "/next-on-calls"
}
func (r *GetNextOnCallsRequest) RequestParams() map[string]string {
params := make(map[string]string)
if r.ScheduleIdentifierType == Name {
params["scheduleIdentifierType"] = "name"
} else {
params["scheduleIdentifierType"] = "id"
}
if *r.Flat {
params["flat"] = "true"
}
if r.Date != nil {
params["date"] = r.Date.Format("2006-01-02T15:04:05.000Z")
}
return params
}
type ExportOnCallUserRequest struct {
client.BaseRequest
UserIdentifier string
ExportedFilePath string
}
func (r *ExportOnCallUserRequest) Validate() error {
err := validateIdentifiers(r.UserIdentifier, "User identifier cannot be empty.")
if err != nil {
return err
}
return nil
}
func (r *ExportOnCallUserRequest) Method() string {
return http.MethodGet
}
func (r *ExportOnCallUserRequest) getFileName() string {
return r.UserIdentifier + ".ics"
}
func (r *ExportOnCallUserRequest) ResourcePath() string {
return "/v2/schedules/on-calls/" + r.getFileName()
}