2016-09-04 05:13:42 +00:00
|
|
|
package kolide
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
type PackStore interface {
|
|
|
|
// Pack methods
|
|
|
|
NewPack(pack *Pack) error
|
|
|
|
SavePack(pack *Pack) error
|
2016-10-03 03:14:35 +00:00
|
|
|
DeletePack(pid uint) error
|
|
|
|
Pack(pid uint) (*Pack, error)
|
2016-10-14 15:59:27 +00:00
|
|
|
ListPacks(opt ListOptions) ([]*Pack, error)
|
2016-09-04 05:13:42 +00:00
|
|
|
|
|
|
|
// Modifying the queries in packs
|
2016-10-03 03:14:35 +00:00
|
|
|
AddQueryToPack(qid uint, pid uint) error
|
2016-10-14 15:59:27 +00:00
|
|
|
ListQueriesInPack(pack *Pack) ([]*Query, error)
|
2016-09-04 05:13:42 +00:00
|
|
|
RemoveQueryFromPack(query *Query, pack *Pack) error
|
2016-10-03 03:14:35 +00:00
|
|
|
|
|
|
|
// Modifying the labels for packs
|
|
|
|
AddLabelToPack(lid uint, pid uint) error
|
2016-10-14 15:59:27 +00:00
|
|
|
ListLabelsForPack(pack *Pack) ([]*Label, error)
|
2016-10-03 03:14:35 +00:00
|
|
|
RemoveLabelFromPack(label *Label, pack *Pack) error
|
2016-09-04 05:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PackService interface {
|
2016-10-13 18:21:47 +00:00
|
|
|
ListPacks(ctx context.Context, opt ListOptions) ([]*Pack, error)
|
2016-09-04 05:13:42 +00:00
|
|
|
GetPack(ctx context.Context, id uint) (*Pack, error)
|
|
|
|
NewPack(ctx context.Context, p PackPayload) (*Pack, error)
|
|
|
|
ModifyPack(ctx context.Context, id uint, p PackPayload) (*Pack, error)
|
|
|
|
DeletePack(ctx context.Context, id uint) error
|
|
|
|
|
|
|
|
AddQueryToPack(ctx context.Context, qid, pid uint) error
|
2016-10-14 15:59:27 +00:00
|
|
|
ListQueriesInPack(ctx context.Context, id uint) ([]*Query, error)
|
2016-09-04 05:13:42 +00:00
|
|
|
RemoveQueryFromPack(ctx context.Context, qid, pid uint) error
|
2016-10-03 03:14:35 +00:00
|
|
|
|
|
|
|
AddLabelToPack(ctx context.Context, lid, pid uint) error
|
2016-10-14 15:59:27 +00:00
|
|
|
ListLabelsForPack(ctx context.Context, pid uint) ([]*Label, error)
|
2016-10-03 03:14:35 +00:00
|
|
|
RemoveLabelFromPack(ctx context.Context, lid, pid uint) error
|
2016-10-17 19:30:47 +00:00
|
|
|
|
|
|
|
ListPacksForHost(ctx context.Context, hid uint) ([]*Pack, error)
|
2016-09-04 05:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Pack struct {
|
2016-10-11 16:22:11 +00:00
|
|
|
ID uint `json:"id" gorm:"primary_key"`
|
|
|
|
CreatedAt time.Time `json:"-"`
|
|
|
|
UpdatedAt time.Time `json:"-"`
|
|
|
|
Name string `json:"name" gorm:"not null;unique_index:idx_pack_unique_name"`
|
|
|
|
Platform string `json:"platform"`
|
2016-09-04 05:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PackQuery struct {
|
|
|
|
ID uint `gorm:"primary_key"`
|
|
|
|
CreatedAt time.Time
|
|
|
|
UpdatedAt time.Time
|
|
|
|
PackID uint
|
|
|
|
QueryID uint
|
|
|
|
}
|
|
|
|
|
|
|
|
type PackTarget struct {
|
|
|
|
ID uint `gorm:"primary_key"`
|
|
|
|
PackID uint
|
2016-11-02 14:59:53 +00:00
|
|
|
Target
|
2016-09-04 05:13:42 +00:00
|
|
|
}
|