X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1b79e315b0adf2744e1df1781c198cf698b1c181..055b9792b7692d6c42f4e13d38dc6cd008396a6f:/lib/controller/router/response.go diff --git a/lib/controller/router/response.go b/lib/controller/router/response.go index 2a7bd9e674..03cdcf18d2 100644 --- a/lib/controller/router/response.go +++ b/lib/controller/router/response.go @@ -31,6 +31,9 @@ func (rtr *router) responseOptions(opts interface{}) (responseOptions, error) { case *arvados.ListOptions: rOpts.Select = opts.Select rOpts.Count = opts.Count + case *arvados.GroupContentsOptions: + rOpts.Select = opts.Select + rOpts.Count = opts.Count } return rOpts, nil } @@ -71,37 +74,42 @@ func (rtr *router) sendResponse(w http.ResponseWriter, req *http.Request, resp i } respKind := kind(resp) - if respKind == "arvados#sharedGroupList" { - tmp["kind"] = "arvados#groupList" - } else if respKind != "" { + if respKind != "" { tmp["kind"] = respKind } + if included, ok := tmp["included"]; ok && included == nil { + tmp["included"] = make([]interface{}, 0) + } defaultItemKind := "" if strings.HasSuffix(respKind, "List") { defaultItemKind = strings.TrimSuffix(respKind, "List") } - if items, ok := tmp["items"].([]interface{}); ok { - for i, item := range items { - // Fill in "kind" by inspecting UUID/PDH if - // possible; fall back on assuming each - // Items[] entry in an "arvados#fooList" - // response should have kind="arvados#foo". - item, _ := item.(map[string]interface{}) - infix := "" - if uuid, _ := item["uuid"].(string); len(uuid) == 27 { - infix = uuid[6:11] - } - if k := kind(infixMap[infix]); k != "" { - item["kind"] = k - } else if pdh, _ := item["portable_data_hash"].(string); pdh != "" { - item["kind"] = "arvados#collection" - } else if defaultItemKind != "" { - item["kind"] = defaultItemKind + if _, isListResponse := tmp["items"].([]interface{}); isListResponse { + items, _ := tmp["items"].([]interface{}) + included, _ := tmp["included"].([]interface{}) + for _, slice := range [][]interface{}{items, included} { + for i, item := range slice { + // Fill in "kind" by inspecting UUID/PDH if + // possible; fall back on assuming each + // Items[] entry in an "arvados#fooList" + // response should have kind="arvados#foo". + item, _ := item.(map[string]interface{}) + infix := "" + if uuid, _ := item["uuid"].(string); len(uuid) == 27 { + infix = uuid[6:11] + } + if k := kind(infixMap[infix]); k != "" { + item["kind"] = k + } else if pdh, _ := item["portable_data_hash"].(string); pdh != "" { + item["kind"] = "arvados#collection" + } else if defaultItemKind != "" { + item["kind"] = defaultItemKind + } + item = applySelectParam(opts.Select, item) + rtr.mungeItemFields(item) + slice[i] = item } - item = applySelectParam(opts.Select, item) - rtr.mungeItemFields(item) - items[i] = item } if opts.Count == "none" { delete(tmp, "items_available")