triggers

package
v0.0.1-dev-fe8dc22 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Triggers         = "triggers"
	DB               = "triggers"
	Collection       = "triggers"
	ReqCollection    = "requests"
	ResponsePolicyV2 = "/etc/policies/alert_resp/alert_resp2_0.yml"
	ISO8601Z         = "2006-01-02T15:04:05+00:00"
)
View Source
const (
	Module = "triggers"
)

Variables

This section is empty.

Functions

func GetDetailsMap

func GetDetailsMap() map[string]ApiSchema

func GetNameMap

func GetNameMap() map[string]string

func SyncList

func SyncList(triggers []ApiSchema)

func TimeISO8601Z

func TimeISO8601Z(t time.Time) string

Types

type ApiSchema

type ApiSchema struct {
	Name             string      `json:"name" yaml:"name" bson:"name"`
	Description      string      `json:"description" yaml:"description" bson:"description"`
	Match            string      `json:"-" yaml:"match"`
	Attributes       []Attribute `json:"attributes" bson:"attributes" yaml:"-"`
	Response         `json:"response" yaml:"response" bson:"response"`
	Enabled          bool            `json:"enabled" yaml:"enabled" bson:"enabled"`
	Status           *status.Trigger `json:"status" yaml:"-" bson:"status"`
	IsReportRequired bool            `json:"-" yaml:"-"`
}

func Get

func Get(name string) (*ApiSchema, bool)

func List

func List() []ApiSchema

func (*ApiSchema) AppendEmail

func (a *ApiSchema) AppendEmail(email email.Recipient)

func (*ApiSchema) AppendSlack

func (a *ApiSchema) AppendSlack(slack slack.ApiChannel)

func (*ApiSchema) GenEmailList

func (a *ApiSchema) GenEmailList() []string

func (*ApiSchema) GenMatchRule

func (a *ApiSchema) GenMatchRule() string

func (*ApiSchema) GenSlackList

func (a *ApiSchema) GenSlackList() []string

func (*ApiSchema) GenTaskUpdate

func (a *ApiSchema) GenTaskUpdate() ApiSchema

func (*ApiSchema) HasEmail

func (a *ApiSchema) HasEmail(email string) bool

func (*ApiSchema) HasEmailRecipients

func (a *ApiSchema) HasEmailRecipients() bool

func (*ApiSchema) HasSlack

func (a *ApiSchema) HasSlack(channel string) bool

func (*ApiSchema) HasSlackChannels

func (a *ApiSchema) HasSlackChannels() bool

func (*ApiSchema) IsSame

func (a *ApiSchema) IsSame(trigger ApiSchema) bool

func (*ApiSchema) SetCompleted

func (a *ApiSchema) SetCompleted()

func (*ApiSchema) SetEmailDetails

func (a *ApiSchema) SetEmailDetails(email email.Recipient)

func (*ApiSchema) SetError

func (a *ApiSchema) SetError()

func (*ApiSchema) SetOk

func (a *ApiSchema) SetOk()

func (*ApiSchema) SetSlackDetails

func (a *ApiSchema) SetSlackDetails(slack slack.ApiChannel)

func (*ApiSchema) SetUpdating

func (a *ApiSchema) SetUpdating()

func (*ApiSchema) ToCosSchema

func (a *ApiSchema) ToCosSchema() CosSchema

type Attribute

type Attribute struct {
	Name    string `json:"name"`
	Type    string `json:"type"`
	Value   any    `json:"value"`
	Enabled bool   `json:"enabled"`
}

type CosSchema

type CosSchema struct {
	Name           string             `json:"name"`
	Enabled        bool               `json:"enabled"`
	Topic          string             `json:"topic"`
	Match          string             `json:"match"`
	Description    string             `json:"description"`
	Emails         []email.Recipient  `json:"emails"`
	Slacks         []slack.CosChannel `json:"slacks"`
	WriteResponses `json:"responses"`
	Execs          `json:"execs"`
}

func (*CosSchema) Bytes

func (c *CosSchema) Bytes() ([]byte, error)

func (*CosSchema) ConvertToApiAttributes

func (c *CosSchema) ConvertToApiAttributes() []Attribute

func (*CosSchema) ConvertToApiEmails

func (c *CosSchema) ConvertToApiEmails() []email.Recipient

func (*CosSchema) ConvertToApiSlacks

func (c *CosSchema) ConvertToApiSlacks() []slack.ApiChannel

func (*CosSchema) ToApiSchema

func (c *CosSchema) ToApiSchema() ApiSchema

type Execs

type Execs struct {
	Shells []string `json:"shells"`
	Bins   []string `json:"bins"`
}

type Response

type Response struct {
	Types  []string           `json:"types" yaml:"-" bson:"types"`
	Slacks []slack.ApiChannel `json:"slacks" yaml:"slacks" bson:"slacks"`
	Emails []email.Recipient  `json:"emails" yaml:"emails" bson:"emails"`
}

type Toggle

type Toggle struct {
	Enable bool `json:"enable" yaml:"enable"`
}

type WriteResponses

type WriteResponses struct {
	Emails []string `json:"emails"`
	Slacks []string `json:"slacks"`
	Execs  []string `json:"execs"`
}

Jump to

Keyboard shortcuts

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