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 { ...@@ -746,6 +746,50 @@ public class GitlabAPI {
return retrieve().to(tailUrl, byte[].class); 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 * Creates a private Project
* *
...@@ -891,7 +935,7 @@ public class GitlabAPI { ...@@ -891,7 +935,7 @@ public class GitlabAPI {
* @param mergeRequestsEnabled Whether Merge Requests 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 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 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 * @return the Gitlab Project
* @throws IOException on gitlab api call error * @throws IOException on gitlab api call error
*/ */
......
...@@ -21,38 +21,38 @@ public class GitlabProject { ...@@ -21,38 +21,38 @@ public class GitlabProject {
private String defaultBranch; private String defaultBranch;
private GitlabUser owner; private GitlabUser owner;
private boolean publicProject; private Boolean publicProject;
private String path; private String path;
@JsonProperty("visibility_level") @JsonProperty("visibility")
private Integer visibilityLevel; private String visibility;
@JsonProperty("path_with_namespace") @JsonProperty("path_with_namespace")
private String pathWithNamespace; private String pathWithNamespace;
@JsonProperty("issues_enabled") @JsonProperty("issues_enabled")
private boolean issuesEnabled; private Boolean issuesEnabled;
@JsonProperty("merge_requests_enabled") @JsonProperty("merge_requests_enabled")
private boolean mergeRequestsEnabled; private Boolean mergeRequestsEnabled;
@JsonProperty("snippets_enabled") @JsonProperty("snippets_enabled")
private boolean snippetsEnabled; private Boolean snippetsEnabled;
@JsonProperty("wall_enabled") @JsonProperty("wall_enabled")
private boolean wallEnabled; private boolean wallEnabled;
@JsonProperty("wiki_enabled") @JsonProperty("wiki_enabled")
private boolean wikiEnabled; private Boolean wikiEnabled;
@JsonProperty("jobs_enabled") @JsonProperty("jobs_enabled")
private boolean jobsEnabled; private Boolean jobsEnabled;
@JsonProperty("shared_runners_enabled") @JsonProperty("shared_runners_enabled")
private boolean sharedRunnersEnabled; private Boolean sharedRunnersEnabled;
@JsonProperty("public_jobs") @JsonProperty("public_jobs")
private boolean publicJobs; private Boolean publicJobs;
@JsonProperty("runners_token") @JsonProperty("runners_token")
private String runnersToken; private String runnersToken;
...@@ -98,6 +98,30 @@ public class GitlabProject { ...@@ -98,6 +98,30 @@ public class GitlabProject {
@JsonProperty("shared_with_groups") @JsonProperty("shared_with_groups")
private List<GitlabProjectSharedGroup> sharedWithGroups; 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() { public Integer getId() {
return id; return id;
} }
...@@ -138,12 +162,12 @@ public class GitlabProject { ...@@ -138,12 +162,12 @@ public class GitlabProject {
this.defaultBranch = defaultBranch; this.defaultBranch = defaultBranch;
} }
public Integer getVisibilityLevel() { public String getVisibility() {
return visibilityLevel; return visibility;
} }
public void setVisibilityLevel(Integer visibilityLevel) { public void setVisibility(String visibility) {
this.visibilityLevel = visibilityLevel; this.visibility = visibility;
} }
public GitlabUser getOwner() { public GitlabUser getOwner() {
...@@ -218,14 +242,54 @@ public class GitlabProject { ...@@ -218,14 +242,54 @@ public class GitlabProject {
this.jobsEnabled = jobsEnabled; 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; return sharedRunnersEnabled;
} }
public void setSharedRunnersEnabled(boolean sharedRunnersEnabled) { public void setSharedRunnersEnabled(Boolean sharedRunnersEnabled) {
this.sharedRunnersEnabled = 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() { public boolean hasPublicJobs() {
return publicJobs; return publicJobs;
} }
...@@ -361,4 +425,28 @@ public class GitlabProject { ...@@ -361,4 +425,28 @@ public class GitlabProject {
public void setSharedWithGroups(List<GitlabProjectSharedGroup> sharedWithGroups) { public void setSharedWithGroups(List<GitlabProjectSharedGroup> sharedWithGroups) {
this.sharedWithGroups = 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