Skip to content

Commit

Permalink
feat: Add various fields to project model
Browse files Browse the repository at this point in the history
- 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 gitlab4j#613 gitlab4j#632 gitlab4j#667
  • Loading branch information
jabby committed Mar 24, 2021
1 parent 4006654 commit 645d5fb
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 21 deletions.
21 changes: 21 additions & 0 deletions src/main/java/org/gitlab4j/api/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -848,5 +848,26 @@ public String toString() {
return (enumHelper.toString(this));
}
}

enum AutoDevopsDeployStrategy {
CONTINUOUS, MANUAL, TIMED_INCREMENTAL;

private static JacksonJsonEnumHelper<AutoDevopsDeployStrategy> 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));
}
}
}

18 changes: 18 additions & 0 deletions src/main/java/org/gitlab4j/api/models/Namespace.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
91 changes: 89 additions & 2 deletions src/main/java/org/gitlab4j/api/models/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
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;

import com.fasterxml.jackson.annotation.JsonCreator;
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.
Expand Down Expand Up @@ -94,6 +95,15 @@ public String toString() {
private List<CustomAttribute> 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;
Expand Down Expand Up @@ -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;
}
}
11 changes: 10 additions & 1 deletion src/main/java/org/gitlab4j/api/models/ProjectSharedGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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));
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/gitlab4j/api/models/ProjectStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ProjectStatistics {
long wikiSize;
long lfsObjectsSize;
long jobArtifactsSize;
long packagesSize;

public long getCommitCount() {
return commitCount;
Expand Down Expand Up @@ -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));
Expand Down
53 changes: 35 additions & 18 deletions src/test/resources/org/gitlab4j/api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"id": 3,
"default_branch": "master",
"public": false,
"visibility_level": 0,
"visibility": "private",
"ssh_url_to_repo": "[email protected]: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"
Expand All @@ -25,15 +26,22 @@
"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",
"creator_id": 3,
"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,
Expand All @@ -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": []
}

0 comments on commit 645d5fb

Please sign in to comment.