Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
commite4384360a16dd9a19d4d2d25d0ef1f2b862ed2a6 (patch)
tree2fcdfa7dcdb9db8f5208b2562f4b4e803d671243 /lib/api/project_export.rb
parentffda4e7bcac36987f936b4ba515995a6698698f0 (diff)
Add latest changes from gitlab-org/gitlab@16-2-stable-eev16.2.0-rc42
Diffstat (limited to 'lib/api/project_export.rb')
-rw-r--r--lib/api/project_export.rb50
1 files changed, 40 insertions, 10 deletions
diff --git a/lib/api/project_export.rb b/lib/api/project_export.rb
index 19e5ed3f9e0..8a72ec051dc 100644
--- a/lib/api/project_export.rb
+++ b/lib/api/project_export.rb
@@ -127,8 +127,13 @@ module API
]
tags ['project_export']
end
+ params do
+ optional :batched, type: Boolean, desc: 'Whether to export in batches'
+ end
post ':id/export_relations' do
- response = ::BulkImports::ExportService.new(portable: user_project, user: current_user).execute
+ response = ::BulkImports::ExportService
+ .new(portable: user_project, user: current_user, batched: params[:batched])
+ .execute
if response.success?
accepted!
@@ -152,19 +157,33 @@ module API
produces %w[application/octet-stream application/json]
end
params do
- requires :relation,
- type: String,
- project_portable: true,
- desc: 'Project relation name'
+ requires :relation, type: String, project_portable: true, desc: 'Project relation name'
+ optional :batched, type: Boolean, desc: 'Whether to download in batches'
+ optional :batch_number, type: Integer, desc: 'Batch number to download'
+
+ all_or_none_of :batched, :batch_number
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)
+ break render_api_error!('Export not found', 404) unless export
+
+ if params[:batched]
+ batch = export.batches.find_by_batch_number(params[:batch_number])
+ batch_file = batch&.upload&.export_file
+
+ break render_api_error!('Export is not batched', 400) unless export.batched?
+ break render_api_error!('Batch not found', 404) unless batch
+ break render_api_error!('Batch file not found', 404) unless batch_file
+
+ present_carrierwave_file!(batch_file)
else
- render_api_error!('404 Not found', 404)
+ file = export&.upload&.export_file
+
+ break render_api_error!('Export is batched', 400) if export.batched?
+ break render_api_error!('Export file not found', 404) unless file
+
+ present_carrierwave_file!(file)
end
end
@@ -180,8 +199,19 @@ module API
]
tags ['project_export']
end
+ params do
+ optional :relation, type: String, desc: 'Project relation name'
+ end
get ':id/export_relations/status' do
- present user_project.bulk_import_exports, with: Entities::BulkImports::ExportStatus
+ if params[:relation]
+ export = user_project.bulk_import_exports.find_by_relation(params[:relation])
+
+ break render_api_error!('Export not found', 404) unless export
+
+ present export, with: Entities::BulkImports::ExportStatus
+ else
+ present user_project.bulk_import_exports, with: Entities::BulkImports::ExportStatus
+ end
end
end
end