def option(option, section): if request.method == "GET": db_option = db.session.query(Option).filter_by( name=option, section=section).first() if db_option: return jsonify(db_option.serialize) if db_option else jsonify(None) return make_response(jsonify({}), 200) elif request.method == "PUT": db_option = db.session.query(Option).filter_by( name=option, section=section).first() if not db_option: # create the new option db_option = Option(name=option, section=section, value="") db.session.add(db_option) # do update changed = db_option.update_value(request.json) db.session.commit() if option == "notifications": if changed: return process_ipc_response(IPCClient().update_configuration()) elif db_option.name == "network" and db_option.section == "dyndns": if os.environ.get("ARGUS_DEVELOPMENT", "0") == "0": return process_ipc_response(IPCClient().update_dyndns()) elif db_option.name == "network" and db_option.section == "access": if os.environ.get("ARGUS_DEVELOPMENT", "0") == "0": return process_ipc_response(IPCClient().update_ssh()) return make_response("", 204) return make_response(jsonify({"error": "Unknown action"}), 400)