-
Notifications
You must be signed in to change notification settings - Fork 13
/
alert_source.go
85 lines (75 loc) · 2.47 KB
/
alert_source.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
package opslevel
type AlertSource struct {
Description string `graphql:"description"`
ExternalId string `graphql:"externalId"`
Id ID `graphql:"id"`
Integration IntegrationId `graphql:"integration"`
Name string `graphql:"name"`
Type AlertSourceTypeEnum `graphql:"type"`
Url string `graphql:"url"`
}
type AlertSourceService struct {
AlertSource AlertSource `graphql:"alertSource"`
Id ID `graphql:"id"`
Service ServiceId `graphql:"service"`
Status AlertSourceStatusTypeEnum `graphql:"status"`
}
type AlertSourceDeleteInput struct {
Id ID `json:"id"`
}
func NewAlertSource(kind AlertSourceTypeEnum, id string) *AlertSourceExternalIdentifier {
output := AlertSourceExternalIdentifier{
Type: kind,
ExternalId: id,
}
return &output
}
func (client *Client) CreateAlertSourceService(input AlertSourceServiceCreateInput) (*AlertSourceService, error) {
var m struct {
Payload struct {
AlertSourceService AlertSourceService
Errors []OpsLevelErrors
} `graphql:"alertSourceServiceCreate(input: $input)"`
}
v := PayloadVariables{
"input": input,
}
err := client.Mutate(&m, v, WithName("AlertSourceServiceCreate"))
return &m.Payload.AlertSourceService, HandleErrors(err, m.Payload.Errors)
}
func (client *Client) GetAlertSourceWithExternalIdentifier(input AlertSourceExternalIdentifier) (*AlertSource, error) {
var q struct {
Account struct {
AlertSource AlertSource `graphql:"alertSource(externalIdentifier: $externalIdentifier)"`
}
}
v := PayloadVariables{
"externalIdentifier": input,
}
err := client.Query(&q, v, WithName("AlertSourceGet"))
return &q.Account.AlertSource, HandleErrors(err, nil)
}
func (client *Client) GetAlertSource(id ID) (*AlertSource, error) {
var q struct {
Account struct {
AlertSource AlertSource `graphql:"alertSource(id: $id)"`
}
}
v := PayloadVariables{
"id": id,
}
err := client.Query(&q, v, WithName("AlertSourceGet"))
return &q.Account.AlertSource, HandleErrors(err, nil)
}
func (client *Client) DeleteAlertSourceService(id ID) error {
var m struct {
Payload struct {
Errors []OpsLevelErrors
} `graphql:"alertSourceServiceDelete(input: $input)"`
}
v := PayloadVariables{
"input": AlertSourceDeleteInput{Id: id},
}
err := client.Mutate(&m, v, WithName("AlertSourceServiceDelete"))
return HandleErrors(err, m.Payload.Errors)
}