From 645d5fb6170442d19c163dc760c1244cf4b6bee3 Mon Sep 17 00:00:00 2001 From: Gautier de Saint Martin Lacaze Date: Wed, 24 Mar 2021 23:41:27 +0100 Subject: [PATCH] feat: Add various fields to project model - readme_url - can_create_merge_request_in - import_status - ci_default_git_depth - remove_source_branch_after_merge - auto_devops_enabled - auto_devops_deploy_strategy - auto_devops_enabled - statistics.packages_size - shared_with_groups.group_full_path fix #613 #632 #667 --- src/main/java/org/gitlab4j/api/Constants.java | 21 +++++ .../org/gitlab4j/api/models/Namespace.java | 18 ++++ .../java/org/gitlab4j/api/models/Project.java | 91 ++++++++++++++++++- .../api/models/ProjectSharedGroup.java | 11 ++- .../api/models/ProjectStatistics.java | 9 ++ .../resources/org/gitlab4j/api/project.json | 53 +++++++---- 6 files changed, 182 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/Constants.java b/src/main/java/org/gitlab4j/api/Constants.java index a86b98895..923e2e1df 100644 --- a/src/main/java/org/gitlab4j/api/Constants.java +++ b/src/main/java/org/gitlab4j/api/Constants.java @@ -848,5 +848,26 @@ public String toString() { return (enumHelper.toString(this)); } } + + enum AutoDevopsDeployStrategy { + CONTINUOUS, MANUAL, TIMED_INCREMENTAL; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(AutoDevopsDeployStrategy.class); + + @JsonCreator + public static AutoDevopsDeployStrategy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } } diff --git a/src/main/java/org/gitlab4j/api/models/Namespace.java b/src/main/java/org/gitlab4j/api/models/Namespace.java index 6afa32653..bb4b20fa5 100644 --- a/src/main/java/org/gitlab4j/api/models/Namespace.java +++ b/src/main/java/org/gitlab4j/api/models/Namespace.java @@ -9,6 +9,8 @@ public class Namespace { private String path; private String kind; private String fullPath; + private String avatarUrl; + private String webUrl; public Integer getId() { return this.id; @@ -75,6 +77,22 @@ public Namespace withFullPath(String fullPath) { return this; } + public String getAvatarUrl() { + return avatarUrl; + } + + public void setAvatarUrl(String avatarUrl) { + this.avatarUrl = avatarUrl; + } + + public String getWebUrl() { + return webUrl; + } + + public void setWebUrl(String webUrl) { + this.webUrl = webUrl; + } + @Override public String toString() { return (JacksonJson.toJsonString(this)); diff --git a/src/main/java/org/gitlab4j/api/models/Project.java b/src/main/java/org/gitlab4j/api/models/Project.java index fc5367b40..b24e107a8 100644 --- a/src/main/java/org/gitlab4j/api/models/Project.java +++ b/src/main/java/org/gitlab4j/api/models/Project.java @@ -4,7 +4,10 @@ import java.util.Date; import java.util.List; +import org.gitlab4j.api.Constants.AutoDevopsDeployStrategy; +import org.gitlab4j.api.Constants.BuildGitStrategy; import org.gitlab4j.api.ProjectLicense; +import org.gitlab4j.api.models.ImportStatus.Status; import org.gitlab4j.api.utils.JacksonJson; import org.gitlab4j.api.utils.JacksonJsonEnumHelper; @@ -12,8 +15,6 @@ import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import org.gitlab4j.api.Constants.BuildGitStrategy; - public class Project { // Enum for the merge_method of the Project instance. @@ -94,6 +95,15 @@ public String toString() { private List customAttributes; private String buildCoverageRegex; private BuildGitStrategy buildGitStrategy; + private String readmeUrl; + private Boolean canCreateMergeRequestIn; + private Status importStatus; + private Integer ciDefaultGitDepth; + private Boolean removeSourceBranchAfterMerge; + private Boolean autoDevopsEnabled; + private AutoDevopsDeployStrategy autoDevopsDeployStrategy; + private Boolean autocloseReferencedIssues; + private Boolean emailsDisabled; @JsonSerialize(using = JacksonJson.DateOnlySerializer.class) private Date markedForDeletionOn; @@ -736,4 +746,81 @@ public Project withBuildGitStrategy(BuildGitStrategy buildGitStrategy) { this.buildGitStrategy = buildGitStrategy; return this; } + + public String getReadmeUrl() { + return readmeUrl; + } + + public void setReadmeUrl(String readmeUrl) { + this.readmeUrl = readmeUrl; + } + + public Boolean getCanCreateMergeRequestIn() { + return canCreateMergeRequestIn; + } + + public void setCanCreateMergeRequestIn(Boolean canCreateMergeRequestIn) { + this.canCreateMergeRequestIn = canCreateMergeRequestIn; + } + + public Status getImportStatus() { + return importStatus; + } + + public void setImportStatus(Status importStatus) { + this.importStatus = importStatus; + } + + public Integer getCiDefaultGitDepth() { + return ciDefaultGitDepth; + } + + public void setCiDefaultGitDepth(Integer ciDefaultGitDepth) { + this.ciDefaultGitDepth = ciDefaultGitDepth; + } + + public Boolean getRemoveSourceBranchAfterMerge() { + return removeSourceBranchAfterMerge; + } + + public void setRemoveSourceBranchAfterMerge(Boolean removeSourceBranchAfterMerge) { + this.removeSourceBranchAfterMerge = removeSourceBranchAfterMerge; + } + + public Boolean getAutoDevopsEnabled() { + return autoDevopsEnabled; + } + + public void setAutoDevopsEnabled(Boolean autoDevopsEnabled) { + this.autoDevopsEnabled = autoDevopsEnabled; + } + + public AutoDevopsDeployStrategy getAutoDevopsDeployStrategy() { + return autoDevopsDeployStrategy; + } + + public void setAutoDevopsDeployStrategy(AutoDevopsDeployStrategy autoDevopsDeployStrategy) { + this.autoDevopsDeployStrategy = autoDevopsDeployStrategy; + } + + public Boolean getAutocloseReferencedIssues() { + return autocloseReferencedIssues; + } + + public void setAutocloseReferencedIssues(Boolean autocloseReferencedIssues) { + this.autocloseReferencedIssues = autocloseReferencedIssues; + } + + public Boolean getEmailsDisabled() { + return emailsDisabled; + } + + public void setEmailsDisabled(Boolean emailsDisabled) { + this.emailsDisabled = emailsDisabled; + } + + public Project withEmailsDisabled(Boolean emailsDisabled) { + this.emailsDisabled = emailsDisabled; + return this; + } } diff --git a/src/main/java/org/gitlab4j/api/models/ProjectSharedGroup.java b/src/main/java/org/gitlab4j/api/models/ProjectSharedGroup.java index b4d10dd4d..3f015340c 100644 --- a/src/main/java/org/gitlab4j/api/models/ProjectSharedGroup.java +++ b/src/main/java/org/gitlab4j/api/models/ProjectSharedGroup.java @@ -3,9 +3,10 @@ import org.gitlab4j.api.utils.JacksonJson; public class ProjectSharedGroup { - + private Integer groupId; private String groupName; + private String groupFullPath; private AccessLevel groupAccessLevel; public int getGroupId() { @@ -32,6 +33,14 @@ public void setGroupAccessLevel(AccessLevel accessLevel) { this.groupAccessLevel = accessLevel; } + public String getGroupFullPath() { + return groupFullPath; + } + + public void setGroupFullPath(String groupFullPath) { + this.groupFullPath = groupFullPath; + } + @Override public String toString() { return (JacksonJson.toJsonString(this)); diff --git a/src/main/java/org/gitlab4j/api/models/ProjectStatistics.java b/src/main/java/org/gitlab4j/api/models/ProjectStatistics.java index d088c6246..ee29511a3 100644 --- a/src/main/java/org/gitlab4j/api/models/ProjectStatistics.java +++ b/src/main/java/org/gitlab4j/api/models/ProjectStatistics.java @@ -16,6 +16,7 @@ public class ProjectStatistics { long wikiSize; long lfsObjectsSize; long jobArtifactsSize; + long packagesSize; public long getCommitCount() { return commitCount; @@ -65,6 +66,14 @@ public void setJobArtifactsSize(long jobArtifactsSize) { this.jobArtifactsSize = jobArtifactsSize; } + public long getPackagesSize() { + return packagesSize; + } + + public void setPackagesSize(long packagesSize) { + this.packagesSize = packagesSize; + } + @Override public String toString() { return (JacksonJson.toJsonString(this)); diff --git a/src/test/resources/org/gitlab4j/api/project.json b/src/test/resources/org/gitlab4j/api/project.json index 714c3fc12..098590cd3 100644 --- a/src/test/resources/org/gitlab4j/api/project.json +++ b/src/test/resources/org/gitlab4j/api/project.json @@ -2,10 +2,11 @@ "id": 3, "default_branch": "master", "public": false, - "visibility_level": 0, + "visibility": "private", "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", + "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", "tag_list": [ "example", "disapora project" @@ -25,6 +26,8 @@ "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, + "can_create_merge_request_in": true, + "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", @@ -32,8 +35,13 @@ "namespace": { "id": 3, "name": "Diaspora", - "path": "diaspora" + "path": "diaspora", + "kind": "group", + "full_path": "diaspora", + "avatar_url": "http://localhost:3000/uploads/group/avatar/3/foo.jpg", + "web_url": "http://localhost:3000/groups/diaspora" }, + "import_status": "none", "permissions": { "project_access": { "access_level": 10, @@ -44,47 +52,56 @@ "notification_level": 3 } }, - "empty_repo": true, "archived": false, "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png", + "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE", + "license": { + "key": "lgpl-3.0", + "name": "GNU Lesser General Public License v3.0", + "nickname": "GNU LGPLv3", + "html_url": "http://choosealicense.com/licenses/lgpl-3.0/", + "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt" + }, "shared_runners_enabled": true, "forks_count": 0, "star_count": 0, "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b", + "ci_default_git_depth": 50, "public_jobs": true, "shared_with_groups": [ { "group_id": 4, "group_name": "Twitter", + "group_full_path": "twitter", "group_access_level": 30 }, { "group_id": 3, "group_name": "Gitlab Org", + "group_full_path": "gitlab-org", "group_access_level": 10 } ], "repository_storage": "default", "only_allow_merge_if_pipeline_succeeds": false, "only_allow_merge_if_all_discussions_are_resolved": false, + "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", + "auto_devops_enabled": true, + "auto_devops_deploy_strategy": "continuous", + "approvals_before_merge": 0, + "packages_enabled": true, + "autoclose_referenced_issues": true, + "marked_for_deletion_on": "2020-04-03", "statistics": { - "commit_count": 9827, - "storage_size": 169043997645, - "repository_size": 388717608, - "wiki_size": 52428, - "lfs_objects_size": 2118052893, - "job_artifacts_size": 166537174716 - }, - "marked_for_deletion_on": "2016-06-17", - "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE", - "license": { - "key": "lgpl-3.0", - "name": "GNU Lesser General Public License v3.0", - "nickname": "GNU LGPLv3", - "html_url": "http://choosealicense.com/licenses/lgpl-3.0/", - "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt" + "commit_count": 37, + "storage_size": 1038090, + "repository_size": 1038090, + "wiki_size": 0, + "lfs_objects_size": 0, + "job_artifacts_size": 0, + "packages_size": 0 }, "custom_attributes": [] } \ No newline at end of file