def save_plugin_configuration(plugin_ref) -> Response: """ Endpoint for persisting a plugin configuration """ project = Project.find() payload = request.get_json() plugin = ConfigService(project).get_plugin(plugin_ref) # TODO iterate pipelines and save each, also set this connector's profile (reuse `pipelineInFocusIndex`?) settings = PluginSettingsService(project, show_hidden=False) for profile in payload: # select the correct profile name = profile["name"] plugin.use_profile(plugin.get_profile(name)) for name, value in profile["config"].items(): if not validate_plugin_config(plugin, name, value, project, settings): continue if value == "": settings.unset(db.session, plugin, name) else: settings.set(db.session, plugin, name, value) profiles = settings.profiles_with_config(db.session, plugin, redacted=True) for profile in profiles: freeze_profile_config_keys(profile) return jsonify(profiles)
def save_plugin_configuration(plugin_ref) -> Response: """ Endpoint for persisting a plugin configuration """ project = Project.find() payload = request.get_json() plugins_service = ProjectPluginsService(project) plugin = plugins_service.get_plugin(plugin_ref) settings = PluginSettingsService(project, plugin, plugins_service=plugins_service, show_hidden=False) config = payload.get("config", {}) for name, value in config.items(): if not validate_plugin_config(plugin, name, value, project, settings): continue if value == "": settings.unset(name, session=db.session) else: settings.set(name, value, session=db.session) return jsonify(get_config_with_metadata(settings))
def save_plugin_configuration(plugin_ref) -> Response: """ endpoint for persisting a plugin configuration """ project = Project.find() payload = request.get_json() settings = PluginSettingsService(project) for name, value in payload.items(): # we want to prevent the edition of protected settings from the UI if settings.find_setting(plugin_ref, name).get("protected"): logging.warning( "Cannot set a 'protected' configuration externally.") continue if value == "": settings.unset(db.session, plugin_ref, name) else: settings.set(db.session, plugin_ref, name, value) return jsonify(settings.as_config(db.session, plugin_ref, redacted=True))