def post(self): """ Save service info @api {post} /api/v1/serviceinfo/ Set server notes @apiParam {String} loginName The user that submitted the task @apiParam {String} configurationPath A Zookeeper path corresponding with an Application @apiParam {String} serviceInfo The notes about an application @apiVersion 1.0.0 @apiName SetNotes @apiGroup Server Notes """ try: login_name = self.get_argument("loginName") configuration_path = self.get_argument("configurationPath") service_info = self.get_argument("serviceInfo") db = Database(self.configuration) query = db.save_service_info(login_name, configuration_path, service_info) if query: logging.info("User {0} saved service information for {1}" .format(login_name, configuration_path)) self.write(query) else: logging.info("Error occurred while saving service info for {0} by " "user {1}".format(login_name, configuration_path)) self.write("Error: Info for {0} could not be saved!" .format(configuration_path)) except Exception as e: self.set_status(INTERNAL_SERVER_ERROR) self.write({'errorText': str(e)}) logging.exception(e)
def post(self): """ Save service info """ try: login_name = self.get_argument("loginName") configuration_path = self.get_argument("configurationPath") service_info = self.get_argument("serviceInfo") db = Database(self.configuration) query = db.save_service_info(login_name, configuration_path, service_info) if query: logging.info("User {0} saved service information for {1}" .format(login_name, configuration_path)) self.write(query) else: logging.info("Error occurred while saving service info for {0} by " "user {1}".format(login_name, configuration_path)) self.write("Error: Info for {0} could not be saved!" .format(configuration_path)) except Exception as e: self.set_status(INTERNAL_SERVER_ERROR) self.write({'errorText': str(e)}) logging.exception(e)
def get(self): """ Get service info """ try: configuration_path = self.get_argument("configurationPath") db = Database(self.configuration) query = db.fetch_service_info(configuration_path) self.write({'servicedata':query}) except Exception as e: self.set_status(INTERNAL_SERVER_ERROR) self.write({'errorText': str(e)}) logging.exception(e)
def post(self): """ @api {post} /api/v1/filters Save|Delete filter for user @apiParam {String} operation add|remove @apiParam {String} name The name of the filter @apiParam {String} loginName The user that submitted the task @apiParam {String} parameter The type of search filter @apiParam {String} searchTerm The search variable @apiParam {Boolean} inversed Whether to inverse the search @apiVersion 1.0.0 @apiName ManageFilter @apiGroup Filters """ try: operation = self.get_argument("operation") name = self.get_argument("name") login_name = self.get_argument("loginName") parameter = self.get_argument("parameter") search_term = self.get_argument("searchTerm") inversed = self.get_argument("inversed") f = CustomFilter(name, login_name, parameter, search_term, inversed) db = Database(self.configuration) if operation == OperationType.ADD: query = db.save_filter(f) elif operation == OperationType.REMOVE: query = db.delete_filter(f) else: query = None if query: logging.info("User {0} {1} filter {2}: success".format( login_name, operation, name)) self.write(query) else: output = ("Could not {0} filter '{1}' for user {2}".format( operation, name, login_name)) logging.warning(output) self.write(output) except Exception as e: self.set_status(INTERNAL_SERVER_ERROR) self.write({'errorText': str(e)}) logging.exception(e)
def get(self): """ Get service info @api {get} /api/v1/serviceinfo/ Get server Notes @apiParam {String} login_user The user that submitted the task @apiVersion 1.0.0 @apiName GetNotes @apiGroup Server Notes """ try: configuration_path = self.get_argument("configurationPath") db = Database(self.configuration) query = db.fetch_service_info(configuration_path) self.write({'servicedata': query}) except Exception as e: self.set_status(INTERNAL_SERVER_ERROR) self.write({'errorText': str(e)}) logging.exception(e)
def get(self): """ @api {get} /api/v1/filters Retrieve filters for user @apiParam {String} loginName The user that submitted the task @apiVersion 1.0.0 @apiName GetFilters @apiGroup Filters """ try: login_name = self.get_argument("loginName") db = Database(self.configuration) filters = db.fetch_all_filters(login_name) arr = [] for f in filters: arr.append(f.to_dictionary()) self.write(json.dumps(arr)) except Exception as e: self.set_status(INTERNAL_SERVER_ERROR) self.write({'errorText': str(e)}) logging.exception(e)
def post(self): """ Save service info @api {post} /api/v1/serviceinfo/ Set server notes @apiParam {String} loginName The user that submitted the task @apiParam {String} configurationPath A Zookeeper path corresponding with an Application @apiParam {String} serviceInfo The notes about an application @apiVersion 1.0.0 @apiName SetNotes @apiGroup Server Notes """ try: login_name = self.get_argument("loginName") configuration_path = self.get_argument("configurationPath") service_info = self.get_argument("serviceInfo") db = Database(self.configuration) query = db.save_service_info(login_name, configuration_path, service_info) if query: logging.info( "User {0} saved service information for {1}".format( login_name, configuration_path)) self.write(query) else: logging.info( "Error occurred while saving service info for {0} by " "user {1}".format(login_name, configuration_path)) self.write("Error: Info for {0} could not be saved!".format( configuration_path)) except Exception as e: self.set_status(INTERNAL_SERVER_ERROR) self.write({'errorText': str(e)}) logging.exception(e)