entityservice

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	Create(c *gin.Context)
	Get(c *gin.Context)
	GetDependencies(c *gin.Context)
	GetImpacts(c *gin.Context)
	Update(c *gin.Context)
	Delete(c *gin.Context)
	BulkCreate(c *gin.Context)
	BulkUpdate(c *gin.Context)
	BulkDelete(c *gin.Context)
}

func NewApi

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

type BulkDeleteRequestItem

type BulkDeleteRequestItem struct {
	ID string `json:"_id" binding:"required"`
}

type BulkUpdateRequestItem

type BulkUpdateRequestItem struct {
	EditRequest
	ID string `json:"_id" binding:"required"`
}

type ContextGraphAggregationResult

type ContextGraphAggregationResult struct {
	Data       []ContextGraphEntity `bson:"data"`
	TotalCount int64                `bson:"total_count" json:"total_count"`
}

func (*ContextGraphAggregationResult) GetData

func (r *ContextGraphAggregationResult) GetData() interface{}

func (*ContextGraphAggregationResult) GetTotal

func (r *ContextGraphAggregationResult) GetTotal() int64

type ContextGraphEntity

type ContextGraphEntity struct {
	entity.Entity     `bson:",inline"`
	StateDependsCount *int                  `bson:"state_depends_count" json:"state_depends_count,omitempty"`
	StateSetting      *StateSettingResponse `bson:"state_setting" json:"state_setting,omitempty"`
}

type ContextGraphRequest

type ContextGraphRequest struct {
	pagination.Query
	entity.SortRequest
	ID        string `form:"_id" json:"_id"`
	Search    string `form:"search" json:"search"`
	Category  string `form:"category" json:"category"`
	WithFlags bool   `form:"with_flags" json:"with_flags"`
	// Show dependencies defining the state of the entity
	DefineState bool `form:"define_state" json:"define_state"`
}

type CreateRequest

type CreateRequest struct {
	EditRequest
	ID string `json:"_id" binding:"id"`
}

type EditRequest

type EditRequest struct {
	ID             string               `json:"-"`
	Name           string               `json:"name" binding:"required,max=255"`
	Enabled        *bool                `json:"enabled" binding:"required"`
	OutputTemplate string               `json:"output_template" binding:"required,max=500"`
	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"`

	common.EntityPatternFieldsRequest
}

type Response

type Response struct {
	entity.Entity  `bson:",inline"`
	OutputTemplate string `bson:"output_template" json:"output_template"`
	SliAvailState  int64  `bson:"sli_avail_state" json:"sli_avail_state"`

	savedpattern.EntityPatternFields `bson:",inline"`
}

type ServiceChanges

type ServiceChanges struct {
	IsPatternChanged bool
	IsToggled        bool
}

type StateSettingResponse

type StateSettingResponse struct {
	ID     string `bson:"_id" json:"_id"`
	Title  string `bson:"title" json:"title"`
	Method string `bson:"method" json:"method"`
}

type Store

type Store interface {
	GetOneBy(ctx context.Context, id string) (*Response, error)
	GetDependencies(ctx context.Context, r ContextGraphRequest, userId string) (*ContextGraphAggregationResult, error)
	GetImpacts(ctx context.Context, r ContextGraphRequest, userId string) (*ContextGraphAggregationResult, error)
	Create(ctx context.Context, request CreateRequest) (*Response, error)
	Update(ctx context.Context, request UpdateRequest) (*Response, ServiceChanges, error)
	Delete(ctx context.Context, id string) (bool, error)
}

func NewStore

func NewStore(db mongo.DbClient, linkGenerator link.Generator, enableSameServiceNames bool, logger zerolog.Logger) Store

type UpdateRequest

type UpdateRequest struct {
	EditRequest
	ID string `json:"-"`
}

type Validator

type Validator interface {
	ValidateEditRequest(ctx context.Context, sl validator.StructLevel)
	ValidateCreateRequest(sl validator.StructLevel)
	ValidateUpdateRequest(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