def merge(id, other_id): entity = get_db_entity(id, request.authz.WRITE) other = get_db_entity(other_id, request.authz.WRITE) try: entity.merge(other) except ValueError as ve: raise BadRequest(ve.message) db.session.commit() data = update_entity(entity) update_entity(other) update_collection(entity.collection) return serialize_data(data, CombinedSchema)
def merge(id, other_id): entity = get_db_entity(id, request.authz.WRITE) other = get_db_entity(other_id, request.authz.WRITE) try: entity.merge(other) except ValueError as ve: raise BadRequest(ve.message) db.session.commit() update_entity(entity) update_entity(other) update_collection(entity.collection) return view(entity.id)
def merge(id, other_id): entity = get_db_entity(id, request.authz.WRITE) other = get_db_entity(other_id, request.authz.WRITE) try: entity.merge(other) except ValueError as ve: raise BadRequest(ve.message) db.session.commit() sync = get_flag('sync', True) data = update_entity(entity, sync=sync) update_entity(other, sync=sync) return EntitySerializer.jsonify(data)
def merge(entity_id, other_id): entity = get_db_entity(entity_id, request.authz.WRITE) other = get_db_entity(other_id, request.authz.WRITE) tag_request(collection_id=entity.collection_id) try: entity.merge(other) except ValueError as ve: raise BadRequest(ve.message) db.session.commit() sync = get_flag('sync', True) data = update_entity(entity, sync=sync) update_entity(other, sync=sync) return EntitySerializer.jsonify(data)
def delete(id): entity = get_db_entity(id, request.authz.WRITE) delete_entity(entity) db.session.commit() update_collection(entity.collection) refresh_index(entities_index()) return ('', 204)
def update(entity_id): entity = get_db_entity(entity_id, request.authz.WRITE) data = parse_request(EntityUpdateSchema) if get_flag('merge'): props = merge_data(data.get('properties'), entity.data) data['properties'] = props entity.update(data) db.session.commit() data = update_entity(entity, sync=get_flag('sync', True)) return EntitySerializer.jsonify(data)
def update(id): entity = get_db_entity(id, request.authz.WRITE) data = parse_request(schema=EntityUpdateSchema) if as_bool(request.args.get('merge')): props = merge_data(data.get('properties'), entity.data) data['properties'] = props entity.update(data) db.session.commit() update_entity(entity) update_collection(entity.collection) return view(entity.id)
def update(entity_id): entity = get_db_entity(entity_id, request.authz.WRITE) tag_request(collection_id=entity.collection_id) data = parse_request(EntityUpdateSchema) if get_flag('merge'): props = merge_data(data.get('properties'), entity.data) data['properties'] = props entity.update(data) db.session.commit() data = update_entity(entity, sync=get_flag('sync', True)) return EntitySerializer.jsonify(data)
def update(id): entity = get_db_entity(id, request.authz.WRITE) data = parse_request(EntityUpdateSchema) sync = get_flag('sync') if get_flag('merge'): props = merge_data(data.get('properties'), entity.data) data['properties'] = props entity.update(data) db.session.commit() data = update_entity(entity, sync=sync) return serialize_data(data, CombinedSchema)
def update(entity_id): """ --- post: summary: Update an entity description: > Update the entity with id `entity_id`. This only applies to entities which are backed by a database row, i.e. not any entities resulting from a mapping or bulk load. parameters: - in: path name: entity_id required: true schema: type: string requestBody: content: application/json: schema: $ref: '#/components/schemas/EntityUpdate' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Entity' tags: - Entity """ entity = get_db_entity(entity_id, request.authz.WRITE) tag_request(collection_id=entity.collection_id) data = parse_request('EntityUpdate') if get_flag('merge'): props = merge_data(data.get('properties'), entity.data) data['properties'] = props entity.update(data) db.session.commit() update_entity(entity, sync=get_flag('sync', True)) entity = get_index_entity(entity_id, request.authz.READ) return EntitySerializer.jsonify(entity)
def delete(entity_id): entity = get_db_entity(entity_id, request.authz.WRITE) tag_request(collection_id=entity.collection_id) delete_entity(entity, sync=True) db.session.commit() return ('', 204)
def delete(id): entity = get_db_entity(id, request.authz.WRITE) delete_entity(entity) db.session.commit() update_collection(entity.collection) return jsonify({'status': 'ok'}, status=410)
def delete(id): entity = get_db_entity(id, request.authz.WRITE) delete_entity(entity, sync=True) db.session.commit() return ('', 204)