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
044bf324
Unverified
Commit
044bf324
authored
Mar 08, 2022
by
Gautier de Saint Martin Lacaze
Committed by
GitHub
Mar 08, 2022
Browse files
Merge pull request #779 from jojansen/master
Create new projects from project template.
parents
9401aace
a319e7d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/ProjectApi.java
View file @
044bf324
...
...
@@ -1195,6 +1195,30 @@ public class ProjectApi extends AbstractApi implements Constants {
return
(
response
.
readEntity
(
Project
.
class
));
}
/**
* Create a new project from a template, belonging to the namespace ID. A namespace ID is either a user or group ID.
*
* @param namespaceId the namespace ID to create the project under
* @param projectName the name of the project top create
* @param groupWithProjectTemplatesId Id of the Gitlab Group, which contains the relevant templates.
* @param templateName name of the template to use
* @param visibility Visibility of the new create project
* @return the created project
* @throws GitLabApiException if any exception occurs
*/
public
Project
createProjectFromTemplate
(
Integer
namespaceId
,
String
projectName
,
Integer
groupWithProjectTemplatesId
,
String
templateName
,
Visibility
visibility
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"namespace_id"
,
namespaceId
)
.
withParam
(
"name"
,
projectName
,
true
)
.
withParam
(
"use_custom_template"
,
true
)
.
withParam
(
"group_with_project_templates_id"
,
groupWithProjectTemplatesId
,
true
)
.
withParam
(
"template_name"
,
templateName
,
true
)
.
withParam
(
"visibility"
,
visibility
)
;
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
return
(
response
.
readEntity
(
Project
.
class
));
}
/**
* Updates a project. The following properties on the Project instance
* are utilized in the edit of the project, null values are not updated:
...
...
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