Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dynamodb saves #418

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions confidant/routes/blind_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ def create_blind_credential():
if not isinstance(data.get('metadata', {}), dict):
return jsonify({'error': 'metadata must be a dict'}), 400
for cred in BlindCredential.data_type_date_index.query(
'blind-credential', name__eq=data['name']):
'blind-credential',
filter_condition=BlindCredential.name == data['name']
):
# Conflict, the name already exists
msg = 'Name already exists. See id: {0}'.format(cred.id)
return jsonify({'error': msg, 'reference': cred.id}), 409
Expand All @@ -210,7 +212,7 @@ def create_blind_credential():
cipher_version=data['cipher_version'],
modified_by=authnz.get_logged_in_user(),
documentation=data.get('documentation')
).save(id__null=True)
).save()
# Make this the current revision
cred = BlindCredential(
id=id,
Expand Down Expand Up @@ -344,7 +346,7 @@ def update_blind_credential(id):
cipher_version=update['cipher_version'],
modified_by=authnz.get_logged_in_user(),
documentation=update['documentation']
).save(id__null=True)
).save()
except PutError as e:
logger.error(e)
return jsonify(
Expand Down Expand Up @@ -454,7 +456,7 @@ def revert_blind_credential_to_revision(id, to_revision):
cipher_version=revert_credential.cipher_version,
modified_by=authnz.get_logged_in_user(),
documentation=revert_credential.documentation
).save(id__null=True)
).save()
except PutError as e:
logger.error(e)
return jsonify(
Expand Down
8 changes: 4 additions & 4 deletions confidant/routes/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def create_credential():
if not _check:
return jsonify(ret), 400
for cred in Credential.data_type_date_index.query(
'credential', name__eq=data['name']):
'credential', filter_condition=Credential.name == data['name']):
# Conflict, the name already exists
msg = 'Name already exists. See id: {0}'.format(cred.id)
return jsonify({'error': msg, 'reference': cred.id}), 409
Expand All @@ -643,7 +643,7 @@ def create_credential():
documentation=data.get('documentation'),
tags=data.get('tags', []),
last_rotation_date=last_rotation_date,
).save(id__null=True)
).save()
# Make this the current revision
cred = Credential(
id=id,
Expand Down Expand Up @@ -882,7 +882,7 @@ def update_credential(id):
documentation=update['documentation'],
tags=update['tags'],
last_rotation_date=update['last_rotation_date'],
).save(id__null=True)
).save()
except PutError as e:
logger.error(e)
return jsonify({'error': 'Failed to add credential to archive.'}), 500
Expand Down Expand Up @@ -1056,7 +1056,7 @@ def revert_credential_to_revision(id, to_revision):
documentation=revert_credential.documentation,
tags=revert_credential.tags,
last_rotation_date=revert_credential.last_rotation_date,
).save(id__null=True)
).save()
except PutError as e:
logger.error(e)
return jsonify({'error': 'Failed to add credential to archive.'}), 500
Expand Down
4 changes: 2 additions & 2 deletions confidant/routes/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def map_service_credentials(id):
enabled=data.get('enabled'),
revision=revision,
modified_by=authnz.get_logged_in_user()
).save(id__null=True)
).save()
except PutError as e:
logger.error(e)
return jsonify({'error': 'Failed to add service to archive.'}), 500
Expand Down Expand Up @@ -811,7 +811,7 @@ def revert_service_to_revision(id, to_revision):
enabled=revert_service.enabled,
revision=new_revision,
modified_by=authnz.get_logged_in_user()
).save(id__null=True)
).save()
except PutError as e:
logger.error(e)
return jsonify({'error': 'Failed to add service to archive.'}), 500
Expand Down
Loading