-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy pathdoc.go
46 lines (46 loc) · 1.67 KB
/
doc.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
// Package pagerduty provides a notifier implementation that sends notifications via PagerDuty.
// It uses the PagerDuty API to create incidents based on the provided configuration.
//
// Usage:
// To use this package, you need to create a new instance of PagerDuty with your API token.
// You can then configure it with the necessary details like the sender's address and receivers.
// Finally, you can send notifications which will create incidents in PagerDuty.
//
// Example:
//
// package main
//
// import (
// "context"
// "log"
//
// "github.com/nikoksr/notify"
// "github.com/nikoksr/notify/service/pagerduty"
// )
//
// func main() {
// // Create a new PagerDuty service. Replace 'your_pagerduty_api_token' with your actual PagerDuty API token.
// pagerDutyService, err := pagerduty.New("your_pagerduty_api_token")
// if err != nil {
// log.Fatalf("failed to create pagerduty service: %s", err)
// }
//
// // Set the sender address and add receivers.
// pagerDutyService.SetFromAddress("[email protected]")
// pagerDutyService.AddReceivers("ServiceDirectory1", "ServiceDirectory2")
//
// // Create a notifier instance and register the PagerDuty service to it.
// notifier := notify.New()
// notifier.UseServices(pagerDutyService)
//
// // Send a notification.
// err = notifier.Send(context.Background(), "Test Alert", "This is a test alert from PagerDuty service.")
// if err != nil {
// log.Fatalf("failed to send notification: %s", err)
// }
//
// log.Println("Notification sent successfully")
// }
//
// This package requires a valid PagerDuty API token to authenticate requests.
package pagerduty