oncall

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

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

func WithClient(client *schedule.Client) gosync.ConfigFn[*OnCall]

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

func WithLogger(logger *log.Logger) gosync.ConfigFn[*OnCall]

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

type OnCall struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

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:

func (*OnCall) Add

func (o *OnCall) Add(_ context.Context, _ []string) error

Add is not supported, as the on-call is readonly.

func (*OnCall) Get

func (o *OnCall) Get(ctx context.Context) ([]string, error)

Get email addresses of users currently on-call.

func (*OnCall) Remove

func (o *OnCall) Remove(_ context.Context, _ []string) error

Remove is not supported, as the on-call is readonly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL