Documentation ¶
Overview ¶
Package schedule allows you to synchronise the participants of a schedule.
Using this as a source supports schedule with multiple rotations, however if you wish to use this as a destination adapter the schedule must only have 1 rotation configured, and all members of the source adapter must already have an Opsgenie license allocated.
Requirements ¶
You will need to create an API Key with the following access rights:
- Read
- Update
Examples ¶
See [New] and Init.
Index ¶
Examples ¶
Constants ¶
const OpsgenieAPIKey gosync.ConfigKey = "opsgenie_api_key" //nolint:gosec
OpsgenieAPIKey is an API key for authenticating with Opsgenie.
const ScheduleID gosync.ConfigKey = "schedule_id"
ScheduleID is the name of the Opsgenie Schedule ID.
Variables ¶
var ( ErrMultipleRotations = errors.New("gosync can only manage schedules with a single rotation") ErrNoRotations = errors.New("gosync cannot create rotations - you must have 1 already defined for schedule") )
Functions ¶
func WithClient ¶ added in v0.14.0
func WithClient(client *ogSchedule.Client) gosync.ConfigFn[*Schedule]
WithClient passes a custom Opsgenie Schedule client to the adapter.
Example ¶
package main import ( "context" "log" "github.com/opsgenie/opsgenie-go-sdk-v2/client" ogSchedule "github.com/opsgenie/opsgenie-go-sdk-v2/schedule" gosync "github.com/ovotech/go-sync" "github.com/ovotech/go-sync/adapters/opsgenie/schedule" ) func main() { ctx := context.Background() scheduleClient, err := ogSchedule.NewClient(&client.Config{ ApiKey: "default", }) if err != nil { log.Fatal(err) } adapter, err := schedule.Init(ctx, map[gosync.ConfigKey]string{ schedule.ScheduleID: "opsgenie-schedule-id", }, schedule.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/schedule" ) func main() { ctx := context.Background() logger := log.New(os.Stdout, "", log.LstdFlags) adapter, err := schedule.Init(ctx, map[gosync.ConfigKey]string{ schedule.OpsgenieAPIKey: "default", schedule.ScheduleID: "opsgenie-schedule-id", }, schedule.WithLogger(logger)) if err != nil { log.Fatal(err) } gosync.New(adapter) }
Output:
Types ¶
type Schedule ¶
func Init ¶ added in v0.7.0
func Init( _ context.Context, config map[gosync.ConfigKey]string, configFns ...gosync.ConfigFn[*Schedule], ) (*Schedule, error)
Init a new Opsgenie Schedule gosync.Adapter.
Required config:
Example ¶
package main import ( "context" "log" gosync "github.com/ovotech/go-sync" "github.com/ovotech/go-sync/adapters/opsgenie/schedule" ) func main() { ctx := context.Background() adapter, err := schedule.Init(ctx, map[gosync.ConfigKey]string{ schedule.OpsgenieAPIKey: "default", schedule.ScheduleID: "opsgenie-schedule-id", }) if err != nil { log.Fatal(err) } gosync.New(adapter) }
Output:
func (*Schedule) Add ¶
Add new participants to a rotation, but the schedule must only have 1 rotation defined.