@@ -102,9 +102,27 @@ public Optional<Environment> getOptionalEnvironment(Object projectIdOrPath, Long
102102 * @param externalUrl the place to link to for this environment
103103 * @return the created Environment instance
104104 * @throws GitLabApiException if any exception occurs
105+ * @deprecated use {@link #createEnvironment(Object, String, String, String)} instead
105106 */
107+ @ Deprecated
106108 public Environment createEnvironment (Object projectIdOrPath , String name , String externalUrl ) throws GitLabApiException {
107- GitLabApiForm formData = new GitLabApiForm ().withParam ("name" , name , true ).withParam ("external_url" , externalUrl );
109+ return createEnvironment (projectIdOrPath , name , externalUrl , null );
110+ }
111+
112+ /**
113+ * Create a new environment with the given name, external_url and tier.
114+ *
115+ * <pre><code>GitLab Endpoint:POST /projects/:id/environments</code></pre>
116+ *
117+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
118+ * @param name the name of the environment
119+ * @param externalUrl the place to link to for this environment
120+ * @param tier the tier of the environment
121+ * @return the created Environment instance
122+ * @throws GitLabApiException if any exception occurs
123+ */
124+ public Environment createEnvironment (Object projectIdOrPath , String name , String externalUrl , String tier ) throws GitLabApiException {
125+ GitLabApiForm formData = new GitLabApiForm ().withParam ("name" , name , true ).withParam ("external_url" , externalUrl ).withParam ("tier" , tier );
108126 Response response = post (Response .Status .CREATED , formData ,
109127 "projects" , getProjectIdOrPath (projectIdOrPath ), "environments" );
110128 return (response .readEntity (Environment .class ));
@@ -121,9 +139,28 @@ public Environment createEnvironment(Object projectIdOrPath, String name, String
121139 * @param externalUrl the place to link to for this environment
122140 * @return the created Environment instance
123141 * @throws GitLabApiException if any exception occurs
142+ * @deprecated use {@link #updateEnvironment(Object, Long, String, String, String)} instead
124143 */
144+ @ Deprecated
125145 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 );
146+ return updateEnvironment (projectIdOrPath , environmentId , name , externalUrl , null );
147+ }
148+
149+ /**
150+ * Update an existing environment.
151+ *
152+ * <pre><code>GitLab Endpoint:POST /projects/:id/environments</code></pre>
153+ *
154+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
155+ * @param environmentId the ID of the environment to update
156+ * @param name the name of the environment
157+ * @param externalUrl the place to link to for this environment
158+ * @param tier the tier of the environment
159+ * @return the created Environment instance
160+ * @throws GitLabApiException if any exception occurs
161+ */
162+ public Environment updateEnvironment (Object projectIdOrPath , Long environmentId , String name , String externalUrl , String tier ) throws GitLabApiException {
163+ GitLabApiForm formData = new GitLabApiForm ().withParam ("name" , name ).withParam ("external_url" , externalUrl ).withParam ("tier" , tier );
127164 Response response = putWithFormData (Response .Status .OK , formData , formData ,
128165 "projects" , getProjectIdOrPath (projectIdOrPath ), "environments" , environmentId );
129166 return (response .readEntity (Environment .class ));
@@ -175,4 +212,4 @@ public Environment createEnvironment(Object projectIdOrPath, Long environmentId)
175212 "projects" , getProjectIdOrPath (projectIdOrPath ), "environments" , environmentId , "stop" );
176213 return (response .readEntity (Environment .class ));
177214 }
178- }
215+ }
0 commit comments