link

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeAlarm  = "alarm"
	TypeEntity = "entity"
)
View Source
const (
	ActionOpen = "open"
	ActionCopy = "copy"
)

Variables

View Source
var ErrNoRule = errors.New("rule not found")
View Source
var ErrNotMatchedAlarm = errors.New("alarms aren't matched to rule")

Functions

func MergeLinks(left, right map[string]LinksByCategory) map[string]LinksByCategory

Types

type ExternalDataParameters

type ExternalDataParameters struct {
	Type string `bson:"type" json:"type" binding:"required,oneof=mongo"`

	Collection string            `bson:"collection" json:"collection" binding:"required"`
	Select     map[string]string `bson:"select" json:"select"`
	Regexp     map[string]string `bson:"regexp" json:"regexp"`
	SortBy     string            `bson:"sort_by" json:"sort_by"`
	Sort       string            `bson:"sort" json:"sort" binding:"oneoforempty=asc desc"`
}

type Generator

type Generator interface {
	GenerateForAlarm(ctx context.Context, alarm types.Alarm, entity types.Entity, user User) (LinksByCategory, error)
	GenerateForAlarms(ctx context.Context, alarmIds []string, user User) (map[string]LinksByCategory, error)
	GenerateForEntities(ctx context.Context, entityIds []string, user User) (map[string]LinksByCategory, error)
	GenerateCombinedForAlarmsByRule(ctx context.Context, ruleId string, alarmIds []string, user User) ([]Link, error)
	Load(ctx context.Context) error
}
type Link struct {
	RuleID     string `json:"rule_id,omitempty"`
	Label      string `json:"label"`
	IconName   string `json:"icon_name"`
	Url        string `json:"url"`
	Single     bool   `json:"single,omitempty"`
	HideInMenu bool   `json:"hide_in_menu,omitempty"`
	Action     string `json:"action"`
}

type LinksByCategory

type LinksByCategory map[string][]Link

type Parameters

type Parameters struct {
	Label    string `bson:"label" json:"label" binding:"required,max=255"`
	Category string `bson:"category" json:"category" binding:"max=255"`
	IconName string `bson:"icon_name" json:"icon_name" binding:"required,max=255"`
	Url      string `bson:"url" json:"url" binding:"required,max=1000"`
	Action   string `bson:"action" json:"action" binding:"required,oneof=open copy"`
	// Single to mark links unavailable to multiple selected alarms
	Single     bool `bson:"single,omitempty" json:"single,omitempty"`
	HideInMenu bool `bson:"hide_in_menu,omitempty" json:"hide_in_menu,omitempty"`
}

type Rule

type Rule struct {
	ID         string           `bson:"_id"`
	Name       string           `bson:"name"`
	Type       string           `bson:"type"`
	Enabled    bool             `bson:"enabled"`
	Links      []Parameters     `bson:"links"`
	SourceCode string           `bson:"source_code"`
	Author     string           `bson:"author"`
	Created    datetime.CpsTime `bson:"created,omitempty"`
	Updated    datetime.CpsTime `bson:"updated,omitempty"`

	ExternalData map[string]ExternalDataParameters `bson:"external_data"`

	savedpattern.EntityPatternFields `bson:",inline"`
	savedpattern.AlarmPatternFields  `bson:",inline"`
}

type User

type User struct {
	Email      string   `bson:"email"`
	Username   string   `bson:"username"`
	Firstname  string   `bson:"firstname"`
	Lastname   string   `bson:"lastname"`
	ExternalID string   `bson:"external_id"`
	Source     string   `bson:"source"`
	Roles      []string `bson:"roles"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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