diff options
author | James Lopez <james@jameslopez.es> | 2018-02-13 09:24:10 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2018-02-13 15:25:48 +0100 |
commit | 583ed0eb94ff938b4986491e27af5f3c97ea6baf (patch) | |
tree | 0102e58fa8f4789af8e0d2ce3745ba9583492896 /lib/api | |
parent | 7ec1a022b79c68dd3232c0abf07d119f0dad808f (diff) | |
download | gitlab-ce-583ed0eb94ff938b4986491e27af5f3c97ea6baf.tar.gz |
add import status endpoint
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/project_import.rb | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/api/project_import.rb b/lib/api/project_import.rb index 5a4e4189a58..d554d6d12bd 100644 --- a/lib/api/project_import.rb +++ b/lib/api/project_import.rb @@ -16,12 +16,13 @@ module API not_found! unless Gitlab::CurrentSettings.import_sources.include?('gitlab_project') end - params do - requires :path, type: String, desc: 'The new project path and name' - optional :namespace, type: String, desc: 'The ID or name of the namespace that the project will be imported into. Defaults to the user namespace.' - requires :file, type: File, desc: 'The project export file to be imported' - end - resource :projects do + resource :projects, requirements: { id: %r{[^/]+} } do + + params do + requires :path, type: String, desc: 'The new project path and name' + optional :namespace, type: String, desc: 'The ID or name of the namespace that the project will be imported into. Defaults to the user namespace.' + requires :file, type: File, desc: 'The project export file to be imported' + end desc 'Get export status' do success Entities::ProjectImportStatus end @@ -40,13 +41,22 @@ module API project_params = import_params.merge(namespace_id: namespace.id, file: import_params[:file]['tempfile']) - project = ::Projects::GitlabProjectsImportService.new(current_user, project_params).execute - render_api_error!(project.full_messages.first, 400) unless project.saved? + render_api_error!(project&.full_messages&.first, 400) unless project&.saved? present project, with: Entities::ProjectImportStatus end + + params do + requires :id, type: String, desc: 'The ID of a project' + end + desc 'Get export status' do + success Entities::ProjectImportStatus + end + get ':id/import' do + present user_project, with: Entities::ProjectImportStatus + end end end end |