Skip to content

Commit 7e8795e

Browse files
authored
Added missing attributes for ProjectApi (#1237)
1 parent c9a2fbe commit 7e8795e

File tree

5 files changed

+1109
-50
lines changed

5 files changed

+1109
-50
lines changed

gitlab4j-api/src/main/java/org/gitlab4j/api/ProjectApi.java

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.io.UnsupportedEncodingException;
2929
import java.net.URLEncoder;
3030
import java.util.Date;
31+
import java.util.HashMap;
3132
import java.util.List;
3233
import java.util.Map;
3334
import java.util.Objects;
@@ -1128,7 +1129,60 @@ public Project createProject(Project project, String importUrl) throws GitLabApi
11281129
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
11291130
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge())
11301131
.withParam("auto_devops_enabled", project.getAutoDevopsEnabled())
1131-
.withParam("squash_option", project.getSquashOption());
1132+
.withParam("squash_option", project.getSquashOption())
1133+
.withParam("use_custom_template", project.getUseCustomTemplate())
1134+
.withParam(
1135+
"external_authorization_classification_label",
1136+
project.getExternalAuthorizationClassificationLabel())
1137+
.withParam("group_runners_enabled", project.getGroupRunnersEnabled())
1138+
.withParam("show_default_award_emojis", project.getShowDefaultAwardEmojis())
1139+
.withParam(
1140+
"warn_about_potentially_unwanted_characters",
1141+
project.getWarnAboutPotentiallyUnwantedCharacters())
1142+
.withParam("mirror_trigger_builds", project.getMirrorTriggerBuilds())
1143+
.withParam("auto_cancel_pending_pipelines", project.getAutoCancelPendingPipelines())
1144+
.withParam("repository_object_format", project.getRepositoryObjectFormat())
1145+
.withParam(
1146+
"only_allow_merge_if_all_status_checks_passed",
1147+
project.getOnlyAllowMergeIfAllStatusChecksPassed())
1148+
.withParam("group_with_project_templates_id", project.getGroupWithProjectTemplatesId())
1149+
.withParam("public_builds", project.getPublicBuilds())
1150+
.withParam("build_timeout", project.getBuildTimeout())
1151+
.withParam("template_name", project.getTemplateName())
1152+
.withParam("emails_enabled", project.getEmailsEnabled())
1153+
.withParam("mirror", project.getMirror())
1154+
.withParam("analytics_access_level", project.getAnalyticsAccessLevel())
1155+
.withParam("builds_access_level", project.getBuildsAccessLevel())
1156+
.withParam("container_registry_access_level", project.getContainerRegistryAccessLevel())
1157+
.withParam("environments_access_level", project.getEnvironmentsAccessLevel())
1158+
.withParam("feature_flags_access_level", project.getFeatureFlagsAccessLevel())
1159+
.withParam("forking_access_level", project.getForkingAccessLevel())
1160+
.withParam("infrastructure_access_level", project.getInfrastructureAccessLevel())
1161+
.withParam("issues_access_level", project.getIssuesAccessLevel())
1162+
.withParam("merge_requests_access_level", project.getMergeRequestsAccessLevel())
1163+
.withParam("model_experiments_access_level", project.getModelExperimentsAccessLevel())
1164+
.withParam("model_registry_access_level", project.getModelRegistryAccessLevel())
1165+
.withParam("monitor_access_level", project.getMonitorAccessLevel())
1166+
.withParam("pages_access_level", project.getPagesAccessLevel())
1167+
.withParam("releases_access_level", project.getReleasesAccessLevel())
1168+
.withParam("repository_access_level", project.getRepositoryAccessLevel())
1169+
.withParam("requirements_access_level", project.getRequirementsAccessLevel())
1170+
.withParam("security_and_compliance_access_level", project.getSecurityAndComplianceAccessLevel())
1171+
.withParam("snippets_access_level", project.getSnippetsAccessLevel())
1172+
.withParam("wiki_access_level", project.getWikiAccessLevel());
1173+
1174+
if (project.getContainerExpirationPolicy() != null) {
1175+
Map<String, Object> attributes = new HashMap<>();
1176+
attributes.put("cadence", project.getContainerExpirationPolicy().getCadence());
1177+
attributes.put("enabled", project.getContainerExpirationPolicy().getEnabled());
1178+
attributes.put("keep_n", project.getContainerExpirationPolicy().getKeepN());
1179+
attributes.put("older_than", project.getContainerExpirationPolicy().getOlderThan());
1180+
attributes.put("name_regex", project.getContainerExpirationPolicy().getNameRegex());
1181+
attributes.put(
1182+
"name_regex_keep", project.getContainerExpirationPolicy().getNameRegexKeep());
1183+
1184+
formData.withParam("container_expiration_policy_attributes", attributes, false);
1185+
}
11321186

