-
Notifications
You must be signed in to change notification settings - Fork 8
/
alert-config.go
2535 lines (2080 loc) · 89.5 KB
/
alert-config.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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Package alertconfig provides primitives to interact with the openapi HTTP API.
//
// Code generated by dev.azure.com/schwarzit/schwarzit.odj.core/_git/stackit-client-generator.git version v1.0.23 DO NOT EDIT.
package alertconfig
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"github.com/pkg/errors"
"github.com/SchwarzIT/community-stackit-go-client/pkg/helpers/runtime"
openapiTypes "github.com/SchwarzIT/community-stackit-go-client/pkg/helpers/types"
contracts "github.com/SchwarzIT/community-stackit-go-client/pkg/contracts"
"github.com/SchwarzIT/community-stackit-go-client/pkg/validate"
)
const (
BearerAuthScopes = "bearerAuth.Scopes"
)
// Alert defines model for Alert.
type Alert struct {
Global *Global `json:"global,omitempty"`
InhibitRules *[]InhibitRules `json:"inhibitRules,omitempty"`
Receivers []Receivers `json:"receivers"`
Route Route `json:"route"`
}
// EmailConfig defines model for EmailConfig.
type EmailConfig struct {
AuthIdentity *openapiTypes.Email `json:"authIdentity,omitempty"`
AuthPassword *string `json:"authPassword,omitempty"`
AuthUsername *string `json:"authUsername,omitempty"`
From *openapiTypes.Email `json:"from,omitempty"`
SendResolved *bool `json:"sendResolved,omitempty"`
Smarthost *string `json:"smarthost,omitempty"`
To openapiTypes.Email `json:"to"`
}
// Error defines model for Error.
type Error struct {
Errors *[]map[string]string `json:"errors,omitempty"`
Message string `json:"message"`
}
// GetAlert defines model for GetAlert.
type GetAlert struct {
Data Alert `json:"data"`
Message string `json:"message"`
}
// Global defines model for Global.
type Global struct {
OpsgenieAPIKey *string `json:"opsgenieApiKey,omitempty"`
OpsgenieAPIURL *string `json:"opsgenieApiUrl,omitempty"`
ResolveTimeout *string `json:"resolveTimeout,omitempty"`
SmtpAuthIdentity *openapiTypes.Email `json:"smtpAuthIdentity,omitempty"`
SmtpAuthPassword *string `json:"smtpAuthPassword,omitempty"`
SmtpAuthUsername *string `json:"smtpAuthUsername,omitempty"`
SmtpFrom *openapiTypes.Email `json:"smtpFrom,omitempty"`
SmtpSmarthost *string `json:"smtpSmarthost,omitempty"`
}
// InhibitRules defines model for InhibitRules.
type InhibitRules struct {
Equal *[]string `json:"equal,omitempty"`
SourceMatch *map[string]string `json:"sourceMatch,omitempty"`
SourceMatchRe *map[string]string `json:"sourceMatchRe,omitempty"`
SourceMatchers *[]string `json:"sourceMatchers,omitempty"`
TargetMatch *map[string]string `json:"targetMatch,omitempty"`
TargetMatchRe *map[string]string `json:"targetMatchRe,omitempty"`
TargetMatchers *[]string `json:"targetMatchers,omitempty"`
}
// Message defines model for Message.
type Message struct {
Message string `json:"message"`
}
// OpsgenieConfig defines model for OpsgenieConfig.
type OpsgenieConfig struct {
APIKey *string `json:"apiKey,omitempty"`
APIURL *string `json:"apiUrl,omitempty"`
Priority *string `json:"priority,omitempty"`
SendResolved *bool `json:"sendResolved,omitempty"`
Tags *string `json:"tags,omitempty"`
}
// PermissionDenied defines model for PermissionDenied.
type PermissionDenied struct {
Detail string `json:"detail"`
}
// PutAlert defines model for PutAlert.
type PutAlert struct {
Data Alert `json:"data"`
Message string `json:"message"`
}
// Receivers defines model for Receivers.
type Receivers struct {
EmailConfigs *[]EmailConfig `json:"emailConfigs,omitempty"`
Name string `json:"name"`
OpsgenieConfigs *[]OpsgenieConfig `json:"opsgenieConfigs,omitempty"`
WebHookConfigs *[]WebHook `json:"webHookConfigs,omitempty"`
}
// ReceiversResponse defines model for ReceiversResponse.
type ReceiversResponse struct {
Data []Receivers `json:"data"`
Message string `json:"message"`
}
// ReceiversResponseSerializerSingle defines model for ReceiversResponseSerializerSingle.
type ReceiversResponseSerializerSingle struct {
Data Receivers `json:"data"`
Message string `json:"message"`
}
// Route defines model for Route.
type Route struct {
Continue *bool `json:"continue,omitempty"`
GroupBy *[]string `json:"groupBy,omitempty"`
GroupInterval *string `json:"groupInterval,omitempty"`
GroupWait *string `json:"groupWait,omitempty"`
Match *map[string]string `json:"match,omitempty"`
MatchRe *map[string]string `json:"matchRe,omitempty"`
Receiver string `json:"receiver"`
RepeatInterval *string `json:"repeatInterval,omitempty"`
Routes *[]RouteSerializer2 `json:"routes,omitempty"`
}
// RouteResponse defines model for RouteResponse.
type RouteResponse struct {
Data Route `json:"data"`
Message string `json:"message"`
}
// RouteSerializer2 defines model for RouteSerializer2.
type RouteSerializer2 struct {
Continue *bool `json:"continue,omitempty"`
GroupBy *[]string `json:"groupBy,omitempty"`
GroupInterval *string `json:"groupInterval,omitempty"`
GroupWait *string `json:"groupWait,omitempty"`
Match *map[string]string `json:"match,omitempty"`
MatchRe *map[string]string `json:"matchRe,omitempty"`
Matchers *[]string `json:"matchers,omitempty"`
Receiver string `json:"receiver"`
RepeatInterval *string `json:"repeatInterval,omitempty"`
Routes *[]map[string]string `json:"routes,omitempty"`
}
// WebHook defines model for WebHook.
type WebHook struct {
MsTeams *bool `json:"msTeams,omitempty"`
SendResolved *bool `json:"sendResolved,omitempty"`
URL string `json:"url"`
}
// UpdateJSONBody defines parameters for Update.
type UpdateJSONBody struct {
// Global Global config. If nothing passed the default argus config will be used.
Global *struct {
// OpsgenieApiKey Opsgenie api key
// `Additional Validators:`
// * should only include the characters: a-zA-Z0-9-
OpsgenieAPIKey *string `json:"opsgenieApiKey,omitempty"`
// OpsgenieApiUrl Opsgenie api url
// `Additional Validators:`
// * must be a syntactically valid url address
OpsgenieAPIURL *string `json:"opsgenieApiUrl,omitempty"`
// ResolveTimeout ResolveTimeout is the default value used by alertmanager if the alert does not include EndsAt, after this time passes it can declare the alert as resolved if it has not been updated. This has no impact on alerts from Prometheus, as they always include EndsAt.
// `Additional Validators:`
// * must be a valid time format
ResolveTimeout *string `json:"resolveTimeout,omitempty"`
// SmtpAuthIdentity Auth identity.
// `Additional Validators:`
// * must be a syntactically valid email address
SmtpAuthIdentity *string `json:"smtpAuthIdentity,omitempty"`
// SmtpAuthPassword SMTP Auth using LOGIN and PLAIN.
SmtpAuthPassword *string `json:"smtpAuthPassword,omitempty"`
// SmtpAuthUsername SMTP Auth using CRAM-MD5, LOGIN and PLAIN. If empty, Alertmanager doesn't authenticate to the SMTP server.
SmtpAuthUsername *string `json:"smtpAuthUsername,omitempty"`
// SmtpFrom The default SMTP From header field.
// `Additional Validators:`
// * must be a syntactically valid email address
SmtpFrom *string `json:"smtpFrom,omitempty"`
// SmtpSmarthost The default SMTP smarthost used for sending emails, including port number. Port number usually is 25, or 587 for SMTP over TLS (sometimes referred to as STARTTLS). Example: smtp.example.org:587
// `Additional Validators:`
// * should only include the characters: a-zA-Z0-9_./@&?:-
SmtpSmarthost *string `json:"smtpSmarthost,omitempty"`
} `json:"global,omitempty"`
// InhibitRules A list of inhibition rules.
InhibitRules *struct {
// Equal Labels that must have an equal value in the source and target alert for the inhibition to take effect.
// `Additional Validators:`
// * should only include the characters: a-zA-Z0-9_./@&?:-
Equal *[]string `json:"equal,omitempty"`
// SourceMatch map of key:value. Matchers for which one or more alerts have to exist for the inhibition to take effect.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not have more than 200 characters
// * each key and value should only include the characters: a-zA-Z0-9_./@&?:-
SourceMatch *map[string]interface{} `json:"sourceMatch,omitempty"`
// SourceMatchRe map of key:value. Regex match
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not have more than 200 characters
SourceMatchRe *map[string]interface{} `json:"sourceMatchRe,omitempty"`
// TargetMatch map of key:value. Matchers that have to be fulfilled in the alerts to be muted.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not have more than 200 characters
// * each key and value should only include the characters: a-zA-Z0-9_./@&?:-
TargetMatch *map[string]interface{} `json:"targetMatch,omitempty"`
// TargetMatchRe map of key:value. Matchers that have to be fulfilled in the alerts to be muted. Regex.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not have more than 200 characters
TargetMatchRe *map[string]interface{} `json:"targetMatchRe,omitempty"`
} `json:"inhibitRules,omitempty"`
// Receivers A list of notification receivers.
Receivers []struct {
// EmailConfigs Email configurations
EmailConfigs *[]struct {
// AuthIdentity SMTP authentication information.
// `Additional Validators:`
// * must be a syntactically valid email address
AuthIdentity *string `json:"authIdentity,omitempty"`
// AuthPassword SMTP authentication information.
AuthPassword *string `json:"authPassword,omitempty"`
// AuthUsername SMTP authentication information.
AuthUsername *string `json:"authUsername,omitempty"`
// From The sender address.
// `Additional Validators:`
// * must be a syntactically valid email address
From *string `json:"from,omitempty"`
// Smarthost The SMTP host through which emails are sent.
// `Additional Validators:`
// * should only include the characters: a-zA-Z0-9_./@&?:-
Smarthost *string `json:"smarthost,omitempty"`
// To The email address to send notifications to.
// `Additional Validators:`
// * must be a syntactically valid email address
To *string `json:"to,omitempty"`
} `json:"emailConfigs,omitempty"`
// Name `Additional Validators:`
// * must be unique
// * should only include the characters: a-zA-Z0-9-
Name string `json:"name"`
// OpsgenieConfigs Configuration for ops genie.
OpsgenieConfigs *[]struct {
// ApiKey The API key to use when talking to the OpsGenie API.
// `Additional Validators:`
// * should only include the characters: a-zA-Z0-9-
APIKey *string `json:"apiKey,omitempty"`
// ApiUrl The host to send OpsGenie API requests to.
// `Additional Validators:`
// * must be a syntactically valid url address
APIURL *string `json:"apiUrl,omitempty"`
// Tags Comma separated list of tags attached to the notifications.
Tags *string `json:"tags,omitempty"`
} `json:"opsgenieConfigs,omitempty"`
WebHookConfigs *[]struct {
// MsTeams Microsoft Teams webhooks require special handling. If you set this property to true, it is treated as such
MsTeams *bool `json:"msTeams,omitempty"`
// Url The endpoint to send HTTP POST requests to.
// `Additional Validators:`
// * must be a syntactically valid url address
URL *string `json:"url,omitempty"`
} `json:"webHookConfigs,omitempty"`
} `json:"receivers"`
// Route The root node of the routing tree.
Route struct {
// GroupBy The labels by which incoming alerts are grouped together. For example, multiple alerts coming in for cluster=A and alertname=LatencyHigh would be batched into a single group. To aggregate by all possible labels use the special value '...' as the sole label name, for example: group_by: ['...']. This effectively disables aggregation entirely, passing through all alerts as-is. This is unlikely to be what you want, unless you have a very low alert volume or your upstream notification system performs its own grouping.
GroupBy *[]string `json:"groupBy,omitempty"`
// GroupInterval How long to wait before sending a notification about new alerts that are added to a group of alerts for which an initial notification has already been sent. (Usually ~5m or more.)
// `Additional Validators:`
// * must be a valid time format
GroupInterval *string `json:"groupInterval,omitempty"`
// GroupWait How long to initially wait to send a notification for a group of alerts. Allows to wait for an inhibiting alert to arrive or collect more initial alerts for the same group. (Usually ~0s to few minutes.)
// `Additional Validators:`
// * must be a valid time format
GroupWait *string `json:"groupWait,omitempty"`
// Match map of key:value. A set of equality matchers an alert has to fulfill to match the node.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not be longer than 200 characters
// * key and values should only include the characters: a-zA-Z0-9_./@&?:-
Match *map[string]interface{} `json:"match,omitempty"`
// MatchRe map of key:value. A set of regex-matchers an alert has to fulfill to match the node.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not be longer than 200 characters
MatchRe *map[string]interface{} `json:"matchRe,omitempty"`
// Matchers A list of matchers that an alert has to fulfill to match the node. A matcher is a string with a syntax inspired by PromQL and OpenMetrics. The syntax of a matcher consists of three tokens:
// * A valid Prometheus label name.
// * One of =, !=, =~, or !~. = means equals, != means that the strings are not equal, =~ is used for equality of regex expressions and !~ is used for un-equality of regex expressions. They have the same meaning as known from PromQL selectors.
// * A UTF-8 string, which may be enclosed in double quotes. Before or after each token, there may be any amount of whitespace.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not be longer than 200 characters
Matchers *[]string `json:"matchers,omitempty"`
// Receiver Receiver that should be one item of receivers
// `Additional Validators:`
// * must be a in name of receivers
Receiver string `json:"receiver"`
// RepeatInterval How long to wait before sending a notification again if it has already been sent successfully for an alert. (Usually ~3h or more).
// `Additional Validators:`
// * must be a valid time format
RepeatInterval *string `json:"repeatInterval,omitempty"`
// Routes Zero or more child routes.
Routes *[]struct {
GroupBy *[]string `json:"groupBy,omitempty"`
// GroupInterval As in one level above
GroupInterval *string `json:"groupInterval,omitempty"`
// GroupWait As in one level above
GroupWait *string `json:"groupWait,omitempty"`
// Match As in one level above
Match *map[string]interface{} `json:"match,omitempty"`
// MatchRe As in one level above
MatchRe *map[string]interface{} `json:"matchRe,omitempty"`
// Receiver As in one level above
Receiver *string `json:"receiver,omitempty"`
// RepeatInterval As in one level above
RepeatInterval *string `json:"repeatInterval,omitempty"`
// Routes Another child routes
Routes *[]map[string]interface{} `json:"routes,omitempty"`
} `json:"routes,omitempty"`
} `json:"route"`
}
// ReceiversCreateJSONBody defines parameters for ReceiversCreate.
type ReceiversCreateJSONBody struct {
// EmailConfigs Email configurations
EmailConfigs *[]struct {
// AuthIdentity SMTP authentication information.
// `Additional Validators:`
// * must be a syntactically valid email address
AuthIdentity *string `json:"authIdentity,omitempty"`
// AuthPassword SMTP authentication information.
AuthPassword *string `json:"authPassword,omitempty"`
// AuthUsername SMTP authentication information.
AuthUsername *string `json:"authUsername,omitempty"`
// From The sender address.
// `Additional Validators:`
// * must be a syntactically valid email address
From *string `json:"from,omitempty"`
// Smarthost The SMTP host through which emails are sent.
// `Additional Validators:`
// * should only include the characters: a-zA-Z0-9_./@&?:-
Smarthost *string `json:"smarthost,omitempty"`
// To The email address to send notifications to.
// `Additional Validators:`
// * must be a syntactically valid email address
To *string `json:"to,omitempty"`
} `json:"emailConfigs,omitempty"`
// Name `Additional Validators:`
// * must be unique
// * should only include the characters: a-zA-Z0-9-
Name string `json:"name"`
// OpsgenieConfigs Configuration for ops genie.
OpsgenieConfigs *[]struct {
// ApiKey The API key to use when talking to the OpsGenie API.
// `Additional Validators:`
// * should only include the characters: a-zA-Z0-9-
APIKey *string `json:"apiKey,omitempty"`
// ApiUrl The host to send OpsGenie API requests to.
// `Additional Validators:`
// * must be a syntactically valid url address
APIURL *string `json:"apiUrl,omitempty"`
// Tags Comma separated list of tags attached to the notifications.
Tags *string `json:"tags,omitempty"`
} `json:"opsgenieConfigs,omitempty"`
WebHookConfigs *[]struct {
// MsTeams Microsoft Teams webhooks require special handling. If you set this property to true, it is treated as such
MsTeams *bool `json:"msTeams,omitempty"`
// Url The endpoint to send HTTP POST requests to.
// `Additional Validators:`
// * must be a syntactically valid url address
URL *string `json:"url,omitempty"`
} `json:"webHookConfigs,omitempty"`
}
// ReceiversUpdateJSONBody defines parameters for ReceiversUpdate.
type ReceiversUpdateJSONBody struct {
// EmailConfigs Email configurations
EmailConfigs *[]struct {
// AuthIdentity SMTP authentication information.
// `Additional Validators:`
// * must be a syntactically valid email address
AuthIdentity *string `json:"authIdentity,omitempty"`
// AuthPassword SMTP authentication information.
AuthPassword *string `json:"authPassword,omitempty"`
// AuthUsername SMTP authentication information.
AuthUsername *string `json:"authUsername,omitempty"`
// From The sender address.
// `Additional Validators:`
// * must be a syntactically valid email address
From *string `json:"from,omitempty"`
// Smarthost The SMTP host through which emails are sent.
// `Additional Validators:`
// * should only include the characters: a-zA-Z0-9_./@&?:-
Smarthost *string `json:"smarthost,omitempty"`
// To The email address to send notifications to.
// `Additional Validators:`
// * must be a syntactically valid email address
To *string `json:"to,omitempty"`
} `json:"emailConfigs,omitempty"`
// Name `Additional Validators:`
// * must be unique
// * should only include the characters: a-zA-Z0-9-
Name string `json:"name"`
// OpsgenieConfigs Configuration for ops genie.
OpsgenieConfigs *[]struct {
// ApiKey The API key to use when talking to the OpsGenie API.
// `Additional Validators:`
// * should only include the characters: a-zA-Z0-9-
APIKey *string `json:"apiKey,omitempty"`
// ApiUrl The host to send OpsGenie API requests to.
// `Additional Validators:`
// * must be a syntactically valid url address
APIURL *string `json:"apiUrl,omitempty"`
// Tags Comma separated list of tags attached to the notifications.
Tags *string `json:"tags,omitempty"`
} `json:"opsgenieConfigs,omitempty"`
WebHookConfigs *[]struct {
// MsTeams Microsoft Teams webhooks require special handling. If you set this property to true, it is treated as such
MsTeams *bool `json:"msTeams,omitempty"`
// Url The endpoint to send HTTP POST requests to.
// `Additional Validators:`
// * must be a syntactically valid url address
URL *string `json:"url,omitempty"`
} `json:"webHookConfigs,omitempty"`
}
// RoutesCreateJSONBody defines parameters for RoutesCreate.
type RoutesCreateJSONBody struct {
// GroupBy The labels by which incoming alerts are grouped together. For example, multiple alerts coming in for cluster=A and alertname=LatencyHigh would be batched into a single group. To aggregate by all possible labels use the special value '...' as the sole label name, for example: group_by: ['...']. This effectively disables aggregation entirely, passing through all alerts as-is. This is unlikely to be what you want, unless you have a very low alert volume or your upstream notification system performs its own grouping.
GroupBy *[]string `json:"groupBy,omitempty"`
// GroupInterval How long to wait before sending a notification about new alerts that are added to a group of alerts for which an initial notification has already been sent. (Usually ~5m or more.)
// `Additional Validators:`
// * must be a valid time format
GroupInterval *string `json:"groupInterval,omitempty"`
// GroupWait How long to initially wait to send a notification for a group of alerts. Allows to wait for an inhibiting alert to arrive or collect more initial alerts for the same group. (Usually ~0s to few minutes.)
// `Additional Validators:`
// * must be a valid time format
GroupWait *string `json:"groupWait,omitempty"`
// Match map of key:value. A set of equality matchers an alert has to fulfill to match the node.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not be longer than 200 characters
// * key and values should only include the characters: a-zA-Z0-9_./@&?:-
Match *map[string]interface{} `json:"match,omitempty"`
// MatchRe map of key:value. A set of regex-matchers an alert has to fulfill to match the node.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not be longer than 200 characters
MatchRe *map[string]interface{} `json:"matchRe,omitempty"`
// Matchers A list of matchers that an alert has to fulfill to match the node. A matcher is a string with a syntax inspired by PromQL and OpenMetrics. The syntax of a matcher consists of three tokens:
// * A valid Prometheus label name.
// * One of =, !=, =~, or !~. = means equals, != means that the strings are not equal, =~ is used for equality of regex expressions and !~ is used for un-equality of regex expressions. They have the same meaning as known from PromQL selectors.
// * A UTF-8 string, which may be enclosed in double quotes. Before or after each token, there may be any amount of whitespace.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not be longer than 200 characters
Matchers *[]string `json:"matchers,omitempty"`
// Receiver Receiver that should be one item of receivers
// `Additional Validators:`
// * must be a in name of receivers
Receiver string `json:"receiver"`
// RepeatInterval How long to wait before sending a notification again if it has already been sent successfully for an alert. (Usually ~3h or more).
// `Additional Validators:`
// * must be a valid time format
RepeatInterval *string `json:"repeatInterval,omitempty"`
// Routes Zero or more child routes.
Routes *[]struct {
GroupBy *[]string `json:"groupBy,omitempty"`
// GroupInterval As in one level above
GroupInterval *string `json:"groupInterval,omitempty"`
// GroupWait As in one level above
GroupWait *string `json:"groupWait,omitempty"`
// Match As in one level above
Match *map[string]interface{} `json:"match,omitempty"`
// MatchRe As in one level above
MatchRe *map[string]interface{} `json:"matchRe,omitempty"`
// Receiver As in one level above
Receiver *string `json:"receiver,omitempty"`
// RepeatInterval As in one level above
RepeatInterval *string `json:"repeatInterval,omitempty"`
// Routes Another child routes
Routes *[]map[string]interface{} `json:"routes,omitempty"`
} `json:"routes,omitempty"`
}
// RoutesUpdateJSONBody defines parameters for RoutesUpdate.
type RoutesUpdateJSONBody struct {
// GroupBy The labels by which incoming alerts are grouped together. For example, multiple alerts coming in for cluster=A and alertname=LatencyHigh would be batched into a single group. To aggregate by all possible labels use the special value '...' as the sole label name, for example: group_by: ['...']. This effectively disables aggregation entirely, passing through all alerts as-is. This is unlikely to be what you want, unless you have a very low alert volume or your upstream notification system performs its own grouping.
GroupBy *[]string `json:"groupBy,omitempty"`
// GroupInterval How long to wait before sending a notification about new alerts that are added to a group of alerts for which an initial notification has already been sent. (Usually ~5m or more.)
// `Additional Validators:`
// * must be a valid time format
GroupInterval *string `json:"groupInterval,omitempty"`
// GroupWait How long to initially wait to send a notification for a group of alerts. Allows to wait for an inhibiting alert to arrive or collect more initial alerts for the same group. (Usually ~0s to few minutes.)
// `Additional Validators:`
// * must be a valid time format
GroupWait *string `json:"groupWait,omitempty"`
// Match map of key:value. A set of equality matchers an alert has to fulfill to match the node.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not be longer than 200 characters
// * key and values should only include the characters: a-zA-Z0-9_./@&?:-
Match *map[string]interface{} `json:"match,omitempty"`
// MatchRe map of key:value. A set of regex-matchers an alert has to fulfill to match the node.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not be longer than 200 characters
MatchRe *map[string]interface{} `json:"matchRe,omitempty"`
// Matchers A list of matchers that an alert has to fulfill to match the node. A matcher is a string with a syntax inspired by PromQL and OpenMetrics. The syntax of a matcher consists of three tokens:
// * A valid Prometheus label name.
// * One of =, !=, =~, or !~. = means equals, != means that the strings are not equal, =~ is used for equality of regex expressions and !~ is used for un-equality of regex expressions. They have the same meaning as known from PromQL selectors.
// * A UTF-8 string, which may be enclosed in double quotes. Before or after each token, there may be any amount of whitespace.
// `Additional Validators:`
// * should not contain more than 5 keys
// * each key and value should not be longer than 200 characters
Matchers *[]string `json:"matchers,omitempty"`
// Receiver Receiver that should be one item of receivers
// `Additional Validators:`
// * must be a in name of receivers
Receiver string `json:"receiver"`
// RepeatInterval How long to wait before sending a notification again if it has already been sent successfully for an alert. (Usually ~3h or more).
// `Additional Validators:`
// * must be a valid time format
RepeatInterval *string `json:"repeatInterval,omitempty"`
// Routes Zero or more child routes.
Routes *[]struct {
GroupBy *[]string `json:"groupBy,omitempty"`
// GroupInterval As in one level above
GroupInterval *string `json:"groupInterval,omitempty"`
// GroupWait As in one level above
GroupWait *string `json:"groupWait,omitempty"`
// Match As in one level above
Match *map[string]interface{} `json:"match,omitempty"`
// MatchRe As in one level above
MatchRe *map[string]interface{} `json:"matchRe,omitempty"`
// Receiver As in one level above
Receiver *string `json:"receiver,omitempty"`
// RepeatInterval As in one level above
RepeatInterval *string `json:"repeatInterval,omitempty"`
// Routes Another child routes
Routes *[]map[string]interface{} `json:"routes,omitempty"`
} `json:"routes,omitempty"`
}
// UpdateJSONRequestBody defines body for Update for application/json ContentType.
type UpdateJSONRequestBody UpdateJSONBody
// ReceiversCreateJSONRequestBody defines body for ReceiversCreate for application/json ContentType.
type ReceiversCreateJSONRequestBody ReceiversCreateJSONBody
// ReceiversUpdateJSONRequestBody defines body for ReceiversUpdate for application/json ContentType.
type ReceiversUpdateJSONRequestBody ReceiversUpdateJSONBody
// RoutesCreateJSONRequestBody defines body for RoutesCreate for application/json ContentType.
type RoutesCreateJSONRequestBody RoutesCreateJSONBody
// RoutesUpdateJSONRequestBody defines body for RoutesUpdate for application/json ContentType.
type RoutesUpdateJSONRequestBody RoutesUpdateJSONBody
// RequestEditorFn is the function signature for the RequestEditor callback function
type RequestEditorFn func(ctx context.Context, req *http.Request) error
// Client which conforms to the OpenAPI3 specification for this service.
type Client struct {
// The endpoint of the server conforming to this interface, with scheme,
// https://api.deepmap.com for example. This can contain a path relative
// to the server, such as https://api.deepmap.com/dev-test, and all the
// paths in the swagger spec will be appended to the server.
Server string
// Doer for performing requests, typically a *http.Client with any
// customized settings, such as certificate chains.
Client contracts.BaseClientInterface
}
// NewRawClient Creates a new Client, with reasonable defaults
func NewRawClient(server string, httpClient contracts.BaseClientInterface) *Client {
// create a client with sane default values
client := Client{
Server: server,
Client: httpClient,
}
return &client
}
// The interface specification for the client above.
type rawClientInterface interface {
// List request
ListRaw(ctx context.Context, projectID string, instanceID string, reqEditors ...RequestEditorFn) (*http.Response, error)
// Update request with any body
UpdateRawWithBody(ctx context.Context, projectID string, instanceID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
UpdateRaw(ctx context.Context, projectID string, instanceID string, body UpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// ReceiversList request
ReceiversListRaw(ctx context.Context, projectID string, instanceID string, reqEditors ...RequestEditorFn) (*http.Response, error)
// ReceiversCreate request with any body
ReceiversCreateRawWithBody(ctx context.Context, projectID string, instanceID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
ReceiversCreateRaw(ctx context.Context, projectID string, instanceID string, body ReceiversCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// ReceiversDelete request
ReceiversDeleteRaw(ctx context.Context, projectID string, instanceID string, receiver string, reqEditors ...RequestEditorFn) (*http.Response, error)
// ReceiversRead request
ReceiversReadRaw(ctx context.Context, projectID string, instanceID string, receiver string, reqEditors ...RequestEditorFn) (*http.Response, error)
// ReceiversUpdate request with any body
ReceiversUpdateRawWithBody(ctx context.Context, projectID string, instanceID string, receiver string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
ReceiversUpdateRaw(ctx context.Context, projectID string, instanceID string, receiver string, body ReceiversUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// RoutesList request
RoutesListRaw(ctx context.Context, projectID string, instanceID string, reqEditors ...RequestEditorFn) (*http.Response, error)
// RoutesCreate request with any body
RoutesCreateRawWithBody(ctx context.Context, projectID string, instanceID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
RoutesCreateRaw(ctx context.Context, projectID string, instanceID string, body RoutesCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// RoutesDelete request
RoutesDeleteRaw(ctx context.Context, projectID string, instanceID string, receiver string, reqEditors ...RequestEditorFn) (*http.Response, error)
// RoutesRead request
RoutesReadRaw(ctx context.Context, projectID string, instanceID string, receiver string, reqEditors ...RequestEditorFn) (*http.Response, error)
// RoutesUpdate request with any body
RoutesUpdateRawWithBody(ctx context.Context, projectID string, instanceID string, receiver string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
RoutesUpdateRaw(ctx context.Context, projectID string, instanceID string, receiver string, body RoutesUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}
func (c *Client) ListRaw(ctx context.Context, projectID string, instanceID string, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewListRequest(ctx, c.Server, projectID, instanceID)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) UpdateRawWithBody(ctx context.Context, projectID string, instanceID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewUpdateRequestWithBody(ctx, c.Server, projectID, instanceID, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) UpdateRaw(ctx context.Context, projectID string, instanceID string, body UpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewUpdateRequest(ctx, c.Server, projectID, instanceID, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) ReceiversListRaw(ctx context.Context, projectID string, instanceID string, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewReceiversListRequest(ctx, c.Server, projectID, instanceID)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) ReceiversCreateRawWithBody(ctx context.Context, projectID string, instanceID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewReceiversCreateRequestWithBody(ctx, c.Server, projectID, instanceID, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) ReceiversCreateRaw(ctx context.Context, projectID string, instanceID string, body ReceiversCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewReceiversCreateRequest(ctx, c.Server, projectID, instanceID, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) ReceiversDeleteRaw(ctx context.Context, projectID string, instanceID string, receiver string, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewReceiversDeleteRequest(ctx, c.Server, projectID, instanceID, receiver)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) ReceiversReadRaw(ctx context.Context, projectID string, instanceID string, receiver string, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewReceiversReadRequest(ctx, c.Server, projectID, instanceID, receiver)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) ReceiversUpdateRawWithBody(ctx context.Context, projectID string, instanceID string, receiver string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewReceiversUpdateRequestWithBody(ctx, c.Server, projectID, instanceID, receiver, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) ReceiversUpdateRaw(ctx context.Context, projectID string, instanceID string, receiver string, body ReceiversUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewReceiversUpdateRequest(ctx, c.Server, projectID, instanceID, receiver, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) RoutesListRaw(ctx context.Context, projectID string, instanceID string, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewRoutesListRequest(ctx, c.Server, projectID, instanceID)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) RoutesCreateRawWithBody(ctx context.Context, projectID string, instanceID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewRoutesCreateRequestWithBody(ctx, c.Server, projectID, instanceID, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) RoutesCreateRaw(ctx context.Context, projectID string, instanceID string, body RoutesCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewRoutesCreateRequest(ctx, c.Server, projectID, instanceID, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) RoutesDeleteRaw(ctx context.Context, projectID string, instanceID string, receiver string, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewRoutesDeleteRequest(ctx, c.Server, projectID, instanceID, receiver)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) RoutesReadRaw(ctx context.Context, projectID string, instanceID string, receiver string, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewRoutesReadRequest(ctx, c.Server, projectID, instanceID, receiver)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) RoutesUpdateRawWithBody(ctx context.Context, projectID string, instanceID string, receiver string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewRoutesUpdateRequestWithBody(ctx, c.Server, projectID, instanceID, receiver, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) RoutesUpdateRaw(ctx context.Context, projectID string, instanceID string, receiver string, body RoutesUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewRoutesUpdateRequest(ctx, c.Server, projectID, instanceID, receiver, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
// NewListRequest generates requests for List
func NewListRequest(ctx context.Context, server string, projectID string, instanceID string) (*http.Request, error) {
var err error
var pathParam0 string
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID)
if err != nil {
return nil, err
}
var pathParam1 string
pathParam1, err = runtime.StyleParamWithLocation("simple", false, "instanceID", runtime.ParamLocationPath, instanceID)
if err != nil {
return nil, err
}
serverURL, err := url.Parse(server)
if err != nil {
return nil, err
}
operationPath := fmt.Sprintf("/v1/projects/%s/instances/%s/alertconfigs", pathParam0, pathParam1)
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
queryURL, err := serverURL.Parse(operationPath)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "GET", queryURL.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// NewUpdateRequest calls the generic Update builder with application/json body
func NewUpdateRequest(ctx context.Context, server string, projectID string, instanceID string, body UpdateJSONRequestBody) (*http.Request, error) {
var bodyReader io.Reader
buf, err := json.Marshal(body)
if err != nil {
return nil, err
}
bodyReader = bytes.NewReader(buf)
return NewUpdateRequestWithBody(ctx, server, projectID, instanceID, "application/json", bodyReader)
}
// NewUpdateRequestWithBody generates requests for Update with any type of body
func NewUpdateRequestWithBody(ctx context.Context, server string, projectID string, instanceID string, contentType string, body io.Reader) (*http.Request, error) {
var err error