def get_data_status_messages(): component_id = request.args.get('component_id') component_type = request.args.get('component_type') message_id = request.args.get('message_id', None) level = request.args.get('level') if level is not None: level = level.split(',') order_desc = request.args.get('order_desc') page = request.args.get('page', 1) if page is not None: if not is_valid_integer(page): return make_error( "The parameter page (%s) is not a valid integer value" % str(page), 500) page = int(page) if message_id is not None: if not is_valid_integer(message_id): return make_error( "The parameter message_id (%s) is not a valid integer value" % str(message_id), 500) message_id = int(message_id) page_row = request.args.get('page_rows', 50) if page_row is not None: page_row = int(page_row) orderby = request.args.get('order_by') if orderby not in ['creation_time', 'component_type', 'level', '', None]: return make_bad_request( "Invalid parameter order by. Allowed values are ('creation_time','component_type','level','')" ) (success, data) = get_status_messages(component_id=component_id, level=level, orderby=orderby, page=page, page_row=page_row, order_desc=order_desc, component_type=component_type, message_id=message_id) if not success: return make_error(data, 500) return make_ok(**data)
def get_data_status_messages(): component_id = request.args.get('component_id') component_type = request.args.get('component_type') message_id = request.args.get('message_id',None) level = request.args.get('level') if level is not None: level = level.split(',') order_desc = request.args.get('order_desc') page = request.args.get('page', 1) if page is not None: if not is_valid_integer(page): return make_error("The parameter page (%s) is not a valid integer value" % str(page),500) page = int(page) if message_id is not None: if not is_valid_integer(message_id): return make_error("The parameter message_id (%s) is not a valid integer value" % str(message_id),500) message_id = int(message_id) page_row = request.args.get('page_rows', 50) if page_row is not None: page_row = int(page_row) orderby = request.args.get('order_by') if orderby not in ['creation_time','component_type','level','', None]: return make_bad_request("Invalid parameter order by. Allowed values are ('creation_time','component_type','level','')") (success, data) = get_status_messages(component_id=component_id, level=level, orderby=orderby, page=page, page_row=page_row, order_desc=order_desc, component_type=component_type, message_id=message_id) if not success: return make_error(data, 500) return make_ok(**data)
def get_data_status_messages(): """Retrieves a list of current_status messages matching the given criteria""" component_id = request.args.get('component_id') component_type = request.args.get('component_type') message_id = request.args.get('message_id', None) search = request.args.get('search', None) order_desc = is_json_true(request.args.get('order_desc')) only_unread = is_json_true(request.args.get('only_unread')) level = request.args.get('level') if level is not None: level = level.split(',') valid_levels = ["info","warning","error"] if not set(level).issubset(valid_levels): return make_bad_request("Invalid parameter level. Allowed valeus are %s" % str(valid_levels)) page = request.args.get('page', 1) if page is not None: if not is_valid_integer(page): return make_bad_request("The parameter page (%s) is not a valid integer value" % str(page)) page = int(page) page_row = request.args.get('page_rows', 50) if page_row is not None: page_row = int(page_row) message_type = request.args.get('message_type', None) if message_type is not None: message_type = message_type.split(',') orderby = request.args.get('order_by') if orderby not in ['creation_time', 'component_type', 'message_level', 'message_type', 'message_title', '', None]: return make_bad_request("Invalid parameter order by. Allowed values are ('creation_time','component_type','" "message_level','message_type','message_title','')") (success, data) = get_status_messages(component_id=component_id, message_level=level, order_by=orderby, page=page, page_row=page_row, order_desc=order_desc, component_type=component_type, message_id=message_id, message_type=message_type, search=search, only_unread=only_unread, login_user=current_user.login, is_admin=current_user.is_admin) if not success: return make_error(data, 500) return make_ok(**data)