Documentation ¶
Overview ¶
Package oncall allows you to synchronise other services with the emails of users who are currently on-call for a schedule.
Note: On-call is readonly, and so you can only use this as a source.
Requirements ¶
You will need to create an API Key with the following access rights:
- Read
Examples ¶
See [New] and Init.
Index ¶
Examples ¶
Constants ¶
View Source
const OpsgenieAPIKey gosync.ConfigKey = "opsgenie_api_key" //nolint:gosec
OpsgenieAPIKey is an API key for authenticating with Opsgenie.
View Source
const ScheduleID gosync.ConfigKey = "schedule_id"
ScheduleID is the name of the Opsgenie Schedule ID.
Variables ¶
This section is empty.
Functions ¶
func WithClient ¶ added in v0.14.0
WithClient passes a custom Opsgenie Schedule client to the adapter.
Example ¶
package main import ( "context" "log" "github.com/opsgenie/opsgenie-go-sdk-v2/client" "github.com/opsgenie/opsgenie-go-sdk-v2/schedule" gosync "github.com/ovotech/go-sync" "github.com/ovotech/go-sync/adapters/opsgenie/oncall" ) func main() { ctx := context.Background() scheduleClient, err := schedule.NewClient(&client.Config{ ApiKey: "default", }) if err != nil { log.Fatal(err) } adapter, err := oncall.Init(ctx, map[gosync.ConfigKey]string{ oncall.ScheduleID: "opsgenie-schedule-id", }, oncall.WithClient(scheduleClient)) if err != nil { log.Fatal(err) } gosync.New(adapter) }
Output:
func WithLogger ¶ added in v0.14.0
WithLogger passes a custom logger to the adapter.
Example ¶
package main import ( "context" "log" "os" gosync "github.com/ovotech/go-sync" "github.com/ovotech/go-sync/adapters/opsgenie/oncall" ) func main() { ctx := context.Background() logger := log.New(os.Stdout, "", log.LstdFlags) adapter, err := oncall.Init(ctx, map[gosync.ConfigKey]string{ oncall.OpsgenieAPIKey: "default", oncall.ScheduleID: "opsgenie-schedule-id", }, oncall.WithLogger(logger)) if err != nil { log.Fatal(err) } gosync.New(adapter) }
Output:
Types ¶
type OnCall ¶
func Init ¶ added in v0.7.0
func Init( _ context.Context, config map[gosync.ConfigKey]string, configFns ...gosync.ConfigFn[*OnCall], ) (*OnCall, error)
Init a new Opsgenie OnCall gosync.Adapter.
Required config:
Example ¶
package main import ( "context" "log" gosync "github.com/ovotech/go-sync" "github.com/ovotech/go-sync/adapters/opsgenie/oncall" ) func main() { ctx := context.Background() adapter, err := oncall.Init(ctx, map[gosync.ConfigKey]string{ oncall.OpsgenieAPIKey: "default", oncall.ScheduleID: "opsgenie-schedule-id", }) if err != nil { log.Fatal(err) } gosync.New(adapter) }
Output:
Click to show internal directories.
Click to hide internal directories.