fleet/server/kolide/queries.go
Zachary Wasserman bc6109fb56 Fixes for saved queries (#576)
- Only saved queries should be returned by ListQueries
- Bugfixes

Addresses #388
2016-12-06 10:16:04 -08:00

80 lines
2.0 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 returns a list of saved queries. Note only saved queries
// should be returned (those that are created for distributed queries
// but not saved should not be returned).
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"`
Name string `json:"name"`
Description string `json:"description"`
Query string `json:"query"`
Interval uint `json:"interval"`
Saved bool `json:"saved"`
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
}