Commit 1109c0fc authored by Matthias's avatar Matthias
Browse files

implement reqparse for reporting

parent 929c9284
from flask_restful import Resource, request
from flask_restful import Resource, request, reqparse
from flask_restful import current_app
from helpers.Error import ImportApiError
from datetime import datetime
......@@ -28,8 +28,6 @@ class WriteJobResultToDrupal(Resource):
name: body
required: true
schema:
items:
type: object
properties:
sessionId:
type: string
......@@ -86,11 +84,28 @@ class WriteJobResultToDrupal(Resource):
"""
try:
current_app.logger.debug("report data: " + bytes.decode(request.data))
fatal = request.json[0]['fatal']
parser = reqparse.RequestParser()
parser.add_argument('earliest')
parser.add_argument('elapsedTime')
parser.add_argument('fatal')
parser.add_argument('ignore')
parser.add_argument('institutionId')
parser.add_argument('latest')
parser.add_argument('messageId')
parser.add_argument('previousMessageId')
parser.add_argument('recordSetId')
parser.add_argument('sessionId')
parser.add_argument('step')
parser.add_argument('success')
parser.add_argument('total')
parser.add_argument('version')
parser.add_argument('warning')
args = parser.parse_args()
fatal = args['fatal']
status = 'FAILED'
if fatal == 0:
status = 'SUCCESS'
report = json.dumps(request.json[0], indent=2)
report = json.dumps(request.json, indent=2)
return write_results(job_drupal_uuid, job_log_drupal_uuid, status, report)
except ImportApiError as e:
return {'error': e.message}, 500
......
Supports Markdown
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