receiver

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelKeyID   = "id"
	LabelKeyType = "type"
)
View Source
const (
	TypeSlack        string = "slack"
	TypeSlackChannel string = "slack_channel"
	TypeHTTP         string = "http"
	TypePagerDuty    string = "pagerduty"
	TypeFile         string = "file"
)

Variables

View Source
var (
	ErrNotImplemented = errors.New("operation not supported")
)

Functions

func IsTypeSupported

func IsTypeSupported(receiverType string) bool

Types

type ConfigResolver

type ConfigResolver interface {
	BuildData(ctx context.Context, configs map[string]any) (map[string]any, error)
	PreHookDBTransformConfigs(ctx context.Context, configs map[string]any) (map[string]any, error)
	PostHookDBTransformConfigs(ctx context.Context, configs map[string]any) (map[string]any, error)
}

type Encryptor

type Encryptor interface {
	Encrypt(str string) (string, error)
	Decrypt(str string) (string, error)
}

type Filter

type Filter struct {
	ReceiverIDs    []uint64
	MultipleLabels []map[string]string
	Expanded       bool
}

type GetOption

type GetOption func(*getOpts)

func GetWithData

func GetWithData() GetOption

GetWithData populates receiver with data

func GetWithExpand added in v0.6.5

func GetWithExpand() GetOption

GetWithExpand populates receiver configs with parent config

type NotFoundError

type NotFoundError struct {
	ID uint64
}

func (NotFoundError) Error

func (err NotFoundError) Error() string

type Receiver

type Receiver struct {
	ID             uint64            `json:"id"`
	Name           string            `json:"name"`
	Labels         map[string]string `json:"labels"`
	Configurations map[string]any    `json:"configurations"`
	Data           map[string]any    `json:"data"`
	CreatedAt      time.Time         `json:"created_at"`
	UpdatedAt      time.Time         `json:"updated_at"`

	// The pointer to receiver parent of a child receiver. This field is required if a receiver is a child receiver
	// If ParentID != 0, the receiver is a child receiver.
	ParentID uint64 `json:"parent_id"`

	// Type should be immutable
	Type string `json:"type"`
}

func (Receiver) ToSubscriptionReceiverRelation added in v0.7.5

func (r Receiver) ToSubscriptionReceiverRelation(subscriptionID uint64) subscriptionreceiver.Relation

func (*Receiver) Validate added in v0.6.5

func (r *Receiver) Validate() error

type Repository

type Repository interface {
	List(context.Context, Filter) ([]Receiver, error)
	Create(context.Context, *Receiver) error
	Get(context.Context, uint64, Filter) (*Receiver, error)
	Update(context.Context, *Receiver) error
	Delete(context.Context, uint64) error
	PatchLabels(context.Context, *Receiver) error
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles business logic

func NewService

func NewService(repository Repository, receiverPlugins map[string]ConfigResolver) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, rcv *Receiver) error

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id uint64) error

func (*Service) Get

func (s *Service) Get(ctx context.Context, id uint64, gopts ...GetOption) (*Receiver, error)

func (*Service) List

func (s *Service) List(ctx context.Context, flt Filter) ([]Receiver, error)

func (*Service) PostHookDBTransformConfigs added in v0.7.5

func (s *Service) PostHookDBTransformConfigs(ctx context.Context, receiverType string, configs map[string]any) (map[string]any, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, rcv *Receiver) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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