forked from OpsLevel/opslevel-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_manual.go
64 lines (53 loc) · 2.11 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
54
55
56
57
58
59
60
61
62
63
64
package opslevel
import "github.com/relvacode/iso8601"
type ManualCheckFragment struct {
UpdateFrequency *ManualCheckFrequency `graphql:"updateFrequency"`
UpdateRequiresComment bool `graphql:"updateRequiresComment"`
}
type ManualCheckFrequency struct {
StartingDate iso8601.Time `graphql:"startingDate"`
FrequencyTimeScale FrequencyTimeScale `graphql:"frequencyTimeScale"`
FrequencyValue int `graphql:"frequencyValue"`
}
type ManualCheckFrequencyInput struct {
StartingDate iso8601.Time `json:"startingDate"`
FrequencyTimeScale FrequencyTimeScale `json:"frequencyTimeScale"`
FrequencyValue int `json:"frequencyValue"`
}
func NewManualCheckFrequencyInput(startingDate string, timeScale FrequencyTimeScale, value int) *ManualCheckFrequencyInput {
return &ManualCheckFrequencyInput{
StartingDate: NewISO8601Date(startingDate),
FrequencyTimeScale: timeScale,
FrequencyValue: value,
}
}
type CheckManualCreateInput struct {
CheckCreateInput
UpdateFrequency *ManualCheckFrequencyInput `json:"updateFrequency,omitempty"`
UpdateRequiresComment bool `json:"updateRequiresComment"`
}
type CheckManualUpdateInput struct {
CheckUpdateInput
UpdateFrequency *ManualCheckFrequencyInput `json:"updateFrequency,omitempty"`
UpdateRequiresComment bool `json:"updateRequiresComment,omitempty"`
}
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)
}