diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /lib/api/group_export.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'lib/api/group_export.rb')
-rw-r--r-- | lib/api/group_export.rb | 116 |
1 files changed, 61 insertions, 55 deletions
diff --git a/lib/api/group_export.rb b/lib/api/group_export.rb index eb0a01e0d3d..37dfbfdb925 100644 --- a/lib/api/group_export.rb +++ b/lib/api/group_export.rb @@ -64,67 +64,73 @@ module API end end - desc 'Start relations export' do - detail 'This feature was introduced in GitLab 13.12' - tags %w[group_export] - success code: 202 - failure [ - { code: 401, message: 'Unauthorized' }, - { code: 403, message: 'Forbidden' }, - { code: 404, message: 'Not found' }, - { code: 503, message: 'Service unavailable' } - ] - end - post ':id/export_relations' do - response = ::BulkImports::ExportService.new(portable: user_group, user: current_user).execute + resource do + before do + not_found! unless Gitlab::CurrentSettings.bulk_import_enabled? + end - if response.success? - accepted! - else - render_api_error!(message: 'Group relations export could not be started.') + desc 'Start relations export' do + detail 'This feature was introduced in GitLab 13.12' + tags %w[group_export] + success code: 202 + failure [ + { code: 401, message: 'Unauthorized' }, + { code: 403, message: 'Forbidden' }, + { code: 404, message: 'Not found' }, + { code: 503, message: 'Service unavailable' } + ] end - end + post ':id/export_relations' do + response = ::BulkImports::ExportService.new(portable: user_group, user: current_user).execute - desc 'Download relations export' do - detail 'This feature was introduced in GitLab 13.12' - produces %w[application/octet-stream application/json] - tags %w[group_export] - success code: 200 - failure [ - { code: 401, message: 'Unauthorized' }, - { code: 403, message: 'Forbidden' }, - { code: 404, message: 'Not found' }, - { code: 503, message: 'Service unavailable' } - ] - end - params do - requires :relation, type: String, desc: 'Group relation name' - end - get ':id/export_relations/download' do - export = user_group.bulk_import_exports.find_by_relation(params[:relation]) - file = export&.upload&.export_file + if response.success? + accepted! + else + render_api_error!(message: 'Group relations export could not be started.') + end + end - if file - present_carrierwave_file!(file) - else - render_api_error!('404 Not found', 404) + desc 'Download relations export' do + detail 'This feature was introduced in GitLab 13.12' + produces %w[application/octet-stream application/json] + tags %w[group_export] + success code: 200 + failure [ + { code: 401, message: 'Unauthorized' }, + { code: 403, message: 'Forbidden' }, + { code: 404, message: 'Not found' }, + { code: 503, message: 'Service unavailable' } + ] end - end + params do + requires :relation, type: String, desc: 'Group relation name' + end + get ':id/export_relations/download' do + export = user_group.bulk_import_exports.find_by_relation(params[:relation]) + file = export&.upload&.export_file - desc 'Relations export status' do - detail 'This feature was introduced in GitLab 13.12' - is_array true - tags %w[group_export] - success code: 200, model: Entities::BulkImports::ExportStatus - failure [ - { code: 401, message: 'Unauthorized' }, - { code: 403, message: 'Forbidden' }, - { code: 404, message: 'Not found' }, - { code: 503, message: 'Service unavailable' } - ] - end - get ':id/export_relations/status' do - present user_group.bulk_import_exports, with: Entities::BulkImports::ExportStatus + if file + present_carrierwave_file!(file) + else + render_api_error!('404 Not found', 404) + end + end + + desc 'Relations export status' do + detail 'This feature was introduced in GitLab 13.12' + is_array true + tags %w[group_export] + success code: 200, model: Entities::BulkImports::ExportStatus + failure [ + { code: 401, message: 'Unauthorized' }, + { code: 403, message: 'Forbidden' }, + { code: 404, message: 'Not found' }, + { code: 503, message: 'Service unavailable' } + ] + end + get ':id/export_relations/status' do + present user_group.bulk_import_exports, with: Entities::BulkImports::ExportStatus + end end end end |