11331187
Namespace namespace = project.getNamespace();
11341188
if (namespace != null && namespace.getId() != null) {
@@ -1490,7 +1544,60 @@ public Project updateProject(Project project) throws GitLabApiException {
14901544
.withParam("merge_method", project.getMergeMethod())
14911545
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
14921546
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge())
1493-
.withParam("squash_option", project.getSquashOption());
1547+
.withParam("squash_option", project.getSquashOption())
1548+
.withParam("use_custom_template", project.getUseCustomTemplate())
1549+
.withParam(
1550+
"external_authorization_classification_label",
1551+
project.getExternalAuthorizationClassificationLabel())
1552+
.withParam("group_runners_enabled", project.getGroupRunnersEnabled())
1553+
.withParam("show_default_award_emojis", project.getShowDefaultAwardEmojis())
1554+
.withParam(
1555+
"warn_about_potentially_unwanted_characters",
1556+
project.getWarnAboutPotentiallyUnwantedCharacters())
1557+
.withParam("mirror_trigger_builds", project.getMirrorTriggerBuilds())
1558+
.withParam("auto_cancel_pending_pipelines", project.getAutoCancelPendingPipelines())
1559+
.withParam("repository_object_format", project.getRepositoryObjectFormat())
1560+
.withParam(
1561+
"only_allow_merge_if_all_status_checks_passed",
1562+
project.getOnlyAllowMergeIfAllStatusChecksPassed())
1563+
.withParam("group_with_project_templates_id", project.getGroupWithProjectTemplatesId())
1564+
.withParam("public_builds", project.getPublicBuilds())
1565+
.withParam("build_timeout", project.getBuildTimeout())
1566+
.withParam("template_name", project.getTemplateName())
1567+
.withParam("emails_enabled", project.getEmailsEnabled())
1568+
.withParam("mirror", project.getMirror())
1569+
.withParam("analytics_access_level", project.getAnalyticsAccessLevel())
1570+
.withParam("builds_access_level", project.getBuildsAccessLevel())
1571+
.withParam("container_registry_access_level", project.getContainerRegistryAccessLevel())
1572+
.withParam("environments_access_level", project.getEnvironmentsAccessLevel())
1573+
.withParam("feature_flags_access_level", project.getFeatureFlagsAccessLevel())
1574+
.withParam("forking_access_level", project.getForkingAccessLevel())
1575+
.withParam("infrastructure_access_level", project.getInfrastructureAccessLevel())
1576+
.withParam("issues_access_level", project.getIssuesAccessLevel())
1577+
.withParam("merge_requests_access_level", project.getMergeRequestsAccessLevel())
1578+
.withParam("model_experiments_access_level", project.getModelExperimentsAccessLevel())
1579+
.withParam("model_registry_access_level", project.getModelRegistryAccessLevel())
1580+
.withParam("monitor_access_level", project.getMonitorAccessLevel())
1581+
.withParam("pages_access_level", project.getPagesAccessLevel())
1582+
.withParam("releases_access_level", project.getReleasesAccessLevel())
1583+
.withParam("repository_access_level", project.getRepositoryAccessLevel())
1584+
.withParam("requirements_access_level", project.getRequirementsAccessLevel())
1585+
.withParam("security_and_compliance_access_level", project.getSecurityAndComplianceAccessLevel())
1586+
.withParam("snippets_access_level", project.getSnippetsAccessLevel())
1587+
.withParam("wiki_access_level", project.getWikiAccessLevel());
1588+
1589+
if (project.getContainerExpirationPolicy() != null) {
1590+
Map<String, Object> attributes = new HashMap<>();
1591+
attributes.put("cadence", project.getContainerExpirationPolicy().getCadence());
1592+
attributes.put("enabled", project.getContainerExpirationPolicy().getEnabled());
1593+
attributes.put("keep_n", project.getContainerExpirationPolicy().getKeepN());
1594+
attributes.put("older_than", project.getContainerExpirationPolicy().getOlderThan());
1595+
attributes.put("name_regex", project.getContainerExpirationPolicy().getNameRegex());
1596+
attributes.put(
1597+
"name_regex_keep", project.getContainerExpirationPolicy().getNameRegexKeep());
1598+
1599+
formData.withParam("container_expiration_policy_attributes", attributes, false);
1600+
}
14941601

14951602
if (isApiVersion(ApiVersion.V3)) {
14961603
formData.withParam("visibility_level", project.getVisibilityLevel());
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package org.gitlab4j.api.models;
2+
3+
import java.io.Serializable;
4+
5+
import org.gitlab4j.models.utils.JacksonJson;
6+
7+
public class ContainerExpirationPolicy implements Serializable {
8+
private static final long serialVersionUID = 1L;
9+
10+
private String cadence;
11+
private Boolean enabled;
12+
private Integer keepN;
13+
private String olderThan;
14+
private String nameRegex;
15+
private String nameRegexKeep;
16+
17+
private String nextRunAt;
18+
19+
public String getCadence() {
20+
return cadence;
21+
}
22+
23+
public void setCadence(String cadence) {
24+
this.cadence = cadence;
25+
}
26+
27+
public ContainerExpirationPolicy withCadence(String cadence) {
28+
this.cadence = cadence;
29+
return this;
30+
}
31+
32+
public Boolean getEnabled() {
33+
return enabled;
34+
}
35+
36+
public void setEnabled(Boolean enabled) {
37+
this.enabled = enabled;
38+
}
39+
40+
public ContainerExpirationPolicy withEnabled(Boolean enabled) {
41+
this.enabled = enabled;
42+
return this;
43+
}
44+
45+
public Integer getKeepN() {
46+
return keepN;
47+
}
48+
49+
public void setKeepN(Integer keepN) {
50+
this.keepN = keepN;
51+
}
52+
53+
public ContainerExpirationPolicy withKeepN(Integer keepN) {
54+
this.keepN = keepN;
55+
return this;
56+
}
57+
58+
public String getOlderThan() {
59+
return olderThan;
60+
}
61+
62+
public void setOlderThan(String olderThan) {
63+
this.olderThan = olderThan;
64+
}
65+
66+
public ContainerExpirationPolicy withOlderThan(String olderThan) {
67+
this.olderThan = olderThan;
68+
return this;
69+
}
70+
71+
public String getNameRegex() {
72+
return nameRegex;
73+
}
74+
75+
public void setNameRegex(String nameRegex) {
76+
this.nameRegex = nameRegex;
77+
}
78+
79+
public ContainerExpirationPolicy withNameRegex(String nameRegex) {
80+
this.nameRegex = nameRegex;
81+
return this;
82+
}
83+
84+
public String getNameRegexKeep() {
85+
return nameRegexKeep;
86+
}
87+
88+
public void setNameRegexKeep(String nameRegexKeep) {
89+
this.nameRegexKeep = nameRegexKeep;
90+
}
91+
92+
public ContainerExpirationPolicy withNameRegexKeep(String nameRegexKeep) {
93+
this.nameRegexKeep = nameRegexKeep;
94+
return this;
95+
}
96+
97+
public String getNextRunAt() {
98+
return nextRunAt;
99+
}
100+
101+
public void setNextRunAt(String nextRunAt) {
102+
this.nextRunAt = nextRunAt;
103+
}
104+
105+
@Override
106+
public String toString() {
107+
return (JacksonJson.toJsonString(this));
108+
}
109+
}

0 commit comments

Comments
 (0)