debian-mirror-gitlab/lib/api/error_tracking/project_settings.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
2.6 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module API
2021-11-18 22:05:49 +05:30
class ErrorTracking::ProjectSettings < ::API::Base
2020-03-13 15:44:24 +05:30
before { authenticate! }
2023-01-13 00:05:48 +05:30
ERROR_TRACKING_PROJECT_SETTINGS_TAGS = %w[error_tracking_project_settings].freeze
2021-01-29 00:20:46 +05:30
feature_category :error_tracking
2022-07-23 23:45:48 +05:30
urgency :low
2021-01-29 00:20:46 +05:30
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
2023-01-13 00:05:48 +05:30
requires :id, types: [String, Integer],
desc: 'The ID or URL-encoded path of the project owned by the authenticated user'
2020-03-13 15:44:24 +05:30
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
2023-01-13 00:05:48 +05:30
desc 'Get Error Tracking settings' do
detail 'Get error tracking settings for the project. This feature was introduced in GitLab 12.7.'
2020-03-13 15:44:24 +05:30
success Entities::ErrorTracking::ProjectSetting
2023-01-13 00:05:48 +05:30
tags ERROR_TRACKING_PROJECT_SETTINGS_TAGS
2020-03-13 15:44:24 +05:30
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
2023-01-13 00:05:48 +05:30
desc 'Enable or disable the Error Tracking project settings' do
detail 'The API allows you to enable or disable the Error Tracking settings for a project.'\
'Only for users with the Maintainer role for the project.'
2020-03-13 15:44:24 +05:30
success Entities::ErrorTracking::ProjectSetting
2023-01-13 00:05:48 +05:30
failure [
{ code: 400, message: 'Bad request' },
{ code: 401, message: 'Unauthorized' },
{ code: 404, message: 'Not found' }
]
tags ERROR_TRACKING_PROJECT_SETTINGS_TAGS
2020-03-13 15:44:24 +05:30
end
params do
2023-01-13 00:05:48 +05:30
requires :active,
type: Boolean,
desc: 'Pass true to enable the already configured Error Tracking settings or false to disable it.',
allow_blank: false
optional :integrated,
type: Boolean,
desc: 'Pass true to enable the integrated Error Tracking backend. Available in GitLab 14.2 and later.'
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