mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
0b7747bef0
Replaces (and appropriately refactors) a number of endpoints that were removed long ago when we decided to kill the UI with the fleetctl release. We turned out not to do this, and now need to restore these missing endpoints. This is not a straight up replacement of the existing code because of refactoring to the DB schemas that was also done in the migration. Most of the replaced code was removed in #1670 and #1686. Fixes #1811, fixes #1810
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func decodeGetScheduledQueriesInPackRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
id, err := idFromRequest(r, "id")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var req getScheduledQueriesInPackRequest
|
|
req.ID = id
|
|
return req, nil
|
|
}
|
|
|
|
func decodeScheduleQueryRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
var req scheduleQueryRequest
|
|
|
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
func decodeModifyScheduledQueryRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
id, err := idFromRequest(r, "id")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var req modifyScheduledQueryRequest
|
|
|
|
if err := json.NewDecoder(r.Body).Decode(&req.payload); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.ID = id
|
|
return req, nil
|
|
}
|
|
|
|
func decodeDeleteScheduledQueryRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
id, err := idFromRequest(r, "id")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var req deleteScheduledQueryRequest
|
|
req.ID = id
|
|
return req, nil
|
|
}
|
|
|
|
func decodeGetScheduledQueryRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
id, err := idFromRequest(r, "id")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var req getScheduledQueryRequest
|
|
req.ID = id
|
|
return req, nil
|
|
}
|