diff options
Diffstat (limited to 'lib/api/project_export.rb')
-rw-r--r-- | lib/api/project_export.rb | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/lib/api/project_export.rb b/lib/api/project_export.rb index 4041e130f9e..e01c195dbc4 100644 --- a/lib/api/project_export.rb +++ b/lib/api/project_export.rb @@ -2,8 +2,6 @@ module API class ProjectExport < ::API::Base - helpers Helpers::RateLimiter - feature_category :importers before do @@ -74,6 +72,52 @@ module API accepted! end + + resource do + before do + not_found! unless ::Feature.enabled?(:bulk_import, default_enabled: :yaml) + end + + desc 'Start relations export' do + detail 'This feature was introduced in GitLab 14.4' + end + post ':id/export_relations' do + response = ::BulkImports::ExportService.new(portable: user_project, user: current_user).execute + + if response.success? + accepted! + else + render_api_error!(message: 'Project relations export could not be started.') + end + end + + desc 'Download relations export' do + detail 'This feature was introduced in GitLab 14.4' + end + params do + requires :relation, + type: String, + project_portable: true, + desc: 'Project relation name' + end + get ':id/export_relations/download' do + export = user_project.bulk_import_exports.find_by_relation(params[:relation]) + file = export&.upload&.export_file + + 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 14.4' + end + get ':id/export_relations/status' do + present user_project.bulk_import_exports, with: Entities::BulkImports::ExportStatus + end + end end end end |