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

Function update_record

keepercommander/api.py:976–1021  ·  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

974
975
976def update_record(params, record, **kwargs):
977 """ Push a record update to the cloud.
978 Takes a Record() object, converts to record JSON
979 and pushes to the Keeper cloud API
980 """
981
982 if (record and record.record_uid in params.record_cache
983 and 'version' in params.record_cache[record.record_uid]
984 and params.record_cache[record.record_uid]['version'] == 3):
985 return update_record_v3(params, record, **kwargs)
986
987 record_rq = prepare_record(params, record)
988 if record_rq is None:
989 return
990
991 request = {
992 'command': 'record_update',
993 'update_records': [record_rq]
994 }
995 response_json = communicate(params, request)
996
997 new_revision = 0
998 if 'update_records' in response_json:
999 for info in response_json['update_records']:
1000 if info['record_uid'] == record.record_uid:
1001 if info['status'] == 'success':
1002 new_revision = response_json['revision']
1003
1004 if new_revision == 0:
1005 logging.error('Error: Revision not updated')
1006 return False
1007
1008 if new_revision == record_rq['revision']:
1009 logging.error('Error: Revision did not change')
1010 return False
1011
1012 if not kwargs.get('silent'):
1013 logging.info('Update record successful for record_uid=%s, revision=%d, new_revision=%s',
1014 record_rq['record_uid'], record_rq['revision'], new_revision)
1015
1016 record_rq['revision'] = new_revision
1017
1018 # sync down the data which updates the caches
1019 sync_down(params)
1020 add_record_audit_data(params, [record.record_uid])
1021 return True
1022
1023
1024def 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
communicateFunction · 0.85
update_record_v3Function · 0.70
add_record_audit_dataFunction · 0.70
errorMethod · 0.45
getMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected