2016-08-01 16:07:00 +08:00
|
|
|
package annotations
|
|
|
|
|
2020-09-02 14:07:31 +08:00
|
|
|
import (
|
|
|
|
"context"
|
2021-03-29 21:47:16 +08:00
|
|
|
"errors"
|
2020-09-02 14:07:31 +08:00
|
|
|
|
2024-06-13 12:11:35 +08:00
|
|
|
"github.com/grafana/grafana/pkg/apimachinery/errutil"
|
2020-09-02 14:07:31 +08:00
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
|
)
|
2016-08-01 16:07:00 +08:00
|
|
|
|
2021-03-29 21:47:16 +08:00
|
|
|
var (
|
2022-09-23 18:04:41 +08:00
|
|
|
ErrTimerangeMissing = errors.New("missing timerange")
|
2023-08-22 18:52:24 +08:00
|
|
|
ErrBaseTagLimitExceeded = errutil.BadRequest("annotations.tag-limit-exceeded", errutil.WithPublicMessage("Tags length exceeds the maximum allowed."))
|
2021-03-29 21:47:16 +08:00
|
|
|
)
|
|
|
|
|
2022-10-19 09:48:20 +08:00
|
|
|
//go:generate mockery --name Repository --structname FakeAnnotationsRepo --inpackage --filename annotations_repository_mock.go
|
2016-08-01 16:07:00 +08:00
|
|
|
type Repository interface {
|
2022-09-19 15:54:37 +08:00
|
|
|
Save(ctx context.Context, item *Item) error
|
2022-11-04 23:39:26 +08:00
|
|
|
SaveMany(ctx context.Context, items []Item) error
|
2022-03-22 19:20:57 +08:00
|
|
|
Update(ctx context.Context, item *Item) error
|
|
|
|
Find(ctx context.Context, query *ItemQuery) ([]*ItemDTO, error)
|
2022-03-26 01:23:09 +08:00
|
|
|
Delete(ctx context.Context, params *DeleteParams) error
|
|
|
|
FindTags(ctx context.Context, query *TagsQuery) (FindTagsResult, error)
|
2016-08-30 15:32:56 +08:00
|
|
|
}
|
|
|
|
|
2022-09-22 20:27:48 +08:00
|
|
|
// Cleaner is responsible for cleaning up old annotations
|
|
|
|
type Cleaner interface {
|
|
|
|
Run(ctx context.Context, cfg *setting.Cfg) (int64, int64, error)
|
2020-09-02 14:07:31 +08:00
|
|
|
}
|