Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
f86b3a26
Commit
f86b3a26
authored
Aug 03, 2020
by
Greg Messner
Browse files
Added createProject(name, path) method (#601)
parent
1366c31d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/ProjectApi.java
View file @
f86b3a26
...
@@ -913,6 +913,25 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -913,6 +913,25 @@ public class ProjectApi extends AbstractApi implements Constants {
return
(
response
.
readEntity
(
Project
.
class
));
return
(
response
.
readEntity
(
Project
.
class
));
}
}
/**
* Creates a new project owned by the authenticated user.
*
* @param name the name of the project top create. Equals path if not provided.
* @param path repository name for new project. Generated based on name if not provided (generated lowercased with dashes).
* @return the created project
* @throws GitLabApiException if any exception occurs
*/
public
Project
createProject
(
String
name
,
String
path
)
throws
GitLabApiException
{
if
((
name
==
null
||
name
.
trim
().
isEmpty
())
&&
(
path
==
null
||
path
.
trim
().
isEmpty
()))
{
throw
new
RuntimeException
(
"Either name or path must be specified."
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"name"
,
name
).
withParam
(
"path"
,
path
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
return
(
response
.
readEntity
(
Project
.
class
));
}
/**
/**
* Creates new project owned by the current user.
* Creates new project owned by the current user.
*
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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