models

package
v0.12.1-alpha4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Action added in v0.13.0

type Action struct {
	Channel   ChannelReference `json:"channel" validate:"required"`
	Recipient string           `json:"recipient,omitempty"` // specific recipient if supported/required by the channel, e.g. for mail a comma separated list of mail adresses
}

Action determines to which channel the event is forwarded. Some channels (e.g. mail) require the explicit recipient(s).

type ChannelReference added in v0.13.0

type ChannelReference struct {
	ID   string      `json:"id" validate:"required"`
	Name string      `json:"name" readonly:"true"`
	Type ChannelType `json:"type" readonly:"true"`
}

type ChannelType added in v0.12.0

type ChannelType string
const (
	ChannelTypeMail       ChannelType = "mail"
	ChannelTypeMattermost ChannelType = "mattermost"
	ChannelTypeTeams      ChannelType = "teams"
)

func (ChannelType) HasRecipient added in v0.13.0

func (ct ChannelType) HasRecipient() bool

HasRecipient returns true if the channel type requires/supports an explicit recipient.

type Notification

type Notification struct {
	Id               string              `json:"id" readonly:"true"`
	Origin           string              `json:"origin" binding:"required"`  // name of the origin, e.g. `SBOM - React`
	OriginClass      string              `json:"originClass"`                // unique identifier for the class of origins, e.g. `/vi/SBOM`, for now optional for backwards compatibility, will be required in future
	OriginResourceID string              `json:"originResourceID,omitempty"` // together with class it can be used to provide a link to the origin, e.g. `<id of react sbom object>`
	Timestamp        string              `json:"timestamp" binding:"required" format:"date-time"`
	Title            string              `json:"title" binding:"required"`
	Detail           string              `json:"detail" binding:"required"`
	Level            notifications.Level `json:"level" binding:"required" enums:"info,warning,error,urgent"`
	CustomFields     map[string]any      `json:"customFields,omitempty"` // can contain arbitrary structured information about the event
}

Notification is sent by a backend service. It will always be stored by the notification service and it will possibly also trigger actions like sending mails, depending on the configured rules.

type NotificationChannel added in v0.12.0

type NotificationChannel struct {
	Id                       *string     `json:"id" readonly:"true"`
	CreatedAt                string      `json:"createdAt" readonly:"true"`
	UpdatedAt                *string     `json:"updatedAt,omitempty"`
	ChannelType              ChannelType `json:"channelType" binding:"required"`
	ChannelName              *string     `json:"channelName,omitempty"`
	WebhookUrl               *string     `json:"webhookUrl,omitempty"`
	Description              *string     `json:"description,omitempty"`
	Domain                   *string     `json:"domain,omitempty"`
	Port                     *int        `json:"port,omitempty"`
	IsAuthenticationRequired *bool       `json:"isAuthenticationRequired,omitempty"`
	IsTlsEnforced            *bool       `json:"isTlsEnforced,omitempty"`
	Username                 *string     `json:"username,omitempty"`
	Password                 *string     `json:"password,omitempty"`
	MaxEmailAttachmentSizeMb *int        `json:"maxEmailAttachmentSizeMb,omitempty"`
	MaxEmailIncludeSizeMb    *int        `json:"maxEmailIncludeSizeMb,omitempty"`
	SenderEmailAddress       *string     `json:"senderEmailAddress,omitempty"`
}

type Origin added in v0.12.0

type Origin struct {
	Name      string `json:"name" validate:"required"`  // human readable name representation
	Class     string `json:"class" validate:"required"` // unique identifier
	ServiceID string `json:"serviceID" readonly:"true"` // service in which this origin is defined
}

Origin of an event/notification.

func (Origin) ToEntity added in v0.12.0

func (o Origin) ToEntity() entities.Origin

ToEntity transforms the rest model to the entity for use in the service

type OriginList added in v0.12.0

type OriginList []Origin

func (OriginList) Validate added in v0.12.0

func (o OriginList) Validate() ValidationErrors

type OriginReference added in v0.13.0

type OriginReference struct {
	Name      string `json:"name" readonly:"true"`
	Class     string `json:"class" validate:"required"`
	ServiceID string `json:"serviceID" readonly:"true"`
}

func ToOriginReferences added in v0.13.0

func ToOriginReferences(origins []entities.Origin) []OriginReference

type Rule added in v0.13.0

type Rule struct {
	ID      string           `json:"id" readonly:"true"`
	Name    string           `json:"name" validate:"required"`
	Trigger Trigger          `json:"trigger" validate:"required"`
	Action  Action           `json:"action" validate:"required"`
	Active  bool             `json:"active"`
	Errors  ValidationErrors `json:"errors,omitempty" readonly:"true"` // populated if the rule is invalid, this can be useful to highlight rules which need action from the user.
}

A rule determines which events cause which action. Each incoming event is matched with the trigger conditions. If the condition is fulfilled, the provided action is triggered.

func (*Rule) Cleanup added in v0.13.0

func (r *Rule) Cleanup()

func (*Rule) Validate added in v0.13.0

func (r *Rule) Validate() ValidationErrors

Validate checks if the rule is valid and returns validation errors if not. Furthermore it populates the `Errors` field with these validation errors.

type RuleOptionChannel added in v0.13.0

type RuleOptionChannel struct {
	Id           *string     `json:"id" readonly:"true"`
	ChannelType  ChannelType `json:"channelType" binding:"required"`
	ChannelName  *string     `json:"channelName,omitempty"`
	HasRecipient bool        `json:"hasRecipient"`
}

func ToRuleOptionChannels added in v0.13.0

func ToRuleOptionChannels(channels []NotificationChannel) []RuleOptionChannel

type RuleOptions added in v0.13.0

type RuleOptions struct {
	Origins  []OriginReference     `json:"origins"`
	Levels   []notifications.Level `json:"levels"`
	Channels []RuleOptionChannel   `json:"channels"`
}

RuleOptions Represents a list of all options required for the creation of a Rule

type Trigger added in v0.13.0

type Trigger struct {
	Origins []OriginReference     `json:"origins" validate:"required"`
	Levels  []notifications.Level `json:"levels" validate:"required"`
}

Trigger condition, fulfilled if both one of `origins` and `levels` match the ones from the incoming event.

type ValidationErrors added in v0.12.0

type ValidationErrors map[string]string

func (ValidationErrors) Error added in v0.12.0

func (v ValidationErrors) Error() string

Jump to

Keyboard shortcuts

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