Skip to content

Commit d8777af

Browse files
committed
Merge remote-tracking branch 'origin/main' into 6.x
2 parents 1a6b02a + 9f969f8 commit d8777af

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

src/main/java/org/gitlab4j/api/EnvironmentsApi.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,19 @@ public Optional<Environment> getOptionalEnvironment(Object projectIdOrPath, Long
9393
}
9494

9595
/**
96-
* Create a new environment with the given name and external_url.
96+
* Create a new environment with the given name, external_url and tier.
9797
*
9898
* <pre><code>GitLab Endpoint:POST /projects/:id/environments</code></pre>
9999
*
100100
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
101101
* @param name the name of the environment
102102
* @param externalUrl the place to link to for this environment
103+
* @param tier the tier of the environment
103104
* @return the created Environment instance
104105
* @throws GitLabApiException if any exception occurs
105106
*/
106-
public Environment createEnvironment(Object projectIdOrPath, String name, String externalUrl) throws GitLabApiException {
107-
GitLabApiForm formData = new GitLabApiForm().withParam("name", name, true).withParam("external_url", externalUrl);
107+
public Environment createEnvironment(Object projectIdOrPath, String name, String externalUrl, String tier) throws GitLabApiException {
108+
GitLabApiForm formData = new GitLabApiForm().withParam("name", name, true).withParam("external_url", externalUrl).withParam("tier", tier);
108109
Response response = post(Response.Status.CREATED, formData,
109110
"projects", getProjectIdOrPath(projectIdOrPath), "environments");
110111
return (response.readEntity(Environment.class));
@@ -119,11 +120,12 @@ public Environment createEnvironment(Object projectIdOrPath, String name, String
119120
* @param environmentId the ID of the environment to update
120121
* @param name the name of the environment
121122
* @param externalUrl the place to link to for this environment
123+
* @param tier the tier of the environment
122124
* @return the created Environment instance
123125
* @throws GitLabApiException if any exception occurs
124126
*/
125-
public Environment updateEnvironment(Object projectIdOrPath, Long environmentId, String name, String externalUrl) throws GitLabApiException {
126-
GitLabApiForm formData = new GitLabApiForm().withParam("name", name).withParam("external_url", externalUrl);
127+
public Environment updateEnvironment(Object projectIdOrPath, Long environmentId, String name, String externalUrl, String tier) throws GitLabApiException {
128+
GitLabApiForm formData = new GitLabApiForm().withParam("name", name).withParam("external_url", externalUrl).withParam("tier", tier);
127129
Response response = putWithFormData(Response.Status.OK, formData, formData,
128130
"projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId);
129131
return (response.readEntity(Environment.class));
@@ -175,4 +177,4 @@ public Environment createEnvironment(Object projectIdOrPath, Long environmentId)
175177
"projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId, "stop");
176178
return (response.readEntity(Environment.class));
177179
}
178-
}
180+
}

src/main/java/org/gitlab4j/api/models/Environment.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public String toString() {
3535
private String name;
3636
private String slug;
3737
private String externalUrl;
38+
private String tier;
3839
private EnvironmentState state;
3940
private Deployment lastDeployment;
4041

@@ -70,6 +71,14 @@ public void setExternalUrl(String externalUrl) {
7071
this.externalUrl = externalUrl;
7172
}
7273

74+
public String getTier() {
75+
return tier;
76+
}
77+
78+
public void setTier(String tier) {
79+
this.tier = tier;
80+
}
81+
7382
public EnvironmentState getState() {
7483
return state;
7584
}

src/test/java/org/gitlab4j/api/TestEnvironmentsApi.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest {
3838

3939
private static final String ENVIRONMENT_NAME = "gitlab4j-testing";
4040
private static final String EXTERNAL_URL = "https:/testing.example.com/";
41+
private static final String TIER = "testing";
4142
private static Random randomNumberGenerator = new Random();
4243

4344
public TestEnvironmentsApi() {
@@ -94,7 +95,7 @@ private static String getUniqueName() {
9495
public void testGetEnvironments() throws GitLabApiException {
9596

9697
final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment(
97-
testProject, getUniqueName(), EXTERNAL_URL);
98+
testProject, getUniqueName(), EXTERNAL_URL, TIER);
9899

99100
List<Environment> envs = gitLabApi.getEnvironmentsApi().getEnvironments(testProject);
100101
assertTrue(envs.size() > 0);
@@ -108,7 +109,7 @@ public void testGetEnvironments() throws GitLabApiException {
108109
public void testStopAndDeleteEnvironment() throws GitLabApiException {
109110

110111
final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment(
111-
testProject, getUniqueName(), EXTERNAL_URL);
112+
testProject, getUniqueName(), EXTERNAL_URL, TIER);
112113

113114
gitLabApi.getEnvironmentsApi().stopEnvironment(testProject, env.getId());
114115
gitLabApi.getEnvironmentsApi().deleteEnvironment(testProject, env.getId());
@@ -122,7 +123,7 @@ public void testStopAndDeleteEnvironment() throws GitLabApiException {
122123
public void testOptionalEnvironment() throws GitLabApiException {
123124

124125
final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment(
125-
testProject, getUniqueName(), EXTERNAL_URL);
126+
testProject, getUniqueName(), EXTERNAL_URL, TIER);
126127
Optional<Environment> optionalEnv =
127128
gitLabApi.getEnvironmentsApi().getOptionalEnvironment(testProject, env.getId());
128129
assertTrue(optionalEnv.isPresent());

src/test/resources/org/gitlab4j/api/environment.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"slug": "review-fix-foo-dfjre3",
55
"external_url": "https://review-fix-foo-dfjre3.example.gitlab.com",
66
"state": "available",
7+
"tier": "testing",
78
"last_deployment": {
89
"id": 100,
910
"iid": 34,
@@ -78,4 +79,4 @@
7879
]
7980
}
8081
}
81-
}
82+
}

0 commit comments

Comments
 (0)