Package org.gitlab4j.api
Class ProtectedBranchesApi
- java.lang.Object
-
- org.gitlab4j.api.AbstractApi
-
- org.gitlab4j.api.ProtectedBranchesApi
-
- All Implemented Interfaces:
Constants
public class ProtectedBranchesApi extends AbstractApi
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.gitlab4j.api.Constants
Constants.ActionType, Constants.ApplicationScope, Constants.ArchiveFormat, Constants.CommitBuildState, Constants.Encoding, Constants.EpicOrderBy, Constants.GroupOrderBy, Constants.ImpersonationState, Constants.IssueOrderBy, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestState, Constants.MilestoneState, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.SortOrder, Constants.StateEvent, Constants.TargetType, Constants.TokenType
-
-
Field Summary
-
Fields inherited from interface org.gitlab4j.api.Constants
NEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER
-
-
Constructor Summary
Constructors Constructor Description ProtectedBranchesApi(GitLabApi gitLabApi)
-
Method Summary
Modifier and Type Method Description List<ProtectedBranch>
getProtectedBranches(Object projectIdOrPath)
Gets a list of protected branches from a project.Pager<ProtectedBranch>
getProtectedBranches(Object projectIdOrPath, int itemsPerPage)
Gets a Pager of protected branches from a project.Stream<ProtectedBranch>
getProtectedBranchesStream(Object projectIdOrPath)
Gets a Stream of protected branches from a project.ProtectedBranch
protectBranch(Integer projectIdOrPath, String branchName)
Protects a single repository branch or several project repository branches using a wildcard protected branch.ProtectedBranch
protectBranch(Integer projectIdOrPath, String branchName, AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel)
Protects a single repository branch or several project repository branches using a wildcard protected branch.void
unprotectBranch(Integer projectIdOrPath, String branchName)
Unprotects the given protected branch or wildcard protected branch.-
Methods inherited from class org.gitlab4j.api.AbstractApi
addFormParam, addFormParam, delete, delete, get, get, getApiClient, getApiVersion, getDefaultPerPage, getDefaultPerPageParam, getDefaultPerPageParam, getGroupIdOrPath, getPageQueryParams, getPageQueryParams, getPerPageQueryParam, getProjectIdOrPath, getUserIdOrUsername, getWithAccepts, handle, head, isApiVersion, post, post, post, post, post, put, put, putUpload, putUpload, putWithFormData, upload, upload, upload, urlEncode, validate
-
-
-
-
Constructor Detail
-
ProtectedBranchesApi
public ProtectedBranchesApi(GitLabApi gitLabApi)
-
-
Method Detail
-
getProtectedBranches
public List<ProtectedBranch> getProtectedBranches(Object projectIdOrPath) throws GitLabApiException
Gets a list of protected branches from a project.GitLab Endpoint: GET /projects/:id/protected_branches
- Parameters:
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instance- Returns:
- the list of protected branches for the project
- Throws:
GitLabApiException
- if any exception occurs
-
getProtectedBranches
public Pager<ProtectedBranch> getProtectedBranches(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException
Gets a Pager of protected branches from a project.GitLab Endpoint: GET /projects/:id/protected_branches
- Parameters:
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instanceitemsPerPage
- the number of instances that will be fetched per page- Returns:
- the Pager of protected branches for the project
- Throws:
GitLabApiException
- if any exception occurs
-
getProtectedBranchesStream
public Stream<ProtectedBranch> getProtectedBranchesStream(Object projectIdOrPath) throws GitLabApiException
Gets a Stream of protected branches from a project.GitLab Endpoint: GET /projects/:id/protected_branches
- Parameters:
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instance- Returns:
- the Stream of protected branches for the project
- Throws:
GitLabApiException
- if any exception occurs
-
unprotectBranch
public void unprotectBranch(Integer projectIdOrPath, String branchName) throws GitLabApiException
Unprotects the given protected branch or wildcard protected branch.GitLab Endpoint: DELETE /projects/:id/protected_branches/:name
- Parameters:
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instancebranchName
- the name of the branch to un-protect- Throws:
GitLabApiException
- if any exception occurs
-
protectBranch
public ProtectedBranch protectBranch(Integer projectIdOrPath, String branchName) throws GitLabApiException
Protects a single repository branch or several project repository branches using a wildcard protected branch.GitLab Endpoint: POST /projects/:id/protected_branches
- Parameters:
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instancebranchName
- the name of the branch to protect- Returns:
- the branch info for the protected branch
- Throws:
GitLabApiException
- if any exception occurs
-
protectBranch
public ProtectedBranch protectBranch(Integer projectIdOrPath, String branchName, AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel) throws GitLabApiException
Protects a single repository branch or several project repository branches using a wildcard protected branch.GitLab Endpoint: POST /projects/:id/protected_branches
- Parameters:
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instancebranchName
- the name of the branch to protectpushAccessLevel
- Access levels allowed to push (defaults: 40, maintainer access level)mergeAccessLevel
- Access levels allowed to merge (defaults: 40, maintainer access level)- Returns:
- the branch info for the protected branch
- Throws:
GitLabApiException
- if any exception occurs
-
-