2017-12-02 14:49:01 -05:00
|
|
|
module API
|
|
|
|
class ProjectExport < Grape::API
|
|
|
|
before do
|
2018-02-28 22:32:03 -05:00
|
|
|
not_found! unless Gitlab::CurrentSettings.project_export_enabled?
|
2017-12-02 14:49:01 -05:00
|
|
|
authorize_admin_project
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a project'
|
|
|
|
end
|
|
|
|
resource :projects, requirements: { id: %r{[^/]+} } do
|
|
|
|
desc 'Get export status' do
|
2018-02-24 22:18:46 -05:00
|
|
|
detail 'This feature was introduced in GitLab 10.6.'
|
2017-12-02 14:49:01 -05:00
|
|
|
success Entities::ProjectExportStatus
|
|
|
|
end
|
|
|
|
get ':id/export' do
|
|
|
|
present user_project, with: Entities::ProjectExportStatus
|
|
|
|
end
|
|
|
|
|
2018-02-24 22:18:46 -05:00
|
|
|
desc 'Download export' do
|
|
|
|
detail 'This feature was introduced in GitLab 10.6.'
|
|
|
|
end
|
2017-12-02 14:49:01 -05:00
|
|
|
get ':id/export/download' do
|
|
|
|
path = user_project.export_project_path
|
|
|
|
|
|
|
|
render_api_error!('404 Not found or has expired', 404) unless path
|
|
|
|
|
|
|
|
present_file!(path, File.basename(path), 'application/gzip')
|
|
|
|
end
|
|
|
|
|
2018-02-24 22:18:46 -05:00
|
|
|
desc 'Start export' do
|
|
|
|
detail 'This feature was introduced in GitLab 10.6.'
|
|
|
|
end
|
2017-12-02 14:49:01 -05:00
|
|
|
post ':id/export' do
|
|
|
|
user_project.add_export_job(current_user: current_user)
|
|
|
|
|
|
|
|
accepted!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|