Commit 8c8c1bb9 authored by David "novalis" Turner's avatar David "novalis" Turner Committed by Tim Olshansky

Add a createProject method that takes all the options (#213)

* Add a createProject method that takes all the options

This is intended to allow https://gitlab.com/gitlab-org/gitlab-ce/issues/32935 to be worked around, but maybe it will be more generally useful too.

* Replace the bogus "visibilityLevel" value with the correct "visibilty" field
parent 5996edbe
......@@ -746,6 +746,50 @@ public class GitlabAPI {
return retrieve().to(tailUrl, byte[].class);
}
/**
* Creates a Project
*
* @param project The project to create
* @return The GitLab Project
* @throws IOException on gitlab api call error
*/
public GitlabProject createProject(GitlabProject project) throws IOException {
Query query = new Query()
.appendIf("name", project.getName())
.appendIf("path", project.getPath())
.appendIf("default_branch", project.getDefaultBranch())
.appendIf("description", project.getDescription())
.appendIf("issues_enabled", project.isIssuesEnabled())
.appendIf("merge_requests_enabled", project.isMergeRequestsEnabled())
.appendIf("jobs_enabled", project.isJobsEnabled())
.appendIf("wiki_enabled", project.isWikiEnabled())
.appendIf("snippets_enabled", project.isSnippetsEnabled())
.appendIf("container_registry_enabled", project.isContainerRegistryEnabled())
.appendIf("shared_runners_enabled", project.isSharedRunnersEnabled())
.appendIf("visibility", project.getVisibility())
.appendIf("public_jobs", project.hasPublicJobs())
.appendIf("import_url", project.getImportUrl())
.appendIf("only_allow_merge_if_pipeline_succeeds", project.getOnlyAllowMergeIfPipelineSucceeds())
.appendIf("only_allow_merge_if_all_discussions_are_resolved", project.getOnlyAllowMergeIfAllDiscussionsAreResolved())
.appendIf("lfs_enabled", project.isLfsEnabled())
.appendIf("request_enabled", project.isRequestAccessEnabled())
.appendIf("repository_storage", project.getRepositoryStorage())
.appendIf("approvals_before_merge", project.getApprovalsBeforeMerge());
GitlabNamespace namespace = project.getNamespace();
if (namespace != null) {
query.appendIf("namespace_id", namespace.getId());
}
String tailUrl = GitlabProject.URL + query.toString();
return dispatch().to(tailUrl, GitlabProject.class);
}
/**
* Creates a private Project
*
......@@ -891,7 +935,7 @@ public class GitlabAPI {
* @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 visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
* @param visibility The visibility level of the project, otherwise null indicates to use GitLab default
* @return the Gitlab Project
* @throws IOException on gitlab api call error
*/
......
......@@ -21,38 +21,38 @@ public class GitlabProject {
private String defaultBranch;
private GitlabUser owner;
private boolean publicProject;
private Boolean publicProject;
private String path;
@JsonProperty("visibility_level")
private Integer visibilityLevel;
@JsonProperty("visibility")
private String visibility;
@JsonProperty("path_with_namespace")
private String pathWithNamespace;
@JsonProperty("issues_enabled")
private boolean issuesEnabled;
private Boolean issuesEnabled;
@JsonProperty("merge_requests_enabled")
private boolean mergeRequestsEnabled;
private Boolean mergeRequestsEnabled;
@JsonProperty("snippets_enabled")
private boolean snippetsEnabled;
private Boolean snippetsEnabled;
@JsonProperty("wall_enabled")
private boolean wallEnabled;
@JsonProperty("wiki_enabled")
private boolean wikiEnabled;
private Boolean wikiEnabled;
@JsonProperty("jobs_enabled")
private boolean jobsEnabled;
private Boolean jobsEnabled;
@JsonProperty("shared_runners_enabled")
private boolean sharedRunnersEnabled;
private Boolean sharedRunnersEnabled;
@JsonProperty("public_jobs")
private boolean publicJobs;
private Boolean publicJobs;
@JsonProperty("runners_token")
private String runnersToken;
......@@ -98,6 +98,30 @@ public class GitlabProject {
@JsonProperty("shared_with_groups")
private List<GitlabProjectSharedGroup> sharedWithGroups;
@JsonProperty("container_registry_enabled")
private boolean containerRegistryEnabled;
@JsonProperty("only_allow_merge_if_pipeline_succeeds")
private Boolean onlyAllowMergeIfPipelineSucceeds;
@JsonProperty("only_allow_merge_if_all_discussions_are_resolved")
private Boolean onlyAllowMergeIfAllDiscussionsAreResolved;
@JsonProperty("lfs_enabled")
private Boolean lfsEnabled;
@JsonProperty("request_access_enabled")
private Boolean requestAccessEnabled;
@JsonProperty("repository_storage")
private String repositoryStorage;
@JsonProperty("approvals_before_merge")
private Integer approvalsBeforeMerge;
@JsonProperty("import_url")
private String importUrl;
public Integer getId() {
return id;
}
......@@ -138,12 +162,12 @@ public class GitlabProject {
this.defaultBranch = defaultBranch;
}
public Integer getVisibilityLevel() {
return visibilityLevel;
public String getVisibility() {
return visibility;
}
public void setVisibilityLevel(Integer visibilityLevel) {
this.visibilityLevel = visibilityLevel;
public void setVisibility(String visibility) {
this.visibility = visibility;
}
public GitlabUser getOwner() {
......@@ -218,14 +242,54 @@ public class GitlabProject {
this.jobsEnabled = jobsEnabled;
}
public boolean isSharedRunnersEnabled() {
public Boolean isRequestAccessEnabled() {
return requestAccessEnabled;
}
public void setRequestAccessEnabled(Boolean requestAccessEnabled) {
this.requestAccessEnabled = requestAccessEnabled;
}
public Boolean isLfsEnabled() {
return lfsEnabled;
}
public void setLfsEnabled(Boolean lfsEnabled) {
this.lfsEnabled = lfsEnabled;
}
public Boolean isSharedRunnersEnabled() {
return sharedRunnersEnabled;
}
public void setSharedRunnersEnabled(boolean sharedRunnersEnabled) {
public void setSharedRunnersEnabled(Boolean sharedRunnersEnabled) {
this.sharedRunnersEnabled = sharedRunnersEnabled;
}
public boolean getOnlyAllowMergeIfPipelineSucceeds() {
return onlyAllowMergeIfPipelineSucceeds;
}
public void setOnlyAllowMergeIfPipelineSucceeds(boolean onlyAllowMergeIfPipelineSucceeds) {
this.onlyAllowMergeIfPipelineSucceeds = onlyAllowMergeIfPipelineSucceeds;
}
public boolean getOnlyAllowMergeIfAllDiscussionsAreResolved() {
return onlyAllowMergeIfAllDiscussionsAreResolved;
}
public void setOnlyAllowMergeIfAllDiscussionsAreResolved(boolean onlyAllowMergeIfAllDiscussionsAreResolved) {
this.onlyAllowMergeIfAllDiscussionsAreResolved = onlyAllowMergeIfAllDiscussionsAreResolved;
}
public boolean isContainerRegistryEnabled() {
return containerRegistryEnabled;
}
public void setContainerRegistryEnabled(boolean containerRegistryEnabled) {
this.containerRegistryEnabled = containerRegistryEnabled;
}
public boolean hasPublicJobs() {
return publicJobs;
}
......@@ -361,4 +425,28 @@ public class GitlabProject {
public void setSharedWithGroups(List<GitlabProjectSharedGroup> sharedWithGroups) {
this.sharedWithGroups = sharedWithGroups;
}
public String getRepositoryStorage() {
return repositoryStorage;
}
public void setRepositoryStorage(String repositoryStorage) {
this.repositoryStorage = repositoryStorage;
}
public Integer getApprovalsBeforeMerge() {
return approvalsBeforeMerge;
}
public void setApprovalsBeforeMerge(Integer approvalsBeforeMerge) {
this.approvalsBeforeMerge = approvalsBeforeMerge;
}
public String getImportUrl() {
return importUrl;
}
public void setImportUrl(String importUrl) {
this.importUrl = importUrl;
}
}
Markdown is supported
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