3 Copyright (C) The Arvados Authors. All rights reserved.
5 SPDX-License-Identifier: CC-BY-SA-3.0
8 import arvados.util as util
10 def get_subproject_uuids(api, root_uuid):
12 groups = util.keyset_list_all(api.groups().list, filters=[['owner_uuid', '=', '{}'.format(root_uuid)]], select=['uuid'], order='uuid')
14 uuids += ([g['uuid']] + get_subproject_uuids(api, g['uuid']))
17 def get_cols(api, filters):
18 cols = util.keyset_list_all(api.collections().list, filters=filters, select=['uuid', 'properties'], order='uuid')
21 # Search for collections on project hierarchy rooted at root_uuid
22 root_uuid = 'zzzzz-j7d0g-ppppppppppppppp'
23 # Set the property to the UUID below
24 responsible_uuid = 'zzzzz-tpzed-xxxxxxxxxxxxxxx'
27 for p_uuid in [root_uuid] + get_subproject_uuids(api, root_uuid):
28 f = [['properties.responsible_person_uuid', 'exists', False],
29 ['owner_uuid', '=', p_uuid]]
30 cols = get_cols(api, f)
31 print('Found {} collections owned by {}'.format(len(cols), p_uuid))
33 print(' - Updating collection {}'.format(c['uuid']))
34 props = c['properties']
35 props['responsible_person_uuid'] = responsible_uuid
36 api.collections().update(uuid=c['uuid'], body={'properties': props}).execute()