1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
12 "git.arvados.org/arvados.git/sdk/go/arvados"
15 // GroupCreate defers to railsProxy for everything except vocabulary
17 func (conn *Conn) GroupCreate(ctx context.Context, opts arvados.CreateOptions) (arvados.Group, error) {
19 err := conn.checkProperties(ctx, opts.Attrs["properties"])
21 return arvados.Group{}, err
23 resp, err := conn.railsProxy.GroupCreate(ctx, opts)
30 func (conn *Conn) GroupGet(ctx context.Context, opts arvados.GetOptions) (arvados.Group, error) {
32 return conn.railsProxy.GroupGet(ctx, opts)
35 // GroupUpdate defers to railsProxy for everything except vocabulary
37 func (conn *Conn) GroupUpdate(ctx context.Context, opts arvados.UpdateOptions) (arvados.Group, error) {
39 err := conn.checkProperties(ctx, opts.Attrs["properties"])
41 return arvados.Group{}, err
43 resp, err := conn.railsProxy.GroupUpdate(ctx, opts)
50 func (conn *Conn) GroupList(ctx context.Context, opts arvados.ListOptions) (arvados.GroupList, error) {
52 return conn.railsProxy.GroupList(ctx, opts)
55 func (conn *Conn) GroupDelete(ctx context.Context, opts arvados.DeleteOptions) (arvados.Group, error) {
57 return conn.railsProxy.GroupDelete(ctx, opts)
60 func (conn *Conn) GroupContents(ctx context.Context, options arvados.GroupContentsOptions) (arvados.ObjectList, error) {
63 // The requested UUID can be a user (virtual home project), which we just pass on to
65 if strings.Index(options.UUID, "-j7d0g-") != 5 {
66 return conn.railsProxy.GroupContents(ctx, options)
69 var resp arvados.ObjectList
71 // Get the group object
72 respGroup, err := conn.GroupGet(ctx, arvados.GetOptions{UUID: options.UUID})
77 // If the group has groupClass 'filter', apply the filters before getting the contents.
78 if respGroup.GroupClass == "filter" {
79 if filters, ok := respGroup.Properties["filters"].([]interface{}); ok {
80 for _, f := range filters {
81 // f is supposed to be a []string
82 tmp, ok2 := f.([]interface{})
83 if !ok2 || len(tmp) < 3 {
84 return resp, fmt.Errorf("filter unparsable: %T, %+v, original field: %T, %+v\n", tmp, tmp, f, f)
86 var filter arvados.Filter
87 if attr, ok2 := tmp[0].(string); ok2 {
90 return resp, fmt.Errorf("filter unparsable: attribute must be string: %T, %+v, filter: %T, %+v\n", tmp[0], tmp[0], f, f)
92 if operator, ok2 := tmp[1].(string); ok2 {
93 filter.Operator = operator
95 return resp, fmt.Errorf("filter unparsable: operator must be string: %T, %+v, filter: %T, %+v\n", tmp[1], tmp[1], f, f)
97 filter.Operand = tmp[2]
98 options.Filters = append(options.Filters, filter)
101 return resp, fmt.Errorf("filter unparsable: not an array\n")
103 // Use the generic /groups/contents endpoint for filter groups
107 return conn.railsProxy.GroupContents(ctx, options)