summaryrefslogtreecommitdiff
path: root/app/controllers/projects/settings
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-25 09:08:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-25 09:08:11 +0000
commit5064bf8c5647d4c4430cbb4d097cf1592416de29 (patch)
treed051bf2abe2cc7061b3a7facb6669a56ccb9cf54 /app/controllers/projects/settings
parent9c83aadd2604e7e6cb1f84683f951e6b12872618 (diff)
downloadgitlab-ce-5064bf8c5647d4c4430cbb4d097cf1592416de29.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/projects/settings')
-rw-r--r--app/controllers/projects/settings/operations_controller.rb19
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