2016-09-26 18:48:55 +00:00
|
|
|
package service
|
2016-09-04 05:13:42 +00:00
|
|
|
|
|
|
|
import (
|
2017-03-15 15:55:30 +00:00
|
|
|
"context"
|
2018-05-04 01:01:57 +00:00
|
|
|
"encoding/json"
|
2016-09-04 05:13:42 +00:00
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func decodeDeletePackRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
2018-05-04 18:05:55 +00:00
|
|
|
name, err := nameFromRequest(r, "name")
|
2016-09-04 05:13:42 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var req deletePackRequest
|
2018-05-04 18:05:55 +00:00
|
|
|
req.Name = name
|
2016-09-04 05:13:42 +00:00
|
|
|
return req, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeGetPackRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
id, err := idFromRequest(r, "id")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var req getPackRequest
|
|
|
|
req.ID = id
|
|
|
|
return req, nil
|
|
|
|
}
|
|
|
|
|
2016-10-13 18:21:47 +00:00
|
|
|
func decodeListPacksRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
opt, err := listOptionsFromRequest(r)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return listPacksRequest{ListOptions: opt}, nil
|
|
|
|
}
|
2018-05-04 01:01:57 +00:00
|
|
|
|
|
|
|
func decodeApplyPackSpecsRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
var req applyPackSpecsRequest
|
|
|
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return req, nil
|
|
|
|
|
|
|
|
}
|