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

Added support for printing_merge_request_link_enabled when creating and updating a project (#124).

parent 586cc89e
...@@ -567,6 +567,7 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -567,6 +567,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* requestAccessEnabled (optional) - Allow users to request member access * requestAccessEnabled (optional) - Allow users to request member access
* repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins * repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins
* approvalsBeforeMerge (optional) - How many approvers should approve merge request by default * approvalsBeforeMerge (optional) - How many approvers should approve merge request by default
* printingMergeRequestLinkEnabled (optional) - Show link to create/view merge request when pushing from the command line
* *
* @param project the Project instance with the configuration for the new project * @param project the Project instance with the configuration for the new project
* @param importUrl the URL to import the repository from * @param importUrl the URL to import the repository from
...@@ -606,7 +607,8 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -606,7 +607,8 @@ public class ProjectApi extends AbstractApi implements Constants {
.withParam("request_access_enabled", project.getRequestAccessEnabled()) .withParam("request_access_enabled", project.getRequestAccessEnabled())
.withParam("repository_storage", project.getRepositoryStorage()) .withParam("repository_storage", project.getRepositoryStorage())
.withParam("approvals_before_merge", project.getApprovalsBeforeMerge()) .withParam("approvals_before_merge", project.getApprovalsBeforeMerge())
.withParam("import_url", importUrl); .withParam("import_url", importUrl)
.withParam("printing_merge_request_link_enabled", project.getPrintingMergeRequestLinkEnabled());
if (isApiVersion(ApiVersion.V3)) { if (isApiVersion(ApiVersion.V3)) {
boolean isPublic = (project.getPublic() != null ? project.getPublic() : project.getVisibility() == Visibility.PUBLIC); boolean isPublic = (project.getPublic() != null ? project.getPublic() : project.getVisibility() == Visibility.PUBLIC);
...@@ -670,6 +672,54 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -670,6 +672,54 @@ public class ProjectApi extends AbstractApi implements Constants {
return (response.readEntity(Project.class)); return (response.readEntity(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 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 visibility The visibility of the project, otherwise null indicates to use GitLab default
* @param visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
* @param printingMergeRequestLinkEnabled Show link to create/view merge request when pushing from the command line
* @param importUrl The Import URL for the project, otherwise null
* @return the GitLab Project
* @throws GitLabApiException if any exception occurs
*/
public Project createProject(String name, Integer namespaceId, String description, Boolean issuesEnabled, Boolean mergeRequestsEnabled,
Boolean wikiEnabled, Boolean snippetsEnabled, Visibility visibility, Integer visibilityLevel,
Boolean printingMergeRequestLinkEnabled, String importUrl) throws GitLabApiException {
if (isApiVersion(ApiVersion.V3)) {
Boolean isPublic = Visibility.PUBLIC == visibility;
return (createProject(name, namespaceId, description, issuesEnabled, mergeRequestsEnabled,
wikiEnabled, snippetsEnabled, isPublic, visibilityLevel, importUrl));
}
if (name == null || name.trim().length() == 0) {
return (null);
}
GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true)
.withParam("namespace_id", namespaceId)
.withParam("description", description)
.withParam("issues_enabled", issuesEnabled)
.withParam("merge_requests_enabled", mergeRequestsEnabled)
.withParam("wiki_enabled", wikiEnabled)
.withParam("snippets_enabled", snippetsEnabled)
.withParam("visibility_level", visibilityLevel)
.withParam("visibility", visibility)
.withParam("printing_merge_request_link_enabled", printingMergeRequestLinkEnabled)
.withParam("import_url", importUrl);
Response response = post(Response.Status.CREATED, formData, "projects");
return (response.readEntity(Project.class));
}
/** /**
* Creates a Project * Creates a Project
* *
...@@ -741,6 +791,7 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -741,6 +791,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* requestAccessEnabled (optional) - Allow users to request member access * requestAccessEnabled (optional) - Allow users to request member access
* repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins * repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins
* approvalsBeforeMerge (optional) - How many approvers should approve merge request by default * approvalsBeforeMerge (optional) - How many approvers should approve merge request by default
* printingMergeRequestLinkEnabled (optional) - Show link to create/view merge request when pushing from the command line
* *
* NOTE: The following parameters specified by the GitLab API edit project are not supported: * NOTE: The following parameters specified by the GitLab API edit project are not supported:
* import_url * import_url
...@@ -786,7 +837,8 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -786,7 +837,8 @@ public class ProjectApi extends AbstractApi implements Constants {
.withParam("lfs_enabled", project.getLfsEnabled()) .withParam("lfs_enabled", project.getLfsEnabled())
.withParam("request_access_enabled", project.getRequestAccessEnabled()) .withParam("request_access_enabled", project.getRequestAccessEnabled())
.withParam("repository_storage", project.getRepositoryStorage()) .withParam("repository_storage", project.getRepositoryStorage())
.withParam("approvals_before_merge", project.getApprovalsBeforeMerge()); .withParam("approvals_before_merge", project.getApprovalsBeforeMerge())
.withParam("printing_merge_request_link_enabled", project.getPrintingMergeRequestLinkEnabled());
if (isApiVersion(ApiVersion.V3)) { if (isApiVersion(ApiVersion.V3)) {
formData.withParam("visibility_level", project.getVisibilityLevel()); formData.withParam("visibility_level", project.getVisibilityLevel());
......
...@@ -55,6 +55,7 @@ public class Project { ...@@ -55,6 +55,7 @@ public class Project {
private Boolean wallEnabled; private Boolean wallEnabled;
private String webUrl; private String webUrl;
private Boolean wikiEnabled; private Boolean wikiEnabled;
private Boolean printingMergeRequestLinkEnabled;
public Integer getApprovalsBeforeMerge() { public Integer getApprovalsBeforeMerge() {
return approvalsBeforeMerge; return approvalsBeforeMerge;
...@@ -466,6 +467,11 @@ public class Project { ...@@ -466,6 +467,11 @@ public class Project {
this.tagList = tagList; this.tagList = tagList;
} }
public Project withTagList(List<String> tagList) {
this.tagList = tagList;
return (this);
}
public Visibility getVisibility() { public Visibility getVisibility() {
return visibility; return visibility;
} }
...@@ -500,6 +506,11 @@ public class Project { ...@@ -500,6 +506,11 @@ public class Project {
this.wallEnabled = wallEnabled; this.wallEnabled = wallEnabled;
} }
public Project withWallEnabled(Boolean wallEnabled) {
this.wallEnabled = wallEnabled;
return (this);
}
public String getWebUrl() { public String getWebUrl() {
return webUrl; return webUrl;
} }
...@@ -508,6 +519,11 @@ public class Project { ...@@ -508,6 +519,11 @@ public class Project {
this.webUrl = webUrl; this.webUrl = webUrl;
} }
public Project withWebUrl(String webUrl) {
this.webUrl = webUrl;
return (this);
}
public Boolean getWikiEnabled() { public Boolean getWikiEnabled() {
return wikiEnabled; return wikiEnabled;
} }
...@@ -521,6 +537,19 @@ public class Project { ...@@ -521,6 +537,19 @@ public class Project {
return (this); return (this);
} }
public Boolean getPrintingMergeRequestLinkEnabled() {
return printingMergeRequestLinkEnabled;
}
public void setPrintingMergeRequestLinkEnabled(Boolean printingMergeRequestLinkEnabled) {
this.printingMergeRequestLinkEnabled = printingMergeRequestLinkEnabled;
}
public Project withPrintingMergeRequestLinkEnabled(Boolean printingMergeRequestLinkEnabled) {
this.printingMergeRequestLinkEnabled = printingMergeRequestLinkEnabled;
return (this);
}
public static final boolean isValid(Project project) { public static final boolean isValid(Project project) {
return (project != null && project.getId() != null); return (project != null && project.getId() != null);
} }
......
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