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

Function update_record

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

913
914
915def update_record(params, record, **kwargs):
916 """ Push a record update to the cloud.
917 Takes a Record() object, converts to record JSON
918 and pushes to the Keeper cloud API
919 """
920
921 if (record and record.record_uid in params.record_cache
922 and 'version' in params.record_cache[record.record_uid]
923 and params.record_cache[record.record_uid]['version'] == 3):
924 return update_record_v3(params, record, **kwargs)
925
926 record_rq = prepare_record(params, record)
927 if record_rq is None:
928 return
929
930 request = {
931 'command': 'record_update',
932 'update_records': [record_rq]
933 }
934 response_json = communicate(params, request)
935
936 new_revision = 0
937 if 'update_records' in response_json:
938 for info in response_json['update_records']:
939 if info['record_uid'] == record.record_uid:
940 if info['status'] == 'success':
941 new_revision = response_json['revision']
942
943 if new_revision == 0:
944 logging.error('Error: Revision not updated')
945 return False
946
947 if new_revision == record_rq['revision']:
948 logging.error('Error: Revision did not change')
949 return False
950
951 if not kwargs.get('silent'):
952 logging.info('Update record successful for record_uid=%s, revision=%d, new_revision=%s',
953 record_rq['record_uid'], record_rq['revision'], new_revision)
954
955 record_rq['revision'] = new_revision
956
957 # sync down the data which updates the caches
958 sync_down(params)
959 add_record_audit_data(params, [record.record_uid])
960 return True
961
962
963def get_pb2_record_update(params, rec, **kwargs):

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected