MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / enumerate_record_access_paths

Function enumerate_record_access_paths

keepercommander/api.py:1433–1479  ·  view source on GitHub ↗
(params, record_uid)

Source from the content-addressed store, hash-verified

1431
1432
1433def enumerate_record_access_paths(params, record_uid):
1434 # type: (KeeperParams, str) -> collections.Iterable[dict]
1435
1436 if record_uid in params.meta_data_cache:
1437 rmd = params.meta_data_cache[record_uid]
1438 yield {
1439 'record_uid': record_uid,
1440 'can_edit': rmd.get('can_edit') or False,
1441 'can_share': rmd.get('can_share') or False,
1442 'can_view': True
1443 }
1444
1445 for sf_uid in params.shared_folder_cache:
1446 sf = params.shared_folder_cache[sf_uid]
1447 if 'records' in sf:
1448 sfrs = [x for x in sf['records'] if x['record_uid'] == record_uid]
1449 if len(sfrs) > 0:
1450 sfr = sfrs[0]
1451 is_owner = sfr.get('owner') is True
1452 if is_owner:
1453 can_edit = True
1454 can_share = True
1455 else:
1456 can_edit = sfr['can_edit']
1457 can_share = sfr['can_share']
1458 if 'key_type' in sf:
1459 yield {
1460 'record_uid': record_uid,
1461 'shared_folder_uid': sf_uid,
1462 'can_edit': can_edit,
1463 'can_share': can_share,
1464 'can_view': True
1465 }
1466 else:
1467 if 'teams' in sf:
1468 for sf_team in sf['teams']:
1469 team_uid = sf_team['team_uid']
1470 if team_uid in params.team_cache:
1471 team = params.team_cache[team_uid]
1472 yield {
1473 'record_uid': record_uid,
1474 'shared_folder_uid': sf_uid,
1475 'team_uid': team_uid,
1476 'can_edit': can_edit and not team['restrict_edit'],
1477 'can_share': can_share and not team['restrict_share'],
1478 'can_view': not team['restrict_view']
1479 }
1480
1481
1482def get_record_shares(params, record_uids, is_share_admin=False):

Callers 2

Calls 1

getMethod · 0.45

Tested by

no test coverage detected