def POST(self): """ List all meta of a list of data identifiers. HTTP Success: 200 OK HTTP Error: 400 Bad Request 401 Unauthorized 404 DataIdentifierNotFound 500 InternalError :returns: A list of dictionaries containing all meta. """ header('Content-Type', 'application/x-json-stream') json_data = data() try: params = parse_response(json_data) dids = params['dids'] except KeyError as error: raise generate_http_error(400, 'ValueError', 'Cannot find mandatory parameter : %s' % str(error)) except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') try: for meta in get_metadata_bulk(dids): yield render_json(**meta) + '\n' except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') except DataIdentifierNotFound as error: raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error)
def post(self): """ List all meta of a list of data identifiers. HTTP Success: 200 OK HTTP Error: 400 Bad Request 401 Unauthorized 404 DataIdentifierNotFound 500 InternalError :returns: A list of dictionaries containing all meta. """ json_data = request.data try: params = loads(json_data) dids = params['dids'] except KeyError as error: return generate_http_error_flask( 400, 'ValueError', 'Cannot find mandatory parameter : %s' % str(error)) except ValueError: return generate_http_error_flask( 400, 'ValueError', 'Cannot decode json parameter list') try: data = "" for meta in get_metadata_bulk(dids): data += render_json(**meta) + '\n' return Response(data, content_type='application/x-json-stream') except ValueError: return generate_http_error_flask( 400, 'ValueError', 'Cannot decode json parameter list') except DataIdentifierNotFound as error: return generate_http_error_flask(404, 'DataIdentifierNotFound', error.args[0]) except RucioException as error: return generate_http_error_flask(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) return error, 500
def generate(vo): for meta in get_metadata_bulk(dids, vo=vo): yield render_json(**meta) + '\n'