idlerule

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateCountPatternRequest

func ValidateCountPatternRequest(sl validator.StructLevel)

func ValidateEditRequest

func ValidateEditRequest(sl validator.StructLevel)

Types

type API

type API interface {
	common.CrudAPI
	CountPatterns(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	actionLogger logger.ActionLogger,
	conf config.UserInterfaceConfigProvider,
) API

type AggregationResult

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

func (AggregationResult) GetData

func (r AggregationResult) GetData() interface{}

GetData implementation PaginatedData interface

func (AggregationResult) GetTotal

func (r AggregationResult) GetTotal() int64

GetTotal implementation PaginatedData interface

type CountByPatternRequest

type CountByPatternRequest struct {
	EntityPatterns pattern.EntityPatternList `json:"entity_patterns"`
	AlarmPatterns  pattern.AlarmPatternList  `json:"alarm_patterns"`
}

type CountByPatternResult

type CountByPatternResult struct {
	OverLimit          bool  `json:"over_limit"`
	TotalCountEntities int64 `json:"total_count_entities"`
	TotalCountAlarms   int64 `json:"total_count_alarms"`
}

type EditRequest

type EditRequest struct {
	ID                   string                    `json:"-"`
	Name                 string                    `json:"name" binding:"required,max=255"`
	Description          string                    `json:"description" binding:"max=255"`
	Author               string                    `json:"author" binding:"required,max=255"`
	Enabled              *bool                     `json:"enabled" binding:"required"`
	Type                 string                    `json:"type" binding:"required"`
	Priority             *int64                    `json:"priority" binding:"required"`
	Duration             types.DurationWithUnit    `json:"duration" binding:"required"`
	DisableDuringPeriods []string                  `json:"disable_during_periods"`
	EntityPatterns       pattern.EntityPatternList `json:"entity_patterns"`
	AlarmPatterns        pattern.AlarmPatternList  `json:"alarm_patterns"`
	AlarmCondition       string                    `json:"alarm_condition"`
	Operation            *OperationRequest         `json:"operation,omitempty"`
}

type FilteredQuery

type FilteredQuery struct {
	pagination.FilteredQuery
	SortBy string `json:"sort_by" form:"sort_by" binding:"oneoforempty=_id name author duration created updated type priority"`
}

type OperationRequest

type OperationRequest struct {
	Type       string      `json:"type" binding:"required"`
	Parameters interface{} `json:"parameters,omitempty"`
}

func (*OperationRequest) UnmarshalJSON

func (r *OperationRequest) UnmarshalJSON(b []byte) error

type Store

type Store interface {
	Insert(context.Context, EditRequest) (*idlerule.Rule, error)
	Find(context.Context, FilteredQuery) (*AggregationResult, error)
	GetOneBy(ctx context.Context, id string) (*idlerule.Rule, error)
	Update(context.Context, EditRequest) (*idlerule.Rule, error)
	Delete(ctx context.Context, id string) (bool, error)
	CountByPatterns(ctx context.Context, filter CountByPatternRequest, timeout int, overLimit int) (*CountByPatternResult, error)
}

func NewStore

func NewStore(db mongo.DbClient) Store

Jump to

Keyboard shortcuts

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