@@ -23,6 +23,7 @@ import (
23
23
const (
24
24
alertConfigurationPath = "api/public/v1.0/groups/%s/alertConfigs"
25
25
fieldNamesPath = "api/public/v1.0/alertConfigs/matchers/fieldNames"
26
+ testNotificationPath = alertConfigurationPath + "/%s/%s/test"
26
27
)
27
28
28
29
// AlertConfigurationsService provides access to the alert configuration related functions in the Ops Manager API.
@@ -35,6 +36,7 @@ type AlertConfigurationsService interface {
35
36
ListMatcherFields (ctx context.Context ) ([]string , * Response , error )
36
37
Update (context.Context , string , string , * AlertConfiguration ) (* AlertConfiguration , * Response , error )
37
38
Delete (context.Context , string , string ) (* Response , error )
39
+ TestExistingNotification (context.Context , string , string , string ) (* Response , error )
38
40
}
39
41
40
42
// AlertConfigurationsServiceOp handles communication with the AlertConfiguration related methods.
@@ -124,6 +126,8 @@ type Notification struct {
124
126
MicrosoftTeamsWebhookURL string `json:"microsoftTeamsWebhookUrl,omitempty"` // Microsoft Teams Wewbhook URL
125
127
WebhookSecret string `json:"webhookSecret,omitempty"` // Webhook Secret
126
128
WebhookURL string `json:"webhookUrl,omitempty"` // Webhook URL
129
+ WebhookHeadersTemplate string `json:"webhookHeadersTemplate,omitempty"` // Freemarker-syntax template to customize webhook request headers.
130
+ WebhookBodyTemplate string `json:"webhookBodyTemplate,omitempty"` // Freemarker-syntax template to customize webhook request body.
127
131
}
128
132
129
133
// AlertConfigurationsResponse is the response from the AlertConfigurationsService.List.
@@ -359,3 +363,34 @@ func (s *AlertConfigurationsServiceOp) ListMatcherFields(ctx context.Context) ([
359
363
360
364
return root , resp , err
361
365
}
366
+
367
+ // TestAlertConfiguration fires a test notification to the alert configuration.
368
+ //
369
+ // TODO: Update this when documentation is published. See more: https://docs.opsmanager.mongodb.com/current/reference/api/TBD
370
+ func (s * AlertConfigurationsServiceOp ) TestExistingNotification (ctx context.Context , groupID string , alertConfigID string , notificationID string ) (* Response , error ) {
371
+ if groupID == "" {
372
+ return nil , NewArgError ("groupID" , "must be set" )
373
+ }
374
+
375
+ if alertConfigID == "" {
376
+ return nil , NewArgError ("alertConfigID" , "must be set" )
377
+ }
378
+
379
+ if notificationID == "" {
380
+ return nil , NewArgError ("notificationID" , "must be set" )
381
+ }
382
+
383
+ path := fmt .Sprintf (testNotificationPath , groupID , alertConfigID , notificationID )
384
+
385
+ req , err := s .Client .NewRequest (ctx , http .MethodPost , path , nil )
386
+ if err != nil {
387
+ return nil , err
388
+ }
389
+
390
+ resp , err := s .Client .Do (ctx , req , nil )
391
+ if err != nil {
392
+ return resp , err
393
+ }
394
+
395
+ return resp , err
396
+ }
0 commit comments