Commit f86b3a26 authored by Greg Messner's avatar Greg Messner
Browse files

Added createProject(name, path) method (#601)

parent 1366c31d
...@@ -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.
* *
......
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