entitybasic

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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,
	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       []InfoRequest `json:"infos" binding:"dive"`
	Impacts     []string      `json:"impact"`
	Depends     []string      `json:"depends"`
}

type Entity

type Entity struct {
	entity.Entity     `bson:",inline"`
	Description       string   `bson:"description" json:"description"`
	ChangeableImpacts []string `bson:"changeable_impact" json:"changeable_impact"`
	ChangeableDepends []string `bson:"changeable_depends" json:"changeable_depends"`
}

type IdRequest

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

type InfoRequest

type InfoRequest struct {
	Name        string      `json:"name" binding:"required,max=255"`
	Description string      `json:"description" binding:"max=255"`
	Value       interface{} `json:"value"`
}

func (*InfoRequest) UnmarshalJSON

func (r *InfoRequest) UnmarshalJSON(b []byte) error

type Store

type Store interface {
	GetOneBy(id string) (*Entity, error)
	Update(EditRequest) (*Entity, bool, error)
	Delete(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