forked from muxinc/mux-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_incidents.go
295 lines (246 loc) · 9.6 KB
/
api_incidents.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
// Mux Go - Copyright 2019 Mux Inc.
// NOTE: This file is auto generated. Do not edit this file manually.
package muxgo
import (
"fmt"
"io/ioutil"
"net/url"
"strings"
)
type IncidentsApiService service
func (a *IncidentsApiService) GetIncident(iNCIDENTID string, opts ...APIOption) (IncidentResponse, error) {
var (
localVarAPIOptions = new(APIOptions)
localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue IncidentResponse
)
for _, opt := range opts {
opt(localVarAPIOptions)
}
// create path and map variables
localVarPath := a.client.cfg.basePath + "/data/v1/incidents/{INCIDENT_ID}"
localVarPath = strings.Replace(localVarPath, "{"+"INCIDENT_ID"+"}", fmt.Sprintf("%v", iNCIDENTID), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHttpContentTypes := []string{}
// set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
r, err := a.client.prepareRequest(localVarAPIOptions, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, err
}
localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarReturnValue, err
}
// Check for common HTTP error status codes
err = CheckForHttpError(localVarHttpResponse.StatusCode, localVarBody)
if err != nil {
return localVarReturnValue, err
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
type ListIncidentsParams struct {
Limit int32
Page int32
OrderBy string
OrderDirection string
Status string
Severity string
}
// ListIncidents optionally accepts the APIOption of WithParams(*ListIncidentsParams).
func (a *IncidentsApiService) ListIncidents(opts ...APIOption) (ListIncidentsResponse, error) {
var (
localVarAPIOptions = new(APIOptions)
localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue ListIncidentsResponse
)
for _, opt := range opts {
opt(localVarAPIOptions)
}
localVarOptionals, ok := localVarAPIOptions.params.(*ListIncidentsParams)
if localVarAPIOptions.params != nil && !ok {
return localVarReturnValue, reportError("provided params were not of type *ListIncidentsParams")
}
// create path and map variables
localVarPath := a.client.cfg.basePath + "/data/v1/incidents"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if localVarOptionals != nil && isSet(localVarOptionals.Limit) {
localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.Page) {
localVarQueryParams.Add("page", parameterToString(localVarOptionals.Page, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.OrderBy) {
localVarQueryParams.Add("order_by", parameterToString(localVarOptionals.OrderBy, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.OrderDirection) {
localVarQueryParams.Add("order_direction", parameterToString(localVarOptionals.OrderDirection, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.Status) {
localVarQueryParams.Add("status", parameterToString(localVarOptionals.Status, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.Severity) {
localVarQueryParams.Add("severity", parameterToString(localVarOptionals.Severity, ""))
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{}
// set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
r, err := a.client.prepareRequest(localVarAPIOptions, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, err
}
localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarReturnValue, err
}
// Check for common HTTP error status codes
err = CheckForHttpError(localVarHttpResponse.StatusCode, localVarBody)
if err != nil {
return localVarReturnValue, err
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
type ListRelatedIncidentsParams struct {
Limit int32
Page int32
OrderBy string
OrderDirection string
}
// ListRelatedIncidents optionally accepts the APIOption of WithParams(*ListRelatedIncidentsParams).
func (a *IncidentsApiService) ListRelatedIncidents(iNCIDENTID string, opts ...APIOption) (ListRelatedIncidentsResponse, error) {
var (
localVarAPIOptions = new(APIOptions)
localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue ListRelatedIncidentsResponse
)
for _, opt := range opts {
opt(localVarAPIOptions)
}
localVarOptionals, ok := localVarAPIOptions.params.(*ListRelatedIncidentsParams)
if localVarAPIOptions.params != nil && !ok {
return localVarReturnValue, reportError("provided params were not of type *ListRelatedIncidentsParams")
}
// create path and map variables
localVarPath := a.client.cfg.basePath + "/data/v1/incidents/{INCIDENT_ID}/related"
localVarPath = strings.Replace(localVarPath, "{"+"INCIDENT_ID"+"}", fmt.Sprintf("%v", iNCIDENTID), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if localVarOptionals != nil && isSet(localVarOptionals.Limit) {
localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.Page) {
localVarQueryParams.Add("page", parameterToString(localVarOptionals.Page, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.OrderBy) {
localVarQueryParams.Add("order_by", parameterToString(localVarOptionals.OrderBy, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.OrderDirection) {
localVarQueryParams.Add("order_direction", parameterToString(localVarOptionals.OrderDirection, ""))
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{}
// set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
r, err := a.client.prepareRequest(localVarAPIOptions, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, err
}
localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarReturnValue, err
}
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarReturnValue, err
}
// Check for common HTTP error status codes
err = CheckForHttpError(localVarHttpResponse.StatusCode, localVarBody)
if err != nil {
return localVarReturnValue, err
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}