-
Notifications
You must be signed in to change notification settings - Fork 13
/
check_manual.go
53 lines (46 loc) · 1.86 KB
/
check_manual.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
package opslevel
import "github.com/relvacode/iso8601"
type ManualCheckFragment struct {
UpdateFrequency *ManualCheckFrequency `graphql:"updateFrequency"` // The minimum frequency of the updates.
UpdateRequiresComment bool `graphql:"updateRequiresComment"` // Whether the check requires a comment or not.
}
type ManualCheckFrequency struct {
FrequencyTimeScale FrequencyTimeScale `graphql:"frequencyTimeScale"`
FrequencyValue int `graphql:"frequencyValue"`
StartingDate iso8601.Time `graphql:"startingDate"`
}
func NewManualCheckFrequencyInput(startingDate string, timeScale FrequencyTimeScale, value int) *ManualCheckFrequencyInput {
return &ManualCheckFrequencyInput{
StartingDate: NewISO8601Date(startingDate),
FrequencyTimeScale: timeScale,
FrequencyValue: value,
}
}
func NewManualCheckFrequencyUpdateInput(startingDate string, timeScale FrequencyTimeScale, value int) *ManualCheckFrequencyUpdateInput {
startingDateIso := NewISO8601Date(startingDate)
return &ManualCheckFrequencyUpdateInput{
StartingDate: &startingDateIso,
FrequencyTimeScale: &timeScale,
FrequencyValue: &value,
}
}
func (client *Client) CreateCheckManual(input CheckManualCreateInput) (*Check, error) {
var m struct {
Payload CheckResponsePayload `graphql:"checkManualCreate(input: $input)"`
}
v := PayloadVariables{
"input": input,
}
err := client.Mutate(&m, v, WithName("CheckManualCreate"))
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors)
}
func (client *Client) UpdateCheckManual(input CheckManualUpdateInput) (*Check, error) {
var m struct {
Payload CheckResponsePayload `graphql:"checkManualUpdate(input: $input)"`
}
v := PayloadVariables{
"input": input,
}
err := client.Mutate(&m, v, WithName("CheckManualUpdate"))
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors)
}