forked from opsgenie/opsgenie-go-sdk-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration.go
138 lines (123 loc) · 3.88 KB
/
integration.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package integration
import (
"context"
"github.com/opsgenie/opsgenie-go-sdk-v2/client"
)
type Client struct {
client *client.OpsGenieClient
}
func NewClient(config *client.Config) (*Client, error) {
opsgenieClient, err := client.NewOpsGenieClient(config)
if err != nil {
return nil, err
}
return &Client{opsgenieClient}, nil
}
func (c *Client) Get(context context.Context, request *GetRequest) (*GetResult, error) {
result := &GetResult{}
err := c.client.Exec(context, request, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) List(context context.Context) (*ListResult, error) {
request := listRequest{}
result := &ListResult{}
err := c.client.Exec(context, &request, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) CreateApiBased(context context.Context, request *APIBasedIntegrationRequest) (*APIBasedIntegrationResult, error) {
result := &APIBasedIntegrationResult{}
err := c.client.Exec(context, request, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) CreateEmailBased(context context.Context, request *EmailBasedIntegrationRequest) (*EmailBasedIntegrationResult, error) {
result := &EmailBasedIntegrationResult{}
err := c.client.Exec(context, request, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) ForceUpdateAllFields(context context.Context, request *UpdateIntegrationRequest) (*UpdateResult, error) {
result := &UpdateResult{}
if len(request.OtherFields) == 0 {
request.OtherFields = map[string]interface{}{}
}
request.OtherFields["id"] = request.Id
request.OtherFields["name"] = request.Name
request.OtherFields["type"] = request.Type
request.OtherFields["enabled"] = request.Enabled
request.OtherFields["ignoreRespondersFromPayload"] = request.IgnoreRespondersFromPayload
request.OtherFields["suppressNotifications"] = request.SuppressNotifications
request.OtherFields["responders"] = request.Responders
request.OtherFields["emailUsername"] = request.EmailUsername
err := c.client.Exec(context, request.OtherFields, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) Delete(context context.Context, request *DeleteIntegrationRequest) (*DeleteResult, error) {
result := &DeleteResult{}
err := c.client.Exec(context, request, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) Enable(context context.Context, request *EnableIntegrationRequest) (*EnableResult, error) {
result := &EnableResult{}
err := c.client.Exec(context, request, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) Disable(context context.Context, request *DisableIntegrationRequest) (*DisableResult, error) {
result := &DisableResult{}
err := c.client.Exec(context, request, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) Authenticate(context context.Context, request *AuthenticateIntegrationRequest) (*AuthenticateResult, error) {
result := &AuthenticateResult{}
err := c.client.Exec(context, request, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) GetActions(context context.Context, request *GetIntegrationActionsRequest) (*ActionsResult, error) {
result := &ActionsResult{}
err := c.client.Exec(context, request, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) CreateActions(context context.Context, request *CreateIntegrationActionsRequest) (*ActionsResult, error) {
result := &ActionsResult{}
err := c.client.Exec(context, request, result)
if err != nil {
return nil, err
}
return result, nil
}
func (c *Client) UpdateAllActions(context context.Context, request *UpdateAllIntegrationActionsRequest) (*ActionsResult, error) {
result := &ActionsResult{}
err := c.client.Exec(context, request, result)
if err != nil {
return nil, err
}
return result, nil
}