Documentation ¶
Index ¶
- func NewApi(store Store, transformer ModelTransformer, actionLogger logger.ActionLogger) common.BulkCrudAPI
- type AggregationResult
- type BaseEditRequest
- type BulkCreateRequest
- type BulkDeleteRequest
- type BulkUpdateRequest
- type BulkUpdateRequestItem
- type CreateRequest
- type FilteredQuery
- type Heartbeat
- type ModelTransformer
- type NotFoundError
- type Store
- type UpdateRequest
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
type UpdateRequest ¶
type UpdateRequest struct { BaseEditRequest ID string `json:"-"` }
Click to show internal directories.
Click to hide internal directories.