entitybasic

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrComponent = errors.New("component has resources")
View Source
var ErrLinkedEntityToAlarm = errors.New("entity is linked to alarm")

Functions

This section is empty.

Types

type API

type API interface {
	Get(c *gin.Context)
	Update(c *gin.Context)
	Delete(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	entityChangeListener chan<- entityservice.ChangeEntityMessage,
	metricMetaUpdater metrics.MetaUpdater,
	actionLogger logger.ActionLogger,
	logger zerolog.Logger,
) API

type EditRequest

type EditRequest struct {
	ID            string               `json:"-"`
	Description   string               `json:"description" binding:"max=255"`
	Enabled       *bool                `json:"enabled" binding:"required"`
	Category      string               `json:"category"`
	ImpactLevel   int64                `json:"impact_level" binding:"required,min=1,max=10"`
	Infos         []entity.InfoRequest `json:"infos" binding:"dive"`
	SliAvailState *int64               `json:"sli_avail_state" binding:"required,min=0,max=3"`

	Coordinates *types.Coordinates `json:"coordinates"`
}

type Entity

type Entity struct {
	entity.Entity `bson:",inline"`
	Description   string `bson:"description" json:"description"`
	SliAvailState int64  `bson:"sli_avail_state" json:"sli_avail_state"`
}

type IdRequest

type IdRequest struct {
	ID string `form:"_id" binding:"required"`
}

type Store

type Store interface {
	GetOneBy(ctx context.Context, id string) (*Entity, error)
	Update(ctx context.Context, r EditRequest) (*Entity, bool, error)
	Delete(ctx context.Context, id string) (bool, error)
}

func NewStore

func NewStore(db mongo.DbClient) Store

type Validator

type Validator interface {
	ValidateEditRequest(ctx context.Context, sl validator.StructLevel)
}

func NewValidator

func NewValidator(client mongo.DbClient) Validator

Jump to

Keyboard shortcuts

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