eventfilter

package
v0.0.0-...-19d5731 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: AGPL-3.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	crud.BulkAPI
	ListFailures(c *gin.Context)
	ReadFailures(c *gin.Context)
	DBExport(c *gin.Context)
	ValidateTemplates(c *gin.Context)
	GetTemplateVars(c *gin.Context)
	GetCopyVars(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	mongoExporter dbexport.Exporter,
	errorResponder httperror.Responder,
) API

type AggregationFailureResult

type AggregationFailureResult struct {
	Data       []FailureResponse `bson:"data" json:"data"`
	TotalCount int64             `bson:"total_count" json:"total_count"`
}

func (*AggregationFailureResult) GetData

func (r *AggregationFailureResult) GetData() interface{}

func (*AggregationFailureResult) GetTotal

func (r *AggregationFailureResult) GetTotal() int64

type AggregationResult

type AggregationResult struct {
	Data       []Response `bson:"data" json:"data"`
	TotalCount int64      `bson:"total_count" json:"total_count"`
}

func (*AggregationResult) GetData

func (r *AggregationResult) GetData() interface{}

func (*AggregationResult) GetTotal

func (r *AggregationResult) GetTotal() int64

type BulkDeleteRequestItem

type BulkDeleteRequestItem struct {
	ID string `json:"_id" binding:"required"`
}

type BulkUpdateRequestItem

type BulkUpdateRequestItem struct {
	EditRequest
	ID string `json:"_id" binding:"required"`
}

type CopyVarsResponse

type CopyVarsResponse struct {
	Config []template.VarResponse `json:"config"`
}

type CreateRequest

type CreateRequest struct {
	EditRequest
	ID string `json:"_id" binding:"id"`
}

type EditRequest

type EditRequest struct {
	Author       string                       `json:"author" swaggerignore:"true"`
	Description  string                       `json:"description" binding:"required,max=255"`
	Type         string                       `json:"type" binding:"required,oneof=break drop enrichment change_entity"`
	Priority     int64                        `json:"priority" binding:"min=0"`
	Enabled      bool                         `json:"enabled"`
	Config       eventfilter.RuleConfig       `json:"config"`
	ExternalData []externaldata.RefParameters `json:"external_data,omitempty" binding:"dive"`

	patternfields.EntityRequest
	EventPattern pattern.Event `json:"event_pattern" binding:"event_pattern"`

	RRule      string            `json:"rrule,omitempty"`
	Start      *datetime.CpsTime `json:"start,omitempty" swaggertype:"integer"`
	Stop       *datetime.CpsTime `json:"stop,omitempty" swaggertype:"integer"`
	Exdates    []exdate.Request  `json:"exdates" binding:"dive"`
	Exceptions []string          `json:"exceptions"`
}

type Exception

type Exception struct {
	ID          string           `bson:"_id" json:"_id"`
	Name        string           `bson:"name" json:"name"`
	Description string           `bson:"description" json:"description"`
	Exdates     []types.Exdate   `bson:"exdates" json:"exdates"`
	Created     datetime.CpsTime `bson:"created" json:"created" swaggertype:"integer"`
}

type FailureRequest

type FailureRequest struct {
	pagination.Query
	Type *int `json:"type" form:"type"`
}

type FailureResponse

type FailureResponse struct {
	ID        string           `bson:"_id" json:"_id"`
	Type      int64            `bson:"type" json:"type"`
	Timestamp datetime.CpsTime `bson:"t" json:"t" swaggertype:"integer"`
	Message   string           `bson:"message" json:"message"`
	Event     map[string]any   `bson:"event" json:"event" swaggertype:"object"`
	Unread    bool             `bson:"unread" json:"unread"`
}

type FilteredQuery

type FilteredQuery struct {
	pagination.FilteredQuery
	SortBy            string `` /* 135-byte string literal not displayed */
	OnlyUnreadFailure bool   `json:"only_unread_failure" form:"only_unread_failure"`
}

type Response

