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 flask_restful import current_app
from helpers.Error import ImportApiError from helpers.Error import ImportApiError
from datetime import datetime from datetime import datetime
...@@ -28,8 +28,6 @@ class WriteJobResultToDrupal(Resource): ...@@ -28,8 +28,6 @@ class WriteJobResultToDrupal(Resource):
name: body name: body
required: true required: true
schema: schema:
items:
type: object
properties: properties:
sessionId: sessionId:
type: string type: string
...@@ -86,11 +84,28 @@ class WriteJobResultToDrupal(Resource): ...@@ -86,11 +84,28 @@ class WriteJobResultToDrupal(Resource):
""" """
try: try:
current_app.logger.debug("report data: " + bytes.decode(request.data)) 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' status = 'FAILED'
if fatal == 0: if fatal == 0:
status = 'SUCCESS' 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) return write_results(job_drupal_uuid, job_log_drupal_uuid, status, report)
except ImportApiError as e: except ImportApiError as e:
return {'error': e.message}, 500 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