@@ -196,6 +196,7 @@ public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
196
196
* <p>NOTE: This method is only available to GitLab Starter, Bronze, or higher.</p>
197
197
*
198
198
* <pre><code>GitLab Endpoint: POST /projects/:id/protected_branches</code></pre>
199
+ * @deprecated use {@link #protectBranch(Object, String, Long, Long, Long, Boolean)} instead.
199
200
*
200
201
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
201
202
* @param branchName the name of the branch to protect, can be a wildcard
@@ -206,18 +207,42 @@ public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
206
207
* @return the branch info for the protected branch
207
208
* @throws GitLabApiException if any exception occurs
208
209
*/
210
+ @ Deprecated
209
211
public ProtectedBranch protectBranch (Object projectIdOrPath , String branchName ,
210
212
Integer allowedToPushUserId , Integer allowedToMergeUserId , Integer allowedToUnprotectUserId ,
211
213
Boolean codeOwnerApprovalRequired ) throws GitLabApiException {
212
214
return protectBranch (projectIdOrPath , branchName , allowedToPushUserId , allowedToMergeUserId , allowedToUnprotectUserId , codeOwnerApprovalRequired , null );
213
215
}
214
216
217
+ /**
218
+ * Protects a single repository branch or several project repository branches using a wildcard protected branch.
219
+ *
220
+ * <p>NOTE: This method is only available to GitLab Starter, Bronze, or higher.</p>
221
+ *
222
+ * <pre><code>GitLab Endpoint: POST /projects/:id/protected_branches</code></pre>
223
+ *
224
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
225
+ * @param branchName the name of the branch to protect, can be a wildcard
226
+ * @param allowedToPushUserId user ID allowed to push, can be null
227
+ * @param allowedToMergeUserId user ID allowed to merge, can be null
228
+ * @param allowedToUnprotectUserId user ID allowed to unprotect, can be null
229
+ * @param codeOwnerApprovalRequired prevent pushes to this branch if it matches an item in the CODEOWNERS file. (defaults: false)
230
+ * @return the branch info for the protected branch
231
+ * @throws GitLabApiException if any exception occurs
232
+ */
233
+ public ProtectedBranch protectBranch (Object projectIdOrPath , String branchName ,
234
+ Long allowedToPushUserId , Long allowedToMergeUserId , Long allowedToUnprotectUserId ,
235
+ Boolean codeOwnerApprovalRequired ) throws GitLabApiException {
236
+ return protectBranch (projectIdOrPath , branchName , allowedToPushUserId , allowedToMergeUserId , allowedToUnprotectUserId , codeOwnerApprovalRequired , null );
237
+ }
238
+
215
239
/**
216
240
* Protects a single repository branch or several project repository branches using a wildcard protected branch.
217
241
*
218
242
* <p>NOTE: This method is only available to GitLab Starter, Bronze, or higher.</p>
219
243
*
220
244
* <pre><code>GitLab Endpoint: POST /projects/:id/protected_branches</code></pre>
245
+ * @deprecated use {@link #protectBranch(Object, String, Long, Long, Long, Boolean, Boolean)} instead.
221
246
*
222
247
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
223
248
* @param branchName the name of the branch to protect, can be a wildcard
@@ -229,9 +254,40 @@ public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
229
254
* @return the branch info for the protected branch
230
255
* @throws GitLabApiException if any exception occurs
231
256
*/
257
+ @ Deprecated
232
258
public ProtectedBranch protectBranch (Object projectIdOrPath , String branchName ,
233
259
Integer allowedToPushUserId , Integer allowedToMergeUserId , Integer allowedToUnprotectUserId ,
234
260
Boolean codeOwnerApprovalRequired , Boolean allowForcedPush ) throws GitLabApiException {
261
+ return protectBranch (projectIdOrPath , branchName , toLong (allowedToPushUserId ), toLong (allowedToMergeUserId ), toLong (allowedToUnprotectUserId ), codeOwnerApprovalRequired , allowForcedPush );
262
+ }
263
+
264
+ private static Long toLong (Integer value ) {
265
+ if (value == null ) {
266
+ return null ;
267
+ }
268
+ return value .longValue ();
269
+ }
270
+
271
+ /**
272
+ * Protects a single repository branch or several project repository branches using a wildcard protected branch.
273
+ *
274
+ * <p>NOTE: This method is only available to GitLab Starter, Bronze, or higher.</p>
275
+ *
276
+ * <pre><code>GitLab Endpoint: POST /projects/:id/protected_branches</code></pre>
277
+ *
278
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
279
+ * @param branchName the name of the branch to protect, can be a wildcard
280
+ * @param allowedToPushUserId user ID allowed to push, can be null
281
+ * @param allowedToMergeUserId user ID allowed to merge, can be null
282
+ * @param allowedToUnprotectUserId user ID allowed to unprotect, can be null
283
+ * @param codeOwnerApprovalRequired prevent pushes to this branch if it matches an item in the CODEOWNERS file. (defaults: false)
284
+ * @param allowForcedPush when enabled, members who can push to this branch can also force push. (default: false)
285
+ * @return the branch info for the protected branch
286
+ * @throws GitLabApiException if any exception occurs
287
+ */
288
+ public ProtectedBranch protectBranch (Object projectIdOrPath , String branchName ,
289
+ Long allowedToPushUserId , Long allowedToMergeUserId , Long allowedToUnprotectUserId ,
290
+ Boolean codeOwnerApprovalRequired , Boolean allowForcedPush ) throws GitLabApiException {
235
291
236
292
Form formData = new GitLabApiForm ()
237
293
.withParam ("name" , branchName , true )
0 commit comments