diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/settings/operations_controller.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/controllers/projects/settings/operations_controller.rb b/app/controllers/projects/settings/operations_controller.rb index 164cd5b9384..a9d1dc0759d 100644 --- a/app/controllers/projects/settings/operations_controller.rb +++ b/app/controllers/projects/settings/operations_controller.rb @@ -4,6 +4,9 @@ module Projects module Settings class OperationsController < Projects::ApplicationController before_action :authorize_admin_operations! + before_action :authorize_read_prometheus_alerts!, only: [:reset_alerting_token] + + respond_to :json, only: [:reset_alerting_token] helper_method :error_tracking_setting @@ -27,8 +30,24 @@ module Projects end end + def reset_alerting_token + result = ::Projects::Operations::UpdateService + .new(project, current_user, alerting_params) + .execute + + if result[:status] == :success + render json: { token: project.alerting_setting.token } + else + render json: {}, status: :unprocessable_entity + end + end + private + def alerting_params + { alerting_setting_attributes: { regenerate_token: true } } + end + def prometheus_service project.find_or_initialize_service(::PrometheusService.to_param) end |