mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
b901c4c0d3
- Add saved state to query (to differentiate queries explicitly saved from those just run as distributed queries) - Remove unique constraint on query name Closes #390
77 lines
1.8 KiB
Go
77 lines
1.8 KiB
Go
package kolide
|
|
|
|
import (
|
|
"time"
|
|
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
type QueryStore interface {
|
|
// Query methods
|
|
NewQuery(query *Query) (*Query, error)
|
|
SaveQuery(query *Query) error
|
|
DeleteQuery(query *Query) error
|
|
Query(id uint) (*Query, error)
|
|
ListQueries(opt ListOptions) ([]*Query, error)
|
|
}
|
|
|
|
type QueryService interface {
|
|
ListQueries(ctx context.Context, opt ListOptions) ([]*Query, error)
|
|
GetQuery(ctx context.Context, id uint) (*Query, error)
|
|
NewQuery(ctx context.Context, p QueryPayload) (*Query, error)
|
|
ModifyQuery(ctx context.Context, id uint, p QueryPayload) (*Query, error)
|
|
DeleteQuery(ctx context.Context, id uint) error
|
|
}
|
|
|
|
type QueryPayload struct {
|
|
Name *string `json:"name"`
|
|
Description *string `json:"description"`
|
|
Query *string `json:"query"`
|
|
Interval *uint `json:"interval"`
|
|
Snapshot *bool `json:"snapshot"`
|
|
Differential *bool `json:"differential"`
|
|
Platform *string `json:"platform"`
|
|
Version *string `json:"version"`
|
|
}
|
|
|
|
type Query struct {
|
|
UpdateCreateTimestamps
|
|
DeleteFields
|
|
ID uint `json:"id"`
|
|
Saved bool `json:"saved"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Query string `json:"query"`
|
|
Interval uint `json:"interval"`
|
|
Snapshot bool `json:"snapshot"`
|
|
Differential bool `json:"differential"`
|
|
Platform string `json:"platform"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
type Option struct {
|
|
ID uint
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
Key string
|
|
Value string
|
|
Platform string
|
|
}
|
|
|
|
type DecoratorType int
|
|
|
|
const (
|
|
DecoratorLoad DecoratorType = iota
|
|
DecoratorAlways
|
|
DecoratorInterval
|
|
)
|
|
|
|
type Decorator struct {
|
|
ID uint
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
Type DecoratorType
|
|
Interval int
|
|
Query string
|
|
}
|