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

Function update_record

keepercommander/api.py:985–1030  ·  view source on GitHub ↗

Push a record update to the cloud. Takes a Record() object, converts to record JSON and pushes to the Keeper cloud API

(params, record, **kwargs)

Source from the content-addressed store, hash-verified

983
984
985def update_record(params, record, **kwargs):
986 """ Push a record update to the cloud.
987 Takes a Record() object, converts to record JSON
988 and pushes to the Keeper cloud API
989 """
990
991 if (record and record.record_uid in params.record_cache
992 and 'version' in params.record_cache[record.record_uid]
993 and params.record_cache[record.record_uid]['version'] == 3):
994 return update_record_v3(params, record, **kwargs)
995
996 record_rq = prepare_record(params, record)
997 if record_rq is None:
998 return
999
1000 request = {
1001 'command': 'record_update',
1002 'update_records': [record_rq]
1003 }
1004 response_json = communicate(params, request)
1005
1006 new_revision = 0
1007 if 'update_records' in response_json:
1008 for info in response_json['update_records']:
1009 if info['record_uid'] == record.record_uid:
1010 if info['status'] == 'success':
1011 new_revision = response_json['revision']
1012
1013 if new_revision == 0:
1014 logging.error('Error: Revision not updated')
1015 return False
1016
1017 if new_revision == record_rq['revision']:
1018 logging.error('Error: Revision did not change')
1019 return False
1020
1021 if not kwargs.get('silent'):
1022 logging.info('Update record successful for record_uid=%s, revision=%d, new_revision=%s',
1023 record_rq['record_uid'], record_rq['revision'], new_revision)
1024
1025 record_rq['revision'] = new_revision
1026
1027 # sync down the data which updates the caches
1028 sync_down(params)
1029 add_record_audit_data(params, [record.record_uid])
1030 return True
1031
1032
1033def get_pb2_record_update(params, rec, **kwargs):

Callers 1

run_approvals_sync_downFunction · 0.50

Calls 8

sync_downFunction · 0.90
prepare_recordFunction · 0.85
update_record_v3Function · 0.70
communicateFunction · 0.70
add_record_audit_dataFunction · 0.70
errorMethod · 0.45
getMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected