pattern

package
v0.0.0-...-8a398ea Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateEditRequest

func ValidateEditRequest(sl validator.StructLevel)

Types

type API

type API interface {
	common.CrudAPI
	BulkDelete(c *gin.Context)
	CountAlarms(c *gin.Context)
	CountEntities(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	configProvider config.UserInterfaceConfigProvider,
	enforcer security.Enforcer,
	logger zerolog.Logger,
) API

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 Count

type Count struct {
	Count     int64 `bson:"count" json:"count"`
	OverLimit bool  `bson:"-" json:"over_limit"`
}

type CountAlarmsResponse

type CountAlarmsResponse struct {
	AlarmPattern     Count `json:"alarm_pattern"`
	EntityPattern    Count `json:"entity_pattern"`
	PbehaviorPattern Count `json:"pbehavior_pattern"`
	All              Count `json:"all"`
	Entities         Count `json:"entities"`
}

type CountEntitiesResponse

type CountEntitiesResponse struct {
	AlarmPattern     Count `json:"alarm_pattern"`
	EntityPattern    Count `json:"entity_pattern"`
	PbehaviorPattern Count `json:"pbehavior_pattern"`
	All              Count `json:"all"`
}

type CountRequest

type CountRequest struct {
	AlarmPattern     pattern.Alarm         `json:"alarm_pattern" binding:"alarm_pattern"`
	EntityPattern    pattern.Entity        `json:"entity_pattern" binding:"entity_pattern"`
	PbehaviorPattern pattern.PbehaviorInfo `json:"pbehavior_pattern" binding:"pbehavior_pattern"`
}

type EditRequest

type EditRequest struct {
	ID                    string                        `json:"-"`
	Title                 string                        `json:"title" binding:"required,max=255"`
	Type                  string                        `json:"type" binding:"required,oneof=alarm entity pbehavior weather_service"`
	IsCorporate           *bool                         `json:"is_corporate" binding:"required"`
	AlarmPattern          pattern.Alarm                 `json:"alarm_pattern" binding:"alarm_pattern"`
	EntityPattern         pattern.Entity                `json:"entity_pattern" binding:"entity_pattern"`
	PbehaviorPattern      pattern.PbehaviorInfo         `json:"pbehavior_pattern" binding:"pbehavior_pattern"`
	WeatherServicePattern pattern.WeatherServicePattern `json:"weather_service_pattern" binding:"weather_service_pattern"`
	Author                string                        `json:"author" swaggerignore:"true"`
}

type ListRequest

type ListRequest struct {
	pagination.FilteredQuery
	SortBy    string `json:"sort_by" form:"sort_by" binding:"oneoforempty=_id title author.name author.display_name created updated"`
	Corporate *bool  `json:"corporate" form:"corporate"`
	Type      string `json:"type" form:"type"`
}

type Response

type Response struct {
	ID                    string                        `bson:"_id" json:"_id"`
	Title                 string                        `bson:"title" json:"title"`
	Type                  string                        `bson:"type" json:"type"`
	IsCorporate           bool                          `bson:"is_corporate" json:"is_corporate"`
	AlarmPattern          pattern.Alarm                 `bson:"alarm_pattern" json:"alarm_pattern,omitempty"`
	EntityPattern         pattern.Entity                `bson:"entity_pattern" json:"entity_pattern,omitempty"`
	PbehaviorPattern      pattern.PbehaviorInfo         `bson:"pbehavior_pattern" json:"pbehavior_pattern,omitempty"`
	WeatherServicePattern pattern.WeatherServicePattern `bson:"weather_service_pattern" json:"weather_service_pattern,omitempty"`
	Author                *author.Author                `bson:"author" json:"author"`
	Created               datetime.CpsTime              `bson:"created,omitempty" json:"created,omitempty" swaggertype:"integer"`
	Updated               datetime.CpsTime              `bson:"updated,omitempty" json:"updated,omitempty" swaggertype:"integer"`
}

type Store

type Store interface {
	Insert(ctx context.Context, r EditRequest) (*Response, error)
	GetByID(ctx context.Context, id, userID string) (*Response, error)
	Find(ctx context.Context, r ListRequest, userID string) (*AggregationResult, error)
	Update(ctx context.Context, r EditRequest) (*Response, error)
	Delete(ctx context.Context, pattern Response, userID string) (bool, error)
	CountAlarms(ctx context.Context, r CountRequest, maxCount int64) (CountAlarmsResponse, error)
	CountEntities(ctx context.Context, r CountRequest, maxCount int64) (CountEntitiesResponse, error)
}

func NewStore

func NewStore(
	dbClient mongo.DbClient,
	pbhComputeChan chan<- rpc.PbehaviorRecomputeEvent,
	serviceChangeListener chan<- entityservice.ChangeEntityMessage,
	authorProvider author.Provider,
	logger zerolog.Logger,
) Store

Jump to

Keyboard shortcuts

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