Commit d8777afb authored by Jeremie Bresson's avatar Jeremie Bresson
Browse files

Merge remote-tracking branch 'origin/main' into 6.x

parents 1a6b02a3 9f969f88
...@@ -93,18 +93,19 @@ public class EnvironmentsApi extends AbstractApi { ...@@ -93,18 +93,19 @@ public class EnvironmentsApi extends AbstractApi {
} }
/** /**
* Create a new environment with the given name and external_url. * Create a new environment with the given name, external_url and tier.
* *
* <pre><code>GitLab Endpoint:POST /projects/:id/environments</code></pre> * <pre><code>GitLab Endpoint:POST /projects/:id/environments</code></pre>
* *
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param name the name of the environment * @param name the name of the environment
* @param externalUrl the place to link to for this environment * @param externalUrl the place to link to for this environment
* @param tier the tier of the environment
* @return the created Environment instance * @return the created Environment instance
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public Environment createEnvironment(Object projectIdOrPath, String name, String externalUrl) throws GitLabApiException { public Environment createEnvironment(Object projectIdOrPath, String name, String externalUrl, String tier) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm().withParam("name", name, true).withParam("external_url", externalUrl); GitLabApiForm formData = new GitLabApiForm().withParam("name", name, true).withParam("external_url", externalUrl).withParam("tier", tier);
Response response = post(Response.Status.CREATED, formData, Response response = post(Response.Status.CREATED, formData,
"projects", getProjectIdOrPath(projectIdOrPath), "environments"); "projects", getProjectIdOrPath(projectIdOrPath), "environments");
return (response.readEntity(Environment.class)); return (response.readEntity(Environment.class));
...@@ -119,11 +120,12 @@ public class EnvironmentsApi extends AbstractApi { ...@@ -119,11 +120,12 @@ public class EnvironmentsApi extends AbstractApi {
* @param environmentId the ID of the environment to update * @param environmentId the ID of the environment to update
* @param name the name of the environment * @param name the name of the environment
* @param externalUrl the place to link to for this environment * @param externalUrl the place to link to for this environment
* @param tier the tier of the environment
* @return the created Environment instance * @return the created Environment instance
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public Environment updateEnvironment(Object projectIdOrPath, Long environmentId, String name, String externalUrl) throws GitLabApiException { public Environment updateEnvironment(Object projectIdOrPath, Long environmentId, String name, String externalUrl, String tier) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm().withParam("name", name).withParam("external_url", externalUrl); GitLabApiForm formData = new GitLabApiForm().withParam("name", name).withParam("external_url", externalUrl).withParam("tier", tier);
Response response = putWithFormData(Response.Status.OK, formData, formData, Response response = putWithFormData(Response.Status.OK, formData, formData,
"projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId); "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId);
return (response.readEntity(Environment.class)); return (response.readEntity(Environment.class));
...@@ -175,4 +177,4 @@ public class EnvironmentsApi extends AbstractApi { ...@@ -175,4 +177,4 @@ public class EnvironmentsApi extends AbstractApi {
"projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId, "stop"); "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId, "stop");
return (response.readEntity(Environment.class)); return (response.readEntity(Environment.class));
} }
} }
\ No newline at end of file
...@@ -35,6 +35,7 @@ public class Environment implements Serializable { ...@@ -35,6 +35,7 @@ public class Environment implements Serializable {
private String name; private String name;
private String slug; private String slug;
private String externalUrl; private String externalUrl;
private String tier;
private EnvironmentState state; private EnvironmentState state;
private Deployment lastDeployment; private Deployment lastDeployment;
...@@ -70,6 +71,14 @@ public class Environment implements Serializable { ...@@ -70,6 +71,14 @@ public class Environment implements Serializable {
this.externalUrl = externalUrl; this.externalUrl = externalUrl;
} }
public String getTier() {
return tier;
}
public void setTier(String tier) {
this.tier = tier;
}
public EnvironmentState getState() { public EnvironmentState getState() {
return state; return state;
} }
......
...@@ -38,6 +38,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest { ...@@ -38,6 +38,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest {
private static final String ENVIRONMENT_NAME = "gitlab4j-testing"; private static final String ENVIRONMENT_NAME = "gitlab4j-testing";
private static final String EXTERNAL_URL = "https:/testing.example.com/"; private static final String EXTERNAL_URL = "https:/testing.example.com/";
private static final String TIER = "testing";
private static Random randomNumberGenerator = new Random(); private static Random randomNumberGenerator = new Random();
public TestEnvironmentsApi() { public TestEnvironmentsApi() {
...@@ -94,7 +95,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest { ...@@ -94,7 +95,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest {
public void testGetEnvironments() throws GitLabApiException { public void testGetEnvironments() throws GitLabApiException {
final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment( final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment(
testProject, getUniqueName(), EXTERNAL_URL); testProject, getUniqueName(), EXTERNAL_URL, TIER);
List<Environment> envs = gitLabApi.getEnvironmentsApi().getEnvironments(testProject); List<Environment> envs = gitLabApi.getEnvironmentsApi().getEnvironments(testProject);
assertTrue(envs.size() > 0); assertTrue(envs.size() > 0);
...@@ -108,7 +109,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest { ...@@ -108,7 +109,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest {
public void testStopAndDeleteEnvironment() throws GitLabApiException { public void testStopAndDeleteEnvironment() throws GitLabApiException {
final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment( final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment(
testProject, getUniqueName(), EXTERNAL_URL); testProject, getUniqueName(), EXTERNAL_URL, TIER);
gitLabApi.getEnvironmentsApi().stopEnvironment(testProject, env.getId()); gitLabApi.getEnvironmentsApi().stopEnvironment(testProject, env.getId());
gitLabApi.getEnvironmentsApi().deleteEnvironment(testProject, env.getId()); gitLabApi.getEnvironmentsApi().deleteEnvironment(testProject, env.getId());
...@@ -122,7 +123,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest { ...@@ -122,7 +123,7 @@ public class TestEnvironmentsApi extends AbstractIntegrationTest {
public void testOptionalEnvironment() throws GitLabApiException { public void testOptionalEnvironment() throws GitLabApiException {
final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment( final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment(
testProject, getUniqueName(), EXTERNAL_URL); testProject, getUniqueName(), EXTERNAL_URL, TIER);
Optional<Environment> optionalEnv = Optional<Environment> optionalEnv =
gitLabApi.getEnvironmentsApi().getOptionalEnvironment(testProject, env.getId()); gitLabApi.getEnvironmentsApi().getOptionalEnvironment(testProject, env.getId());
assertTrue(optionalEnv.isPresent()); assertTrue(optionalEnv.isPresent());
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"slug": "review-fix-foo-dfjre3", "slug": "review-fix-foo-dfjre3",
"external_url": "https://review-fix-foo-dfjre3.example.gitlab.com", "external_url": "https://review-fix-foo-dfjre3.example.gitlab.com",
"state": "available", "state": "available",
"tier": "testing",
"last_deployment": { "last_deployment": {
"id": 100, "id": 100,
"iid": 34, "iid": 34,
...@@ -78,4 +79,4 @@ ...@@ -78,4 +79,4 @@
] ]
} }
} }
} }
\ No newline at end of file
Supports Markdown
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