2020-01-13 16:07:39 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
2021-09-27 17:09:27 -04:00
|
|
|
class ErrorTracking::ProjectSettings < ::API::Base
|
2020-01-13 16:07:39 -05:00
|
|
|
before { authenticate! }
|
|
|
|
|
2020-10-29 08:08:50 -04:00
|
|
|
feature_category :error_tracking
|
|
|
|
|
2021-08-19 08:08:53 -04:00
|
|
|
helpers do
|
|
|
|
def project_setting
|
|
|
|
@project_setting ||= user_project.error_tracking_setting
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-13 16:07:39 -05:00
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a project'
|
|
|
|
end
|
|
|
|
|
|
|
|
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
2021-08-19 08:08:53 -04:00
|
|
|
before do
|
|
|
|
authorize! :admin_operations, user_project
|
|
|
|
|
|
|
|
not_found!('Error Tracking Setting') unless project_setting
|
|
|
|
end
|
|
|
|
|
2020-01-13 16:07:39 -05:00
|
|
|
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-08-19 08:08:53 -04:00
|
|
|
present project_setting, with: Entities::ErrorTracking::ProjectSetting
|
2020-01-13 16:07:39 -05:00
|
|
|
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
|
2021-08-17 02:08:59 -04:00
|
|
|
optional :integrated, type: Boolean, desc: 'Specifying whether to enable or disable integrated error tracking'
|
2020-02-05 13:09:06 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
patch ':id/error_tracking/settings/' do
|
|
|
|
update_params = {
|
|
|
|
error_tracking_setting_attributes: { enabled: params[:active] }
|
|
|
|
}
|
|
|
|
|
2021-08-17 02:08:59 -04:00
|
|
|
unless params[:integrated].nil?
|
|
|
|
update_params[:error_tracking_setting_attributes][:integrated] = params[:integrated]
|
|
|
|
end
|
|
|
|
|
2020-02-05 13:09:06 -05:00
|
|
|
result = ::Projects::Operations::UpdateService.new(user_project, current_user, update_params).execute
|
|
|
|
|
|
|
|
if result[:status] == :success
|
2021-08-19 08:08:53 -04:00
|
|
|
present project_setting, with: Entities::ErrorTracking::ProjectSetting
|
2020-02-05 13:09:06 -05:00
|
|
|
else
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|
2020-01-13 16:07:39 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|