diff --git a/backdrop/write/api.py b/backdrop/write/api.py index d953b9ab..2b66cfd7 100644 --- a/backdrop/write/api.py +++ b/backdrop/write/api.py @@ -83,8 +83,13 @@ def write_by_group(data_group, data_type): @app.route('/', methods=['POST']) @cache_control.nocache def post_to_data_set(data_set_name): + app.logger.warning("Deprecated use of write API by name: {}".format( + data_set_name)) data_set_config = data_set_repository.retrieve(name=data_set_name) - return _write_to_data_set(data_set_config) + return _write_to_data_set( + data_set_config, + ok_message="Deprecation Warning: accessing by data-set name is " + "deprecated, Please use the /data-group/data-type form.") @app.route('/data-sets/', methods=['POST']) @@ -153,7 +158,7 @@ def _allow_create_collection(auth_header): return _allow_modify_collection(auth_header) -def _write_to_data_set(data_set_config): +def _write_to_data_set(data_set_config, ok_message=None): if data_set_config is None: return jsonify(status="error", message='Could not find data_set_config'), 404 @@ -175,8 +180,11 @@ def _write_to_data_set(data_set_config): data_set = DataSet(db, data_set_config) data_set.parse_and_store(data) + if ok_message: + return jsonify(status='ok', message=ok_message) + else: + return jsonify(status='ok') - return jsonify(status='ok') except (ParseError, ValidationError) as e: return jsonify(status="error", message=str(e)), 400