statesettings

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: 22 Imported by: 0

Documentation

Index

Constants

View Source
const StickySortField = "on_top"

Variables

View Source
var ErrDefaultRule = errors.New("can't delete junit or service settings")

Functions

func NewApi

func NewApi(
	store Store,
	actionLogger logger.ActionLogger,
) common.CrudAPI

Types

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 EditRequest

type EditRequest struct {
	ID           string `json:"-" bson:"_id"`
	StateSetting `bson:"inline"`
}

type FilteredQuery

type FilteredQuery struct {
	pagination.FilteredQuery
	SortBy string `json:"sort_by" form:"sort_by" binding:"oneoforempty=title enabled priority method"`
}

type JUnitThreshold

type JUnitThreshold struct {
	Minor    *float64 `json:"minor" bson:"minor" binding:"required,numeric,gte=0,lte=100,ltefield=Major,ltefield=Critical"`
	Major    *float64 `json:"major" bson:"major" binding:"required,numeric,gte=0,lte=100,ltefield=Critical"`
	Critical *float64 `json:"critical" bson:"critical" binding:"required,numeric,gte=0,lte=100"`
	Type     *int     `json:"type" bson:"type" binding:"required"`
}

type JUnitThresholds

type JUnitThresholds struct {
	Skipped  JUnitThreshold `json:"skipped" bson:"skipped" binding:"required"`
	Errors   JUnitThreshold `json:"errors" bson:"errors" binding:"required"`
	Failures JUnitThreshold `json:"failures" bson:"failures" binding:"required"`
}

type Response

type Response struct {
	ID           string `json:"_id" bson:"_id"`
	StateSetting `bson:"inline"`

	Editable  bool `bson:"editable" json:"editable"`
	Deletable bool `bson:"deletable" json:"deletable"`
}

type StateSetting

type StateSetting struct {
	// Possible method values.
	//   * `worst` - take worst state.
	//   * `worst_of_share` - take worst of share defined in junit_thresholds.
	//   * `inherited` - take worst of subset of dependencies defined by pattern in inherited_entity_pattern.
	//   * `dependencies` - calculate state by rules defined in state_thresholds.
	Method string `json:"method" bson:"method" binding:"required"`

	// Service and component state setting only fields
	Title                  *string          `json:"title,omitempty" bson:"title,omitempty"`
	Enabled                *bool            `json:"enabled,omitempty" bson:"enabled,omitempty"`
	Priority               int64            `json:"priority" bson:"priority" binding:"min=0"`
	EntityPattern          *pattern.Entity  `json:"entity_pattern,omitempty" bson:"entity_pattern,omitempty"`
	InheritedEntityPattern *pattern.Entity  `json:"inherited_entity_pattern,omitempty" bson:"inherited_entity_pattern,omitempty"`
	StateThresholds        *StateThresholds `json:"state_thresholds,omitempty" bson:"state_thresholds,omitempty"`
	Type                   *string          `` /* 148-byte string literal not displayed */

	// JUnit state setting only field
	JUnitThresholds *JUnitThresholds `json:"junit_thresholds,omitempty" bson:"junit_thresholds,omitempty"`
}

type StateThreshold

type StateThreshold struct {
	// Possible method values.
	//   * `number` - calculate by number of entities.
	//   * `share` - calculate by share of entities.
	Method string `json:"method" bson:"method" binding:"oneof=number share"`
	// Possible state values.
	//   * `critical` - calculate critical state.
	//   * `major` - calculate major state.
	//   * `minor` - calculate minor state.
	//   * `ok` - calculate ok state.
	State string `json:"state" bson:"state" binding:"oneof=critical major minor ok"`
	// Possible cond values.
	//   * `gt` - greater than.
	//   * `lt` - less than.
	Cond  string `json:"cond" bson:"cond" binding:"oneof=gt lt"`
	Value int    `json:"value" bson:"value"`
}

type StateThresholds

type StateThresholds struct {
	Critical *StateThreshold `json:"critical,omitempty" bson:"critical,omitempty"`
	Major    *StateThreshold `json:"major,omitempty" bson:"major,omitempty"`
	Minor    *StateThreshold `json:"minor,omitempty" bson:"minor,omitempty"`
	OK       *StateThreshold `json:"ok,omitempty" bson:"ok,omitempty"`
}

type Store

type Store interface {
	GetById(ctx context.Context, id string) (*Response, error)
	Find(ctx context.Context, query FilteredQuery) (*AggregationResult, error)
	Insert(ctx context.Context, r EditRequest) (*Response, error)
	Update(ctx context.Context, r EditRequest) (*Response, error)
	Delete(ctx context.Context, id string) (bool, error)
}

func NewStore

func NewStore(
	dbClient mongo.DbClient,
	stateSettingsUpdatesChan chan statesetting.RuleUpdatedMessage,
) Store

type Validator

type Validator interface {
	ValidateEditRequest(sl validator.StructLevel)
	ValidateJUnitThresholds(sl validator.StructLevel)
	ValidateStateThreshold(sl validator.StructLevel)
}

func NewValidator

func NewValidator() Validator

Jump to

Keyboard shortcuts

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