mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
6a825c11e3
Removed Gorm, replaced it with Sqlx * Added SQL bundling command to Makfile * Using go-kit logger * Added soft delete capability * Changed SearchLabel to accept a variadic param for optional omit list instead of array * Gorm removed * Refactor table structures to use CURRENT_TIMESTAMP mysql function * Moved Inmem datastore into it's own package * Updated README * Implemented code review suggestions from @zwass * Removed reference to Gorm from glide.yaml
67 lines
1.8 KiB
Go
67 lines
1.8 KiB
Go
package kolide
|
|
|
|
import (
|
|
"time"
|
|
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
type PackStore interface {
|
|
// Pack methods
|
|
NewPack(pack *Pack) (*Pack, error)
|
|
SavePack(pack *Pack) error
|
|
DeletePack(pid uint) error
|
|
Pack(pid uint) (*Pack, error)
|
|
ListPacks(opt ListOptions) ([]*Pack, error)
|
|
|
|
// Modifying the queries in packs
|
|
AddQueryToPack(qid uint, pid uint) error
|
|
ListQueriesInPack(pack *Pack) ([]*Query, error)
|
|
RemoveQueryFromPack(query *Query, pack *Pack) error
|
|
|
|
// Modifying the labels for packs
|
|
AddLabelToPack(lid uint, pid uint) error
|
|
ListLabelsForPack(pack *Pack) ([]*Label, error)
|
|
RemoveLabelFromPack(label *Label, pack *Pack) error
|
|
}
|
|
|
|
type PackService interface {
|
|
ListPacks(ctx context.Context, opt ListOptions) ([]*Pack, error)
|
|
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
|
|
ListQueriesInPack(ctx context.Context, id uint) ([]*Query, error)
|
|
RemoveQueryFromPack(ctx context.Context, qid, pid uint) error
|
|
|
|
AddLabelToPack(ctx context.Context, lid, pid uint) error
|
|
ListLabelsForPack(ctx context.Context, pid uint) ([]*Label, error)
|
|
RemoveLabelFromPack(ctx context.Context, lid, pid uint) error
|
|
|
|
ListPacksForHost(ctx context.Context, hid uint) ([]*Pack, error)
|
|
}
|
|
|
|
type Pack struct {
|
|
UpdateCreateTimestamps
|
|
DeleteFields
|
|
ID uint `json:"id" gorm:"primary_key"`
|
|
Name string `json:"name" gorm:"not null;unique_index:idx_pack_unique_name"`
|
|
Platform string `json:"platform"`
|
|
}
|
|
|
|
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
|
|
Target
|
|
}
|