Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
82ff66ef
Commit
82ff66ef
authored
Feb 12, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add post import API endpoint
parent
848f4980
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
lib/api/project_import.rb
lib/api/project_import.rb
+48
-0
No files found.
lib/api/project_import.rb
0 → 100644
View file @
82ff66ef
module
API
class
ProjectImport
<
Grape
::
API
include
PaginationParams
helpers
do
def
import_params
declared_params
(
include_missing:
false
)
end
def
file_is_valid?
import_params
[
:file
]
&&
import_params
[
:file
].
respond_to?
(
:read
)
end
end
before
do
not_found!
unless
Gitlab
::
CurrentSettings
.
import_sources
.
include?
(
'gitlab_project'
)
end
params
do
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
desc
'Get export status'
do
success
Entities
::
ProjectImportStatus
end
post
'import'
do
render_api_error!
(
'The branch refname is invalid'
,
400
)
unless
file_is_valid?
namespace
=
import_params
[
:namespace
]
namespace
=
if
namespace
&&
namespace
=~
/^\d+$/
Namespace
.
find_by
(
id:
namespace
)
elsif
namespace
.
blank?
current_user
.
namespace
else
Namespace
.
find_by_path_or_name
(
namespace
)
end
project
=
::
Projects
::
GitlabProjectsImportService
.
new
(
current_user
,
import_params
).
execute
render_api_error!
(
link
.
project
.
full_messages
.
first
,
400
)
unless
project
.
saved?
present
project
,
with:
Entities
::
ProjectImportStatus
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment