def get_archive_blind_credential_list(): limit = request.args.get( 'limit', default=settings.HISTORY_PAGE_LIMIT, type=int, ) page = request.args.get('page', default=None, type=str) if page: try: page = decode_last_evaluated_key(page) except Exception: logger.exception('Failed to parse provided page') return jsonify({'error': 'Failed to parse page'}), 400 blind_credentials = [] results = BlindCredential.data_type_date_index.query( 'archive-blind-credential', scan_index_forward=False, limit=limit, last_evaluated_key=page, ) for cred in results: blind_credentials.append({ 'id': cred.id, 'name': cred.name, 'credential_pairs': cred.credential_pairs, 'credential_keys': list(cred.credential_keys), 'cipher_type': cred.cipher_type, 'cipher_version': cred.cipher_version, 'metadata': cred.metadata, 'revision': cred.revision, 'enabled': cred.enabled, 'data_key': cred.data_key, 'modified_date': cred.modified_date, 'modified_by': cred.modified_by, 'documentation': cred.documentation }) credential_list = {'blind_credentials': blind_credentials} credential_list['next_page'] = encode_last_evaluated_key( results.last_evaluated_key ) return jsonify(credential_list)
def encode_next_page(self, item): item.next_page = encode_last_evaluated_key(item.next_page) return item