fleet/server/service/transport_global_schedule.go
Tomas Touceda 2d553db2aa
Issue 1231 add global schedule (#1383)
* Add Global Schedule

* Uncomment tests

* Uncomment integration tests

* Add targets for global schedule

* Add host label

* Simplify implementation

* wip

* Fix mock

* Add missing test

* Further simplify the implementation

* Forgot to remove test name

* Update names
2021-07-16 10:15:15 -03:00

53 lines
1.1 KiB
Go

package service
import (
"context"
"encoding/json"
"net/http"
)
func decodeGetGlobalScheduleRequest(ctx context.Context, r *http.Request) (interface{}, error) {
opts, err := listOptionsFromRequest(r)
if err != nil {
return nil, err
}
var req getGlobalScheduleRequest
req.ListOptions = opts
return req, nil
}
func decodeModifyGlobalScheduleRequest(ctx context.Context, r *http.Request) (interface{}, error) {
id, err := idFromRequest(r, "id")
if err != nil {
return nil, err
}
var req modifyGlobalScheduleRequest
if err := json.NewDecoder(r.Body).Decode(&req.payload); err != nil {
return nil, err
}
req.ID = id
return req, nil
}
func decodeDeleteGlobalScheduleRequest(ctx context.Context, r *http.Request) (interface{}, error) {
id, err := idFromRequest(r, "id")
if err != nil {
return nil, err
}
var req deleteGlobalScheduleRequest
req.ID = id
return req, nil
}
func decodeGlobalScheduleQueryRequest(ctx context.Context, r *http.Request) (interface{}, error) {
var req globalScheduleQueryRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
return nil, err
}
return req, nil
}