Skip to content

Commit

Permalink
add createProject method with full params.
Browse files Browse the repository at this point in the history
  • Loading branch information
六幻 committed May 12, 2015
1 parent f876816 commit 04a31e4
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/main/java/com/messners/gitlab/api/ProjectApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,45 @@ public Project createProject (Project project, String importUrl) throws GitLabAp
return (response.getEntity(Project.class));
}

/**
* Creates a Project
*
* @param name The name of the project
* @param namespaceId The Namespace for the new project, otherwise null indicates to use the GitLab default (user)
* @param description A description for the project, null otherwise
* @param issuesEnabled Whether Issues should be enabled, otherwise null indicates to use GitLab default
* @param wallEnabled Whether The Wall should be enabled, otherwise null indicates to use GitLab default
* @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default
* @param wikiEnabled Whether a Wiki should be enabled, otherwise null indicates to use GitLab default
* @param snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default
* @param publik Whether the project is public or private, if true same as setting visibilityLevel = 20, otherwise null indicates to use GitLab default
* @param visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
* @param importUrl The Import URL for the project, otherwise null
* @return the Gitlab Project
* @throws GitLabApiException
*/
public Project createProject(String name, Integer namespaceId, String description, Boolean issuesEnabled, Boolean wallEnabled, Boolean mergeRequestsEnabled, Boolean wikiEnabled, Boolean snippetsEnabled, Boolean publik, Integer visibilityLevel, String importUrl) throws GitLabApiException{

if (name == null || name.trim().length() == 0) {
return (null);
}

Form formData = new Form();
addFormParam(formData, "name", name, true);
addFormParam(formData, "namespace_id", namespaceId);
addFormParam(formData, "description", description);
addFormParam(formData, "issues_enabled", issuesEnabled);
addFormParam(formData, "wall_enabled", wallEnabled);
addFormParam(formData, "merge_requests_enabled", mergeRequestsEnabled);
addFormParam(formData, "wiki_enabled", wikiEnabled);
addFormParam(formData, "snippets_enabled", snippetsEnabled);
addFormParam(formData, "public", publik);
addFormParam(formData, "visibility_level", visibilityLevel);
addFormParam(formData, "import_url", importUrl);

ClientResponse response = post(ClientResponse.Status.CREATED, formData, "projects");
return (response.getEntity(Project.class));
}

/**
* Removes project with all resources(issues, merge requests etc).
Expand Down

0 comments on commit 04a31e4

Please sign in to comment.