mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 00:18:27 +00:00
Add aliases for order keys in API (#329)
Aliases `hostname` (`host_name`) and `memory` (`physical_memory`) when used as keys for ordering in the API this allows for better consistency on the frontend. To be cleaned up further in #317
This commit is contained in:
parent
8438278ba3
commit
6b5019d65e
2 changed files with 10 additions and 6 deletions
|
|
@ -121,11 +121,6 @@ func (r listHostsResponse) error() error { return r.Err }
|
|||
func makeListHostsEndpoint(svc kolide.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
req := request.(listHostsRequest)
|
||||
// Special case this key so that the frontend can migrate to using only "hostname"
|
||||
// TODO #317 remove special cases for host_name by standardizing on hostname
|
||||
if req.ListOptions.OrderKey == "hostname" {
|
||||
req.ListOptions.OrderKey = "host_name"
|
||||
}
|
||||
hosts, err := svc.ListHosts(ctx, req.ListOptions)
|
||||
if err != nil {
|
||||
return listHostsResponse{Err: err}, nil
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import (
|
|||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/fleetdm/fleet/server/kolide"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
@ -144,6 +144,15 @@ func listOptionsFromRequest(r *http.Request) (kolide.ListOptions, error) {
|
|||
|
||||
}
|
||||
|
||||
// Special some keys so that the frontend can use consistent names.
|
||||
// TODO #317 remove special cases
|
||||
switch orderKey {
|
||||
case "hostname":
|
||||
orderKey = "host_name"
|
||||
case "memory":
|
||||
orderKey = "physical_memory"
|
||||
}
|
||||
|
||||
return kolide.ListOptions{
|
||||
Page: uint(page),
|
||||
PerPage: uint(perPage),
|
||||
|
|
|
|||
Loading…
Reference in a new issue