/
annotationoutage.go
457 lines (394 loc) · 19.8 KB
/
annotationoutage.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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package radar
import (
"context"
"net/http"
"net/url"
"time"
"github.com/cloudflare/cloudflare-go/v2/internal/apijson"
"github.com/cloudflare/cloudflare-go/v2/internal/apiquery"
"github.com/cloudflare/cloudflare-go/v2/internal/param"
"github.com/cloudflare/cloudflare-go/v2/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v2/option"
)
// AnnotationOutageService contains methods and other services that help with
// interacting with the cloudflare API. Note, unlike clients, this service does not
// read variables from the environment automatically. You should not instantiate
// this service directly, and instead use the [NewAnnotationOutageService] method
// instead.
type AnnotationOutageService struct {
Options []option.RequestOption
}
// NewAnnotationOutageService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewAnnotationOutageService(opts ...option.RequestOption) (r *AnnotationOutageService) {
r = &AnnotationOutageService{}
r.Options = opts
return
}
// Get latest Internet outages and anomalies.
func (r *AnnotationOutageService) Get(ctx context.Context, query AnnotationOutageGetParams, opts ...option.RequestOption) (res *AnnotationOutageGetResponse, err error) {
opts = append(r.Options[:], opts...)
var env AnnotationOutageGetResponseEnvelope
path := "radar/annotations/outages"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// Get the number of outages for locations.
func (r *AnnotationOutageService) Locations(ctx context.Context, query AnnotationOutageLocationsParams, opts ...option.RequestOption) (res *AnnotationOutageLocationsResponse, err error) {
opts = append(r.Options[:], opts...)
var env AnnotationOutageLocationsResponseEnvelope
path := "radar/annotations/outages/locations"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
type AnnotationOutageGetResponse struct {
Annotations []AnnotationOutageGetResponseAnnotation `json:"annotations,required"`
JSON annotationOutageGetResponseJSON `json:"-"`
}
// annotationOutageGetResponseJSON contains the JSON metadata for the struct
// [AnnotationOutageGetResponse]
type annotationOutageGetResponseJSON struct {
Annotations apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AnnotationOutageGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r annotationOutageGetResponseJSON) RawJSON() string {
return r.raw
}
type AnnotationOutageGetResponseAnnotation struct {
ID string `json:"id,required"`
ASNs []int64 `json:"asns,required"`
ASNsDetails []AnnotationOutageGetResponseAnnotationsASNsDetail `json:"asnsDetails,required"`
DataSource string `json:"dataSource,required"`
EventType string `json:"eventType,required"`
Locations []string `json:"locations,required"`
LocationsDetails []AnnotationOutageGetResponseAnnotationsLocationsDetail `json:"locationsDetails,required"`
Outage AnnotationOutageGetResponseAnnotationsOutage `json:"outage,required"`
StartDate string `json:"startDate,required"`
Description string `json:"description"`
EndDate string `json:"endDate"`
LinkedURL string `json:"linkedUrl"`
Scope string `json:"scope"`
JSON annotationOutageGetResponseAnnotationJSON `json:"-"`
}
// annotationOutageGetResponseAnnotationJSON contains the JSON metadata for the
// struct [AnnotationOutageGetResponseAnnotation]
type annotationOutageGetResponseAnnotationJSON struct {
ID apijson.Field
ASNs apijson.Field
ASNsDetails apijson.Field
DataSource apijson.Field
EventType apijson.Field
Locations apijson.Field
LocationsDetails apijson.Field
Outage apijson.Field
StartDate apijson.Field
Description apijson.Field
EndDate apijson.Field
LinkedURL apijson.Field
Scope apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AnnotationOutageGetResponseAnnotation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r annotationOutageGetResponseAnnotationJSON) RawJSON() string {
return r.raw
}
type AnnotationOutageGetResponseAnnotationsASNsDetail struct {
ASN string `json:"asn,required"`
Name string `json:"name,required"`
Locations AnnotationOutageGetResponseAnnotationsASNsDetailsLocations `json:"locations"`
JSON annotationOutageGetResponseAnnotationsASNsDetailJSON `json:"-"`
}
// annotationOutageGetResponseAnnotationsASNsDetailJSON contains the JSON metadata
// for the struct [AnnotationOutageGetResponseAnnotationsASNsDetail]
type annotationOutageGetResponseAnnotationsASNsDetailJSON struct {
ASN apijson.Field
Name apijson.Field
Locations apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AnnotationOutageGetResponseAnnotationsASNsDetail) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r annotationOutageGetResponseAnnotationsASNsDetailJSON) RawJSON() string {
return r.raw
}
type AnnotationOutageGetResponseAnnotationsASNsDetailsLocations struct {
Code string `json:"code,required"`
Name string `json:"name,required"`
JSON annotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON `json:"-"`
}
// annotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON contains the JSON
// metadata for the struct
// [AnnotationOutageGetResponseAnnotationsASNsDetailsLocations]
type annotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON struct {
Code apijson.Field
Name apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AnnotationOutageGetResponseAnnotationsASNsDetailsLocations) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r annotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON) RawJSON() string {
return r.raw
}
type AnnotationOutageGetResponseAnnotationsLocationsDetail struct {
Code string `json:"code,required"`
Name string `json:"name,required"`
JSON annotationOutageGetResponseAnnotationsLocationsDetailJSON `json:"-"`
}
// annotationOutageGetResponseAnnotationsLocationsDetailJSON contains the JSON
// metadata for the struct [AnnotationOutageGetResponseAnnotationsLocationsDetail]
type annotationOutageGetResponseAnnotationsLocationsDetailJSON struct {
Code apijson.Field
Name apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AnnotationOutageGetResponseAnnotationsLocationsDetail) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r annotationOutageGetResponseAnnotationsLocationsDetailJSON) RawJSON() string {
return r.raw
}
type AnnotationOutageGetResponseAnnotationsOutage struct {
OutageCause string `json:"outageCause,required"`
OutageType string `json:"outageType,required"`
JSON annotationOutageGetResponseAnnotationsOutageJSON `json:"-"`
}
// annotationOutageGetResponseAnnotationsOutageJSON contains the JSON metadata for
// the struct [AnnotationOutageGetResponseAnnotationsOutage]
type annotationOutageGetResponseAnnotationsOutageJSON struct {
OutageCause apijson.Field
OutageType apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AnnotationOutageGetResponseAnnotationsOutage) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r annotationOutageGetResponseAnnotationsOutageJSON) RawJSON() string {
return r.raw
}
type AnnotationOutageLocationsResponse struct {
Annotations []AnnotationOutageLocationsResponseAnnotation `json:"annotations,required"`
JSON annotationOutageLocationsResponseJSON `json:"-"`
}
// annotationOutageLocationsResponseJSON contains the JSON metadata for the struct
// [AnnotationOutageLocationsResponse]
type annotationOutageLocationsResponseJSON struct {
Annotations apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AnnotationOutageLocationsResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r annotationOutageLocationsResponseJSON) RawJSON() string {
return r.raw
}
type AnnotationOutageLocationsResponseAnnotation struct {
ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"`
ClientCountryName string `json:"clientCountryName,required"`
Value string `json:"value,required"`
JSON annotationOutageLocationsResponseAnnotationJSON `json:"-"`
}
// annotationOutageLocationsResponseAnnotationJSON contains the JSON metadata for
// the struct [AnnotationOutageLocationsResponseAnnotation]
type annotationOutageLocationsResponseAnnotationJSON struct {
ClientCountryAlpha2 apijson.Field
ClientCountryName apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AnnotationOutageLocationsResponseAnnotation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r annotationOutageLocationsResponseAnnotationJSON) RawJSON() string {
return r.raw
}
type AnnotationOutageGetParams struct {
// Single ASN as integer.
ASN param.Field[int64] `query:"asn"`
// End of the date range (inclusive).
DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"`
// Shorthand date ranges for the last X days - use when you don't need specific
// start and end dates.
DateRange param.Field[AnnotationOutageGetParamsDateRange] `query:"dateRange"`
// Start of the date range (inclusive).
DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"`
// Format results are returned in.
Format param.Field[AnnotationOutageGetParamsFormat] `query:"format"`
// Limit the number of objects in the response.
Limit param.Field[int64] `query:"limit"`
// Location Alpha2 code.
Location param.Field[string] `query:"location"`
// Number of objects to skip before grabbing results.
Offset param.Field[int64] `query:"offset"`
}
// URLQuery serializes [AnnotationOutageGetParams]'s query parameters as
// `url.Values`.
func (r AnnotationOutageGetParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Shorthand date ranges for the last X days - use when you don't need specific
// start and end dates.
type AnnotationOutageGetParamsDateRange string
const (
AnnotationOutageGetParamsDateRange1d AnnotationOutageGetParamsDateRange = "1d"
AnnotationOutageGetParamsDateRange2d AnnotationOutageGetParamsDateRange = "2d"
AnnotationOutageGetParamsDateRange7d AnnotationOutageGetParamsDateRange = "7d"
AnnotationOutageGetParamsDateRange14d AnnotationOutageGetParamsDateRange = "14d"
AnnotationOutageGetParamsDateRange28d AnnotationOutageGetParamsDateRange = "28d"
AnnotationOutageGetParamsDateRange12w AnnotationOutageGetParamsDateRange = "12w"
AnnotationOutageGetParamsDateRange24w AnnotationOutageGetParamsDateRange = "24w"
AnnotationOutageGetParamsDateRange52w AnnotationOutageGetParamsDateRange = "52w"
AnnotationOutageGetParamsDateRange1dControl AnnotationOutageGetParamsDateRange = "1dControl"
AnnotationOutageGetParamsDateRange2dControl AnnotationOutageGetParamsDateRange = "2dControl"
AnnotationOutageGetParamsDateRange7dControl AnnotationOutageGetParamsDateRange = "7dControl"
AnnotationOutageGetParamsDateRange14dControl AnnotationOutageGetParamsDateRange = "14dControl"
AnnotationOutageGetParamsDateRange28dControl AnnotationOutageGetParamsDateRange = "28dControl"
AnnotationOutageGetParamsDateRange12wControl AnnotationOutageGetParamsDateRange = "12wControl"
AnnotationOutageGetParamsDateRange24wControl AnnotationOutageGetParamsDateRange = "24wControl"
)
func (r AnnotationOutageGetParamsDateRange) IsKnown() bool {
switch r {
case AnnotationOutageGetParamsDateRange1d, AnnotationOutageGetParamsDateRange2d, AnnotationOutageGetParamsDateRange7d, AnnotationOutageGetParamsDateRange14d, AnnotationOutageGetParamsDateRange28d, AnnotationOutageGetParamsDateRange12w, AnnotationOutageGetParamsDateRange24w, AnnotationOutageGetParamsDateRange52w, AnnotationOutageGetParamsDateRange1dControl, AnnotationOutageGetParamsDateRange2dControl, AnnotationOutageGetParamsDateRange7dControl, AnnotationOutageGetParamsDateRange14dControl, AnnotationOutageGetParamsDateRange28dControl, AnnotationOutageGetParamsDateRange12wControl, AnnotationOutageGetParamsDateRange24wControl:
return true
}
return false
}
// Format results are returned in.
type AnnotationOutageGetParamsFormat string
const (
AnnotationOutageGetParamsFormatJson AnnotationOutageGetParamsFormat = "JSON"
AnnotationOutageGetParamsFormatCsv AnnotationOutageGetParamsFormat = "CSV"
)
func (r AnnotationOutageGetParamsFormat) IsKnown() bool {
switch r {
case AnnotationOutageGetParamsFormatJson, AnnotationOutageGetParamsFormatCsv:
return true
}
return false
}
type AnnotationOutageGetResponseEnvelope struct {
Result AnnotationOutageGetResponse `json:"result,required"`
Success bool `json:"success,required"`
JSON annotationOutageGetResponseEnvelopeJSON `json:"-"`
}
// annotationOutageGetResponseEnvelopeJSON contains the JSON metadata for the
// struct [AnnotationOutageGetResponseEnvelope]
type annotationOutageGetResponseEnvelopeJSON struct {
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AnnotationOutageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r annotationOutageGetResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
type AnnotationOutageLocationsParams struct {
// End of the date range (inclusive).
DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"`
// Shorthand date ranges for the last X days - use when you don't need specific
// start and end dates.
DateRange param.Field[AnnotationOutageLocationsParamsDateRange] `query:"dateRange"`
// Start of the date range (inclusive).
DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"`
// Format results are returned in.
Format param.Field[AnnotationOutageLocationsParamsFormat] `query:"format"`
// Limit the number of objects in the response.
Limit param.Field[int64] `query:"limit"`
}
// URLQuery serializes [AnnotationOutageLocationsParams]'s query parameters as
// `url.Values`.
func (r AnnotationOutageLocationsParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Shorthand date ranges for the last X days - use when you don't need specific
// start and end dates.
type AnnotationOutageLocationsParamsDateRange string
const (
AnnotationOutageLocationsParamsDateRange1d AnnotationOutageLocationsParamsDateRange = "1d"
AnnotationOutageLocationsParamsDateRange2d AnnotationOutageLocationsParamsDateRange = "2d"
AnnotationOutageLocationsParamsDateRange7d AnnotationOutageLocationsParamsDateRange = "7d"
AnnotationOutageLocationsParamsDateRange14d AnnotationOutageLocationsParamsDateRange = "14d"
AnnotationOutageLocationsParamsDateRange28d AnnotationOutageLocationsParamsDateRange = "28d"
AnnotationOutageLocationsParamsDateRange12w AnnotationOutageLocationsParamsDateRange = "12w"
AnnotationOutageLocationsParamsDateRange24w AnnotationOutageLocationsParamsDateRange = "24w"
AnnotationOutageLocationsParamsDateRange52w AnnotationOutageLocationsParamsDateRange = "52w"
AnnotationOutageLocationsParamsDateRange1dControl AnnotationOutageLocationsParamsDateRange = "1dControl"
AnnotationOutageLocationsParamsDateRange2dControl AnnotationOutageLocationsParamsDateRange = "2dControl"
AnnotationOutageLocationsParamsDateRange7dControl AnnotationOutageLocationsParamsDateRange = "7dControl"
AnnotationOutageLocationsParamsDateRange14dControl AnnotationOutageLocationsParamsDateRange = "14dControl"
AnnotationOutageLocationsParamsDateRange28dControl AnnotationOutageLocationsParamsDateRange = "28dControl"
AnnotationOutageLocationsParamsDateRange12wControl AnnotationOutageLocationsParamsDateRange = "12wControl"
AnnotationOutageLocationsParamsDateRange24wControl AnnotationOutageLocationsParamsDateRange = "24wControl"
)
func (r AnnotationOutageLocationsParamsDateRange) IsKnown() bool {
switch r {
case AnnotationOutageLocationsParamsDateRange1d, AnnotationOutageLocationsParamsDateRange2d, AnnotationOutageLocationsParamsDateRange7d, AnnotationOutageLocationsParamsDateRange14d, AnnotationOutageLocationsParamsDateRange28d, AnnotationOutageLocationsParamsDateRange12w, AnnotationOutageLocationsParamsDateRange24w, AnnotationOutageLocationsParamsDateRange52w, AnnotationOutageLocationsParamsDateRange1dControl, AnnotationOutageLocationsParamsDateRange2dControl, AnnotationOutageLocationsParamsDateRange7dControl, AnnotationOutageLocationsParamsDateRange14dControl, AnnotationOutageLocationsParamsDateRange28dControl, AnnotationOutageLocationsParamsDateRange12wControl, AnnotationOutageLocationsParamsDateRange24wControl:
return true
}
return false
}
// Format results are returned in.
type AnnotationOutageLocationsParamsFormat string
const (
AnnotationOutageLocationsParamsFormatJson AnnotationOutageLocationsParamsFormat = "JSON"
AnnotationOutageLocationsParamsFormatCsv AnnotationOutageLocationsParamsFormat = "CSV"
)
func (r AnnotationOutageLocationsParamsFormat) IsKnown() bool {
switch r {
case AnnotationOutageLocationsParamsFormatJson, AnnotationOutageLocationsParamsFormatCsv:
return true
}
return false
}
type AnnotationOutageLocationsResponseEnvelope struct {
Result AnnotationOutageLocationsResponse `json:"result,required"`
Success bool `json:"success,required"`
JSON annotationOutageLocationsResponseEnvelopeJSON `json:"-"`
}
// annotationOutageLocationsResponseEnvelopeJSON contains the JSON metadata for the
// struct [AnnotationOutageLocationsResponseEnvelope]
type annotationOutageLocationsResponseEnvelopeJSON struct {
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AnnotationOutageLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r annotationOutageLocationsResponseEnvelopeJSON) RawJSON() string {
return r.raw
}