Commit 0c69e7ed authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

#9

parent 81793868
Pipeline #5890 passed with stages
in 37 minutes and 37 seconds
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import json import json
import logging import logging
from typing import Tuple, Union from typing import Tuple, Union
from uuid import UUID
from flask import Blueprint, session, request, jsonify, Response from flask import Blueprint, session, request, jsonify, Response
...@@ -93,8 +94,8 @@ def get_all_data() -> Tuple[Response, int]: ...@@ -93,8 +94,8 @@ def get_all_data() -> Tuple[Response, int]:
return jsonify({'data_states': data_states}), 200 return jsonify({'data_states': data_states}), 200
@data_blueprint.route('/<string:task_id>', methods=['DELETE']) @data_blueprint.route('/<uuid:task_id>', methods=['DELETE'])
def delete_data(task_id: str) -> Tuple[Response, int]: def delete_data(task_id: UUID) -> Tuple[Response, int]:
"""Remove all traces of the data associated with the given task id. """Remove all traces of the data associated with the given task id.
:param task_id: The id associated with the data :param task_id: The id associated with the data
See doc/api/ for more information. See doc/api/ for more information.
...@@ -102,6 +103,7 @@ def delete_data(task_id: str) -> Tuple[Response, int]: ...@@ -102,6 +103,7 @@ def delete_data(task_id: str) -> Tuple[Response, int]:
""" """
logger.debug("Received DELETE request on /data/task_id.") logger.debug("Received DELETE request on /data/task_id.")
wait = request.args.get('wait') == '1' wait = request.args.get('wait') == '1'
task_id = str(task_id)
if task_id not in session['data_tasks']: if task_id not in session['data_tasks']:
error = "Task ID '{}' not found in session. " \ error = "Task ID '{}' not found in session. " \
"Refusing access.".format(task_id) "Refusing access.".format(task_id)
...@@ -133,13 +135,14 @@ def delete_all_data() -> Tuple[Response, int]: ...@@ -133,13 +135,14 @@ def delete_all_data() -> Tuple[Response, int]:
return jsonify(''), 200 return jsonify(''), 200
@data_blueprint.route('/meta/<string:task_id>', methods=['GET']) @data_blueprint.route('/meta/<uuid:task_id>', methods=['GET'])
def get_meta_information(task_id: str) -> Tuple[Response, int]: def get_meta_information(task_id: UUID) -> Tuple[Response, int]:
"""Get meta information for given task id. """Get meta information for given task id.
:return: meta information object stored in redis. :return: meta information object stored in redis.
""" """
logger.debug("Received GET request on /data/meta/task_id.") logger.debug("Received GET request on /data/meta/task_id.")
wait = request.args.get('wait') == '1' wait = request.args.get('wait') == '1'
task_id = str(task_id)
if task_id not in session['data_tasks']: if task_id not in session['data_tasks']:
error = "Task ID '{}' not found in session. " \ error = "Task ID '{}' not found in session. " \
"Refusing access.".format(task_id) "Refusing access.".format(task_id)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment