def put(self, request, plugin_id, *args, **kwargs): """ 应用插件配置更新 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 服务别名 required: true type: string paramType: path - name: plugin_id description: 插件ID required: true type: string paramType: path - name: body description: 配置内容 required: true type: string paramType: body """ sid = None try: logger.debug("update service plugin config ") config = json.loads(request.body) logger.debug("====> {0}".format(config)) if not config: return Response(general_message(400, "params error", "参数配置不可为空"), status=400) pbv = plugin_version_service.get_newest_usable_plugin_version(plugin_id) if not pbv: return Response(general_message(400, "no usable plugin version", "无最新更新的版本信息,无法更新配置"), status=400) sid = transaction.savepoint() # 删除原有配置 app_plugin_service.delete_service_plugin_config(self.service, plugin_id) # 全量插入新配置 app_plugin_service.update_service_plugin_config(self.service, plugin_id, pbv.build_version, config) # 更新数据中心配置 region_config = app_plugin_service.get_region_config_from_db(self.service, plugin_id, pbv.build_version) region_api.update_service_plugin_config(self.response_region, self.tenant.tenant_name, self.service.service_alias, plugin_id, region_config) # 提交操作 transaction.savepoint_commit(sid) result = general_message(200, "success", "配置更新成功") except Exception as e: logger.exception(e) if sid: transaction.savepoint_rollback(sid) result = error_message(e.message) return Response(result, result["code"])
def put(self, request, plugin_id, *args, **kwargs): """ 组件插件配置更新 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 组件别名 required: true type: string paramType: path - name: plugin_id description: 插件ID required: true type: string paramType: path - name: body description: 配置内容 required: true type: string paramType: body """ config = json.loads(request.body) if not config: return Response(general_message(400, "params error", "参数配置不可为空"), status=400) pbv = plugin_version_service.get_newest_usable_plugin_version( self.tenant.tenant_id, plugin_id) if not pbv: return Response(general_message(400, "no usable plugin version", "无最新更新的版本信息,无法更新配置"), status=400) # update service plugin config app_plugin_service.update_service_plugin_config( self.tenant, self.service, plugin_id, pbv.build_version, config, self.response_region) result = general_message(200, "success", "配置更新成功") return Response(result, result["code"])