2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
2021-01-03 14:25:43 +05:30
|
|
|
class ErrorTracking < ::API::Base
|
2020-03-13 15:44:24 +05:30
|
|
|
before { authenticate! }
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
feature_category :error_tracking
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
helpers do
|
|
|
|
def project_setting
|
|
|
|
@project_setting ||= user_project.error_tracking_setting
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a project'
|
|
|
|
end
|
|
|
|
|
|
|
|
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
2021-11-11 11:23:49 +05:30
|
|
|
before do
|
|
|
|
authorize! :admin_operations, user_project
|
|
|
|
|
|
|
|
not_found!('Error Tracking Setting') unless project_setting
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
desc 'Get error tracking settings for the project' do
|
|
|
|
detail 'This feature was introduced in GitLab 12.7.'
|
|
|
|
success Entities::ErrorTracking::ProjectSetting
|
|
|
|
end
|
|
|
|
|
|
|
|
get ':id/error_tracking/settings' do
|
2021-11-11 11:23:49 +05:30
|
|
|
present project_setting, with: Entities::ErrorTracking::ProjectSetting
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Enable or disable error tracking settings for the project' do
|
|
|
|
detail 'This feature was introduced in GitLab 12.8.'
|
|
|
|
success Entities::ErrorTracking::ProjectSetting
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :active, type: Boolean, desc: 'Specifying whether to enable or disable error tracking settings', allow_blank: false
|
2021-10-27 15:23:28 +05:30
|
|
|
optional :integrated, type: Boolean, desc: 'Specifying whether to enable or disable integrated error tracking'
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
patch ':id/error_tracking/settings/' do
|
|
|
|
update_params = {
|
|
|
|
error_tracking_setting_attributes: { enabled: params[:active] }
|
|
|
|
}
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
unless params[:integrated].nil?
|
|
|
|
update_params[:error_tracking_setting_attributes][:integrated] = params[:integrated]
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
result = ::Projects::Operations::UpdateService.new(user_project, current_user, update_params).execute
|
|
|
|
|
|
|
|
if result[:status] == :success
|
2021-11-11 11:23:49 +05:30
|
|
|
present project_setting, with: Entities::ErrorTracking::ProjectSetting
|
2020-03-13 15:44:24 +05:30
|
|
|
else
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|