2020-01-13 16:07:39 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
2020-04-27 23:09:53 -04:00
|
|
|
class ErrorTracking < Grape::API
|
2020-01-13 16:07:39 -05:00
|
|
|
before { authenticate! }
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a project'
|
|
|
|
end
|
|
|
|
|
|
|
|
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
|
|
|
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
|
|
|
|
authorize! :admin_operations, user_project
|
|
|
|
|
|
|
|
setting = user_project.error_tracking_setting
|
|
|
|
|
|
|
|
not_found!('Error Tracking Setting') unless setting
|
|
|
|
|
|
|
|
present setting, with: Entities::ErrorTracking::ProjectSetting
|
|
|
|
end
|
2020-02-05 13:09:06 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
end
|
|
|
|
|
|
|
|
patch ':id/error_tracking/settings/' do
|
|
|
|
authorize! :admin_operations, user_project
|
|
|
|
|
|
|
|
setting = user_project.error_tracking_setting
|
|
|
|
|
|
|
|
not_found!('Error Tracking Setting') unless setting
|
|
|
|
|
|
|
|
update_params = {
|
|
|
|
error_tracking_setting_attributes: { enabled: params[:active] }
|
|
|
|
}
|
|
|
|
|
|
|
|
result = ::Projects::Operations::UpdateService.new(user_project, current_user, update_params).execute
|
|
|
|
|
|
|
|
if result[:status] == :success
|
|
|
|
present setting, with: Entities::ErrorTracking::ProjectSetting
|
|
|
|
else
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|
2020-01-13 16:07:39 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|