1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
13 func (fs *customFileSystem) defaultUUID(uuid string) (string, error) {
18 err := fs.RequestAndDecode(&resp, "GET", "arvados/v1/users/current", nil, nil)
25 // loadOneChild loads only the named child, if it exists.
26 func (fs *customFileSystem) projectsLoadOne(parent inode, uuid, name string) (inode, error) {
27 uuid, err := fs.defaultUUID(uuid)
32 var contents CollectionList
33 err = fs.RequestAndDecode(&contents, "GET", "arvados/v1/groups/"+uuid+"/contents", nil, ResourceListParams{
37 {"uuid", "is_a", []string{"arvados#collection", "arvados#group"}},
38 {"groups.group_class", "=", "project"},
44 if len(contents.Items) == 0 {
45 return nil, os.ErrNotExist
47 coll := contents.Items[0]
49 if strings.Contains(coll.UUID, "-j7d0g-") {
50 // Group item was loaded into a Collection var -- but
51 // we only need the Name and UUID anyway, so it's OK.
52 return fs.newProjectNode(parent, coll.Name, coll.UUID), nil
53 } else if strings.Contains(coll.UUID, "-4zz18-") {
54 return deferredCollectionFS(fs, parent, coll), nil
56 log.Printf("projectnode: unrecognized UUID in response: %q", coll.UUID)
57 return nil, ErrInvalidArgument
61 func (fs *customFileSystem) projectsLoadAll(parent inode, uuid string) ([]inode, error) {
62 uuid, err := fs.defaultUUID(uuid)
69 // Note: the "filters" slice's backing array might be reused
70 // by append(filters,...) below. This isn't goroutine safe,
71 // but all accesses are in the same goroutine, so it's OK.
72 filters := []Filter{{"owner_uuid", "=", uuid}}
73 params := ResourceListParams{
79 var resp CollectionList
80 err = fs.RequestAndDecode(&resp, "GET", "arvados/v1/collections", nil, params)
84 if len(resp.Items) == 0 {
87 for _, i := range resp.Items {
89 if !permittedName(coll.Name) {
92 inodes = append(inodes, deferredCollectionFS(fs, parent, coll))
94 params.Filters = append(filters, Filter{"uuid", ">", resp.Items[len(resp.Items)-1].UUID})
97 filters = append(filters, Filter{"group_class", "=", "project"})
98 params.Filters = filters
101 err = fs.RequestAndDecode(&resp, "GET", "arvados/v1/groups", nil, params)
105 if len(resp.Items) == 0 {
108 for _, group := range resp.Items {
109 if !permittedName(group.Name) {
112 inodes = append(inodes, fs.newProjectNode(parent, group.Name, group.UUID))
114 params.Filters = append(filters, Filter{"uuid", ">", resp.Items[len(resp.Items)-1].UUID})