Package org.gitlab4j.api
Class ProtectedBranchesApi
java.lang.Object
org.gitlab4j.api.AbstractApi
org.gitlab4j.api.ProtectedBranchesApi
- All Implemented Interfaces:
Constants
This class provides an entry point to all the Protected Branches API calls.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gitlab4j.api.Constants
Constants.ActionType, Constants.ApplicationScope, Constants.ArchiveFormat, Constants.AutoDevopsDeployStrategy, Constants.BuildGitStrategy, Constants.CommitBuildState, Constants.ContributorOrderBy, Constants.DeploymentOrderBy, Constants.DeploymentStatus, Constants.DeployTokenScope, Constants.Encoding, Constants.EpicOrderBy, Constants.EventScope, Constants.GroupOrderBy, Constants.GroupSearchScope, Constants.ImpersonationState, Constants.IssueOrderBy, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestSearchIn, Constants.MergeRequestState, Constants.MilestoneState, Constants.PackageOrderBy, Constants.PackageStatus, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.ProjectSearchScope, Constants.SearchScope, Constants.SortOrder, Constants.SquashOption, Constants.StateEvent, Constants.TagOrderBy, Constants.TargetType, Constants.TodoAction, Constants.TodoState, Constants.TodoType, Constants.TokenType
-
Field Summary
Fields inherited from class org.gitlab4j.api.AbstractApi
gitLabApi
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
-
Method Summary
Modifier and TypeMethodDescriptiongetOptionalProtectedBranch
(Object projectIdOrPath, String branchName) Get an Optional instance with the value for the specific protected branch.getProtectedBranch
(Object projectIdOrPath, String branchName) Get a single protected branch or wildcard protected branch.getProtectedBranches
(Object projectIdOrPath) Gets a list of protected branches from a project.getProtectedBranches
(Object projectIdOrPath, int itemsPerPage) Gets a Pager of protected branches from a project.getProtectedBranchesStream
(Object projectIdOrPath) Gets a Stream of protected branches from a project.protectBranch
(Object projectIdOrPath, String branchName) Protects a single repository branch or several project repository branches using a wildcard protected branch.protectBranch
(Object projectIdOrPath, String branchName, Integer allowedToPushUserId, Integer allowedToMergeUserId, Integer allowedToUnprotectUserId, Boolean codeOwnerApprovalRequired) Protects a single repository branch or several project repository branches using a wildcard protected branch.protectBranch
(Object projectIdOrPath, String branchName, AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel) Protects a single repository branch or several project repository branches using a wildcard protected branch.protectBranch
(Object projectIdOrPath, String branchName, AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel, AccessLevel unprotectAccessLevel, Boolean codeOwnerApprovalRequired) Protects a single repository branch or several project repository branches using a wildcard protected branch.protectBranch
(Object projectIdOrPath, String branchName, AllowedTo allowedToPush, AllowedTo allowedToMerge, AllowedTo allowedToUnprotect, Boolean codeOwnerApprovalRequired) Protects a single repository branch or several project repository branches using a wildcard protected branch.setCodeOwnerApprovalRequired
(Object projectIdOrPath, String branchName, Boolean codeOwnerApprovalRequired) Sets the code_owner_approval_required flag on the specified protected branch.void
unprotectBranch
(Object 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, getLabelIdOrName, getPageQueryParams, getPageQueryParams, getPerPageQueryParam, getProjectIdOrPath, getUserIdOrUsername, getWithAccepts, handle, head, isApiVersion, patch, patch, post, post, post, post, post, put, put, put, putUpload, putUpload, putWithFormData, upload, upload, upload, upload, urlEncode, validate
-
Constructor Details
-
ProtectedBranchesApi
-
-
Method Details
-
getProtectedBranches
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 Long(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 Long(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 Long(ID), String(path), or Project instance- Returns:
- the Stream of protected branches for the project
- Throws:
GitLabApiException
- if any exception occurs
-
getProtectedBranch
public ProtectedBranch getProtectedBranch(Object projectIdOrPath, String branchName) throws GitLabApiException Get a single protected branch or wildcard protected branch.GitLab Endpoint: GET /projects/:id/protected_branches/:branch_name
- Parameters:
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch or wildcard- Returns:
- a ProtectedBranch instance with info on the protected branch
- Throws:
GitLabApiException
- if any exception occurs
-
getOptionalProtectedBranch
public Optional<ProtectedBranch> getOptionalProtectedBranch(Object projectIdOrPath, String branchName) Get an Optional instance with the value for the specific protected branch.GitLab Endpoint: GET /projects/:id/protected_branches/:branch_name
- Parameters:
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch or wildcard- Returns:
- an Optional instance with the specified protected branch as a value
-
unprotectBranch
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 Long(ID), String(path), or Project instancebranchName
- the name of the branch to un-protect, can be a wildcard- Throws:
GitLabApiException
- if any exception occurs
-
protectBranch
public ProtectedBranch protectBranch(Object 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 Long(ID), String(path), or Project instancebranchName
- the name of the branch to protect, can be a wildcard- Returns:
- the branch info for the protected branch
- Throws:
GitLabApiException
- if any exception occurs
-
protectBranch
public ProtectedBranch protectBranch(Object 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 Long(ID), String(path), or Project instancebranchName
- the name of the branch to protect, can be a wildcardpushAccessLevel
- 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
-
protectBranch
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName, AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel, AccessLevel unprotectAccessLevel, Boolean codeOwnerApprovalRequired) 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 Long(ID), String(path), or Project instancebranchName
- the name of the branch to protect, can be a wildcardpushAccessLevel
- access levels allowed to push (defaults: 40, maintainer access level)mergeAccessLevel
- access levels allowed to merge (defaults: 40, maintainer access level)unprotectAccessLevel
- access levels allowed to unprotect (defaults: 40, maintainer access level)codeOwnerApprovalRequired
- prevent pushes to this branch if it matches an item in the CODEOWNERS file. (defaults: false)- Returns:
- the branch info for the protected branch
- Throws:
GitLabApiException
- if any exception occurs
-
protectBranch
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName, Integer allowedToPushUserId, Integer allowedToMergeUserId, Integer allowedToUnprotectUserId, Boolean codeOwnerApprovalRequired) throws GitLabApiException Protects a single repository branch or several project repository branches using a wildcard protected branch.NOTE: This method is only available to GitLab Starter, Bronze, or higher.
GitLab Endpoint: POST /projects/:id/protected_branches
- Parameters:
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch to protect, can be a wildcardallowedToPushUserId
- user ID allowed to push, can be nullallowedToMergeUserId
- user ID allowed to merge, can be nullallowedToUnprotectUserId
- user ID allowed to unprotect, can be nullcodeOwnerApprovalRequired
- prevent pushes to this branch if it matches an item in the CODEOWNERS file. (defaults: false)- Returns:
- the branch info for the protected branch
- Throws:
GitLabApiException
- if any exception occurs
-
protectBranch
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName, AllowedTo allowedToPush, AllowedTo allowedToMerge, AllowedTo allowedToUnprotect, Boolean codeOwnerApprovalRequired) throws GitLabApiException Protects a single repository branch or several project repository branches using a wildcard protected branch.NOTE: This method is only available to GitLab Starter, Bronze, or higher.
GitLab Endpoint: POST /projects/:id/protected_branches
- Parameters:
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch to protect, can be a wildcardallowedToPush
- an AllowedTo instance holding the configuration for "allowed_to_push"allowedToMerge
- an AllowedTo instance holding the configuration for "allowed_to_merge"allowedToUnprotect
- an AllowedTo instance holding the configuration for "allowed_to_unprotect" be nullcodeOwnerApprovalRequired
- prevent pushes to this branch if it matches an item in the CODEOWNERS file. (defaults: false)- Returns:
- the branch info for the protected branch
- Throws:
GitLabApiException
- if any exception occurs
-
setCodeOwnerApprovalRequired
public ProtectedBranch setCodeOwnerApprovalRequired(Object projectIdOrPath, String branchName, Boolean codeOwnerApprovalRequired) throws GitLabApiException Sets the code_owner_approval_required flag on the specified protected branch.NOTE: This method is only available in GitLab Premium or higher.
GitLab Endpoint: PATCH /projects/:id/protected_branches/:branch_name?code_owner_approval_required=true
- Parameters:
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch to protect, can be a wildcardcodeOwnerApprovalRequired
- prevent pushes to this branch if it matches an item in the CODEOWNERS file.- Returns:
- the branch info for the protected branch
- Throws:
GitLabApiException
- if any exception occurs
-