diff options
author | Travis Miller <travis@travismiller.com> | 2017-12-02 13:49:01 -0600 |
---|---|---|
committer | Travis Miller <travis@travismiller.com> | 2018-02-28 20:47:36 -0600 |
commit | c75187df8ce7d376ddc2c7201ce74d45b49fe5d9 (patch) | |
tree | 81d737e6759996435433cbe436cd1e9004bde177 /lib/api | |
parent | a4308c53e5db594a6e351b143e11ceba6033cdc7 (diff) | |
download | gitlab-ce-c75187df8ce7d376ddc2c7201ce74d45b49fe5d9.tar.gz |
Add project export API implementation
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/project_export.rb | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index 754549f72f0..6c96dccc08a 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -138,6 +138,7 @@ module API mount ::API::PagesDomains mount ::API::Pipelines mount ::API::PipelineSchedules + mount ::API::ProjectExport mount ::API::ProjectImport mount ::API::ProjectHooks mount ::API::Projects diff --git a/lib/api/project_export.rb b/lib/api/project_export.rb new file mode 100644 index 00000000000..8b2c5bedc60 --- /dev/null +++ b/lib/api/project_export.rb @@ -0,0 +1,36 @@ +module API + class ProjectExport < Grape::API + before do + not_found! unless Gitlab::CurrentSettings.current_application_settings.project_export_enabled? + 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 + success Entities::ProjectExportStatus + end + get ':id/export' do + present user_project, with: Entities::ProjectExportStatus + end + + desc 'Download export' + 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 + + desc 'Start export' + post ':id/export' do + user_project.add_export_job(current_user: current_user) + + accepted! + end + end + end +end |