mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
26dc30bd25
- Add new Apply spec methods for queries and packs - Remove now extraneous datastore/service methods - Remove import service (unused, and had many dependencies that this breaks) - Refactor tests as appropriate
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/go-kit/kit/endpoint"
|
|
"github.com/kolide/fleet/server/kolide"
|
|
)
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Get Scheduled Queries In Pack
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
type getScheduledQueriesInPackRequest struct {
|
|
ID uint
|
|
ListOptions kolide.ListOptions
|
|
}
|
|
|
|
type scheduledQueryResponse struct {
|
|
kolide.ScheduledQuery
|
|
}
|
|
|
|
type getScheduledQueriesInPackResponse struct {
|
|
Scheduled []scheduledQueryResponse `json:"scheduled"`
|
|
Err error `json:"error,omitempty"`
|
|
}
|
|
|
|
func (r getScheduledQueriesInPackResponse) error() error { return r.Err }
|
|
|
|
func makeGetScheduledQueriesInPackEndpoint(svc kolide.Service) endpoint.Endpoint {
|
|
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
|
req := request.(getScheduledQueriesInPackRequest)
|
|
resp := getScheduledQueriesInPackResponse{Scheduled: []scheduledQueryResponse{}}
|
|
|
|
queries, err := svc.GetScheduledQueriesInPack(ctx, req.ID, req.ListOptions)
|
|
if err != nil {
|
|
return getScheduledQueriesInPackResponse{Err: err}, nil
|
|
}
|
|
|
|
for _, q := range queries {
|
|
resp.Scheduled = append(resp.Scheduled, scheduledQueryResponse{
|
|
ScheduledQuery: *q,
|
|
})
|
|
}
|
|
|
|
return resp, nil
|
|
}
|
|
}
|