Documentation
¶
Index ¶
- type API
- type AggregationResult
- type BulkDeleteRequestItem
- type BulkToggleRequestItem
- type CategoriesRequest
- type CategoryResponse
- type EditRequest
- type ListRequest
- type Response
- type Store
- type TemplateRequest
- type TemplateRequestLink
- type TemplateRuleRequest
- type TemplateVarsResponse
- type TemplateVarsResponseItem
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type 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() any
func (*AggregationResult) GetTotal ¶
func (r *AggregationResult) GetTotal() int64
type BulkDeleteRequestItem ¶
type BulkToggleRequestItem ¶
type CategoriesRequest ¶
type EditRequest ¶
type EditRequest struct {
ID string `json:"-"`
Name string `json:"name" binding:"required,max=255"`
Type string `json:"type" binding:"required,oneof=alarm entity"`
Enabled *bool `json:"enabled" binding:"required"`
Links []link.Parameters `json:"links" binding:"dive"`
SourceCode string `json:"source_code"`
Author string `json:"author" swaggerignore:"true"`
ExternalData []externaldata.RefParameters `bson:"external_data" json:"external_data" binding:"dive"`
patternfields.AlarmRequest
patternfields.EntityRequest
}
type ListRequest ¶
type ListRequest struct {
pagination.FilteredQuery
SortBy string `json:"sort_by" form:"sort_by" binding:"oneoforempty=_id name author.name author.display_name created updated"`
}
type Response ¶
type Response struct {
ID string `bson:"_id" json:"_id"`
Name string `bson:"name" json:"name"`
Type string `bson:"type" json:"type"`
Enabled bool `bson:"enabled" json:"enabled"`
Links []link.Parameters `bson:"links" json:"links,omitempty"`
SourceCode string `bson:"source_code" json:"source_code,omitempty"`
Author *author.Author `bson:"author" json:"author"`
Created datetime.CpsTime `bson:"created,omitempty" json:"created,omitzero" swaggertype:"integer"`
Updated datetime.CpsTime `bson:"updated,omitempty" json:"updated,omitzero" swaggertype:"integer"`
ExternalData []externaldatatable.RefResponse `bson:"external_data" json:"external_data"`
savedpattern.EntityPatternFields `bson:",inline"`
savedpattern.AlarmPatternFields `bson:",inline"`
}
type Store ¶
type Store interface {
Insert(ctx context.Context, r EditRequest) (*Response, error)
GetByID(ctx context.Context, id string) (*Response, error)
Find(ctx context.Context, r ListRequest) (*AggregationResult, error)
Update(ctx context.Context, r EditRequest) (*Response, error)
Delete(ctx context.Context, id, userID string) (bool, error)
GetCategories(ctx context.Context, r CategoriesRequest) (*CategoryResponse, error)
ValidateTemplates(ctx context.Context, request TemplateRequest) (map[string]template.ValidateResponse, error)
GetTemplateVars(ctx context.Context) (TemplateVarsResponse, error)
Toggle(ctx context.Context, r BulkToggleRequestItem, enabled bool) (bool, error)
}
func NewStore ¶
func NewStore( dbClient mongo.DbClient, authorProvider author.Provider, transformer patternfields.Transformer, tplValidator tplvalidator.Validator, tplExecutor libtemplate.Executor, tplConfigProvider config.TemplateConfigProvider, externalDataContainer *externaldata.GetterContainer, enforcer security.Enforcer, ) Store
type TemplateRequest ¶
type TemplateRequest struct {
Author string `json:"author" swaggerignore:"true"`
Rule struct {
TemplateRuleRequest
ID string `json:"_id" binding:"id"`
} `json:"rule"`
TestData struct {
Test string `json:"test"`
Alarm string `json:"alarm"`
Entity string `json:"entity"`
User string `json:"user"`
} `json:"testdata"`
}
type TemplateRequestLink ¶
type TemplateRuleRequest ¶
type TemplateRuleRequest struct {
Type string `json:"type" binding:"required,oneof=alarm entity"`
SourceCode string `json:"source_code"`
Links []TemplateRequestLink `json:"links" binding:"dive"`
ExternalData []template.TemplateRefParameters `json:"external_data" binding:"dive"`
}
type TemplateVarsResponse ¶
type TemplateVarsResponse struct {
Alarm TemplateVarsResponseItem `json:"alarm"`
Entity TemplateVarsResponseItem `json:"entity"`
}
type TemplateVarsResponseItem ¶
type TemplateVarsResponseItem struct {
URL []template.VarResponse `json:"url"`
Label []template.VarResponse `json:"label"`
ExternalData []template.VarResponse `json:"external_data"`
}
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func (*Validator) ValidateEditRequest ¶
func (v *Validator) ValidateEditRequest(sl validator.StructLevel)
func (*Validator) ValidateTemplateRequest ¶
func (v *Validator) ValidateTemplateRequest(sl validator.StructLevel)
Source Files
¶
- api.go
- models.go
- store.go
- validator.go
Click to show internal directories.
Click to hide internal directories.