Unverified Commit 044bf324 authored by Gautier de Saint Martin Lacaze's avatar Gautier de Saint Martin Lacaze Committed by GitHub
Browse files

Merge pull request #779 from jojansen/master

Create new projects from project template.
parents 9401aace a319e7d6
...@@ -1195,6 +1195,30 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -1195,6 +1195,30 @@ public class ProjectApi extends AbstractApi implements Constants {
return (response.readEntity(Project.class)); 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 * Updates a project. The following properties on the Project instance
* are utilized in the edit of the project, null values are not updated: * are utilized in the edit of the project, null values are not updated:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment