def get(self): """Method to handle system configuration GET requests""" try: config = yield Config.find(limit=1) # Return a 404 if not found. if config is None: abort(404, message={'error': "Could not get the system configuration"}) returnValue(marshal(config, self.fields)) except TimeoutError: log.error("REST API timeout retrieving application {appeui}", appeui=euiString(appeui))
def put(self): """Method to handle system configuration PUT requests Args: appeui (int): Application EUI """ try: config = yield Config.find(limit=1) # Return a 404 if not found. if config is None: abort(404, message={'error': "Could not get the system configuration"}) # Filter args params = {k: v for k, v in self.args.iteritems() if v is not None} # Set the new attributes for a,v in params.items(): setattr(config, a, v) # Validate the configuration (valid, message) = config.check() if not valid: abort(400, message=message) # Reload the config (success, message) = self.server.reload(config) if not success: abort(500, message=message) yield config.save() returnValue(({}, 200)) except TimeoutError: log.error("REST API timeout retrieving application {appeui}", appeui=euiString(appeui)) except TimeoutError: log.error("REST API timeout retrieving application {appeui}", appeui=euiString(appeui))