type Response struct {
	ID           string                          `bson:"_id" json:"_id"`
	Author       *author.Author                  `bson:"author" json:"author" swaggerignore:"true"`
	Description  string                          `bson:"description" json:"description"`
	Type         string                          `bson:"type" json:"type"`
	Priority     int64                           `bson:"priority" json:"priority"`
	Enabled      bool                            `bson:"enabled" json:"enabled"`
	Config       eventfilter.RuleConfig          `bson:"config" json:"config"`
	ExternalData []externaldatatable.RefResponse `bson:"external_data" json:"external_data,omitempty"`
	Created      *datetime.CpsTime               `bson:"created,omitempty" json:"created,omitempty" swaggertype:"integer"`
	Updated      *datetime.CpsTime               `bson:"updated,omitempty" json:"updated,omitempty" swaggertype:"integer"`
	RRule        string                          `bson:"rrule" json:"rrule"`
	Start        *datetime.CpsTime               `bson:"start,omitempty" json:"start,omitempty" swaggertype:"integer"`
	Stop         *datetime.CpsTime               `bson:"stop,omitempty" json:"stop,omitempty" swaggertype:"integer"`
	Exdates      []types.Exdate                  `bson:"exdates" json:"exdates"`
	Exceptions   []Exception                     `bson:"exceptions" json:"exceptions"`

	EventsCount         int64 `bson:"events_count" json:"events_count"`
	FailuresCount       int64 `bson:"failures_count" json:"failures_count"`
	UnreadFailuresCount int64 `bson:"unread_failures_count" json:"unread_failures_count"`

	EventPattern                     pattern.Event `bson:"event_pattern" json:"event_pattern"`
	savedpattern.EntityPatternFields `bson:",inline"`
}

type Store

type Store interface {
	Insert(ctx context.Context, request CreateRequest) (*Response, error)
	GetByID(ctx context.Context, id string) (*Response, error)
	Find(ctx context.Context, query FilteredQuery) (*AggregationResult, error)
	Update(ctx context.Context, request UpdateRequest) (*Response, error)
	Delete(ctx context.Context, id, userID string) (bool, error)
	FindFailures(ctx context.Context, id string, r FailureRequest) (*AggregationFailureResult, error)
	ReadFailures(ctx context.Context, id string) (bool, error)
	ValidateTemplates(ctx context.Context, request TemplateRequest) (map[string]template.ValidateResponse, error)
	GetTemplateVars() TemplateVarsResponse
	GetCopyVars() CopyVarsResponse
}

func NewStore

func NewStore(
	dbClient mongo.DbClient,
	authorProvider author.Provider,
	transformer patternfields.Transformer,
	notificationStore usernotification.Store,
	tplValidator tplvalidator.Validator,
	tplExecutor libtemplate.Executor,
	tplConfigProvider config.TemplateConfigProvider,
	externalDataContainer *externaldata.GetterContainer,
	encoder encoding.Encoder,
	decoder encoding.Decoder,
) Store

type TemplateRequest

type TemplateRequest struct {
	Rule struct {
		TemplateRuleRequest
		ID string `json:"_id" binding:"id"`
	} `json:"rule"`
	TestData struct {
		Test  string `json:"test"`
		Event string `json:"event"`
		// TestData.Responses keys correspond with Rule.ExternalData keys
		Responses map[int]string `json:"responses"`
	} `json:"testdata"`
}

type TemplateRuleConfigRequest

type TemplateRuleConfigRequest struct {
	Resource      string               `json:"resource"`
	Component     string               `json:"component"`
	Connector     string               `json:"connector"`
	ConnectorName string               `json:"connector_name"`
	Actions       []eventfilter.Action `json:"actions,omitempty" binding:"dive,required_if=Type enrichment"`
}

type TemplateRuleRequest

type TemplateRuleRequest struct {
	Type         string                           `json:"type" binding:"required,oneof=break drop enrichment change_entity"`
	Config       TemplateRuleConfigRequest        `json:"config"`
	ExternalData []template.TemplateRefParameters `json:"external_data" binding:"dive"`

	patternfields.EntityRequest
	EventPattern pattern.Event `json:"event_pattern" binding:"event_pattern"`
}

type TemplateVarsResponse

type TemplateVarsResponse struct {
	ExternalData []template.VarResponse `json:"external_data"`
	Config       []template.VarResponse `json:"config"`
}

type UpdateRequest

type UpdateRequest struct {
	EditRequest
	ID string `json:"-"`
}

type Validator

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

func NewValidator

func NewValidator(templateExecutor template.Executor) *Validator

func (*Validator) ValidateEditRequest

func (v *Validator) ValidateEditRequest(ctx context.Context, sl validator.StructLevel)

func (*Validator) ValidateTemplateRuleRequest

func (v *Validator) ValidateTemplateRuleRequest(sl validator.StructLevel)

Source Files

  • api.go
  • models.go
  • store.go
  • validator.go

Jump to

Keyboard shortcuts

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