def item_update(item_id): # Check ACL if not func.acl_approval(): return func.error(CONST.STRINGS['ACCESS_DENIED']) # Get data from POST data = request.json # Get current current_data = json.loads(es.get(index=CONFIG.ES_INDEX, doc_type='item', id=item_id)) # Modify current_data['_source'][data.keys()[0]] = data[0] # Update es.update(index=CONFIG.ES_INDEX, doc_type='item', id=item_id, body=current_data)
def item_get(item_id): # Return singular item by id # Get whitelist white_list = func.get_white_list(_default_white_list) # Get known attributes known_filters = func.get_known_filters() # Get item res = func.filter_response( white_list, known_filters, [], es.get(index=CONFIG.ES_INDEX, doc_type="item", id=item_id) ) return func.respond(res)