linkrule

package
v0.0.0-...-7ff62be Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: AGPL-3.0 Imports: 22 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
	GetCategories(*gin.Context)
	BulkDelete(c *gin.Context)
	DBExport(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	mongoExporter dbexport.Exporter,
	transformer common.PatternFieldsTransformer,
	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 CategoriesRequest

type CategoriesRequest struct {
	Limit  int64  `form:"limit" binding:"numeric,gte=0"`
	Type   string `form:"type" binding:"oneoforempty=alarm entity"`
	Search string `form:"search"`
}

type CategoryResponse

type CategoryResponse struct {
	Categories []string `json:"categories"`
}

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 map[string]link.ExternalDataParameters `bson:"external_data" json:"external_data" binding:"dive"`

	common.AlarmPatternFieldsRequest
	common.EntityPatternFieldsRequest
}

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,omitempty" swaggertype:"integer"`
	Updated    datetime.CpsTime  `bson:"updated,omitempty" json:"updated,omitempty" swaggertype:"integer"`

	ExternalData map[string]link.ExternalDataParameters `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)
}

func NewStore

func NewStore(dbClient mongo.DbClient, authorProvider author.Provider) Store

Jump to

Keyboard shortcuts

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