Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/main/java/org/gitlab4j/api/ProjectApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,30 @@ public Project createProject(String name, Integer namespaceId, String descriptio
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:
Expand Down