heartbeat

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewApi

func NewApi(
	store Store,
	transformer ModelTransformer,
	actionLogger logger.ActionLogger,
) common.BulkCrudAPI

Types

type AggregationResult

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

func (AggregationResult) GetData

func (r AggregationResult) GetData() interface{}

GetData implementation PaginatedData interface

func (AggregationResult) GetTotal

func (r AggregationResult) GetTotal() int64

GetTotal implementation PaginatedData interface

type BaseEditRequest

type BaseEditRequest struct {
	Name             string                 `json:"name" binding:"required,max=255"`
	Description      string                 `json:"description" binding:"required,max=255"`
	Author           string                 `json:"author" swaggerignore:"true"`
	Pattern          map[string]string      `json:"pattern" binding:"required"`
	ExpectedInterval types.CpsShortDuration `json:"expected_interval" binding:"required"`
	Output           string                 `json:"output" binding:"max=255"`
}

type BulkCreateRequest

type BulkCreateRequest struct {
	Items []CreateRequest `binding:"required,notblank,dive"`
}

func (BulkCreateRequest) MarshalJSON

func (r BulkCreateRequest) MarshalJSON() ([]byte, error)

func (*BulkCreateRequest) UnmarshalJSON

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

type BulkDeleteRequest

type BulkDeleteRequest struct {
	IDs []string `form:"ids[]" binding:"required,notblank"`
}

type BulkUpdateRequest

type BulkUpdateRequest struct {
	Items []BulkUpdateRequestItem `binding:"required,notblank,dive"`
}

func (BulkUpdateRequest) MarshalJSON

func (r BulkUpdateRequest) MarshalJSON() ([]byte, error)

func (*BulkUpdateRequest) UnmarshalJSON

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

type BulkUpdateRequestItem

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

type CreateRequest

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

type FilteredQuery

type FilteredQuery struct {
	pagination.FilteredQuery
	SortBy string `json:"sort_by" form:"sort_by" binding:"oneoforempty=_id name author expected_interval created updated"`
}

type Heartbeat

type Heartbeat struct {
	ID               string                 `bson:"_id,omitempty" json:"_id"`
	Name             string                 `bson:"name" json:"name"`
	Description      string                 `bson:"description" json:"description"`
	Author           string                 `bson:"author" json:"author"`
	Pattern          map[string]string      `bson:"pattern" json:"pattern"`
	ExpectedInterval types.CpsShortDuration `bson:"expected_interval" json:"expected_interval"`
	Output           string                 `bson:"output" json:"output"`
	Created          *types.CpsTime         `bson:"created,omitempty" json:"created" swaggertype:"integer"`
	Updated          *types.CpsTime         `bson:"updated,omitempty" json:"updated" swaggertype:"integer"`
}

type ModelTransformer

type ModelTransformer interface {
	TransformCreateRequestToModel(request CreateRequest) *Heartbeat
	TransformUpdateRequestToModel(request UpdateRequest) *Heartbeat
	TransformBulkCreateRequestToModels(request BulkCreateRequest) []*Heartbeat
	TransformBulkUpdateRequestToModels(request BulkUpdateRequest) []*Heartbeat
}

func NewModelTransformer

func NewModelTransformer() ModelTransformer

type NotFoundError

type NotFoundError error

type Store

type Store interface {
	Insert(model []*Heartbeat) error
	Find(r FilteredQuery) (*AggregationResult, error)
	GetOneBy(id string) (*Heartbeat, error)
	Update(model []*Heartbeat) error
	Delete(ids []string) error
}

Store is an interface for heartbeats storage

func NewStore

func NewStore(db mongo.DbClient) Store

NewStore instantiates heartbeat store.

type UpdateRequest

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

Jump to

Keyboard shortcuts

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