public ProtectedBranch protectBranch(Integer projectIdOrPath, String branchName, AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel) throws GitLabApiException {
        Form formData = new GitLabApiForm()
                .withParam("name", branchName, true)
                .withParam("push_access_level", pushAccessLevel.toValue(), false)
                .withParam("merge_access_level", mergeAccessLevel.toValue(), false);
        Response response = post(Response.Status.CREATED, formData.asMap(),
                "projects", getProjectIdOrPath(projectIdOrPath), "protected_branches");
        return (response.readEntity(ProtectedBranch.class));
    }
public ProtectedBranch protectBranch ( Integer projectIdOrPath , String branchName , AccessLevel pushAccessLevel , AccessLevel mergeAccessLevel ) throws GitLabApiException { Form formData = new GitLabApiForm ( ) . withParam ( "name" , branchName , true ) . withParam ( "push_access_level" , pushAccessLevel . toValue ( ) , false ) . withParam ( "merge_access_level" , mergeAccessLevel . toValue ( ) , false ) ; Response response = post ( Response . Status . CREATED , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "protected_branches" ) ; return ( response . readEntity ( ProtectedBranch . class ) ) ; }
Protects a single repository branch or several project repository branches using a wildcard protected branch.

<pre><code>GitLab Endpoint: POST /projects/:id/protected_branches</code></pre>

@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param branchName the name of the branch to protect
@param pushAccessLevel Access levels allowed to push (defaults: 40, maintainer access level)
@param mergeAccessLevel Access levels allowed to merge (defaults: 40, maintainer access level)
@return the branch info for the protected branch
@throws GitLabApiException if any exception occurs