Create a branch restriction rule
Creates a new branch restriction rule for a repository.
kind describes what will be restricted. Allowed values include:
push, force, delete, restrict_merges, require_tasks_to_be_completed,
require_approvals_to_merge, require_default_reviewer_approvals_to_merge,
require_no_changes_requested, require_passing_builds_to_merge, require_commits_behind,
reset_pullrequest_approvals_on_change, smart_reset_pullrequest_approvals,
reset_pullrequest_changes_requested_on_change, require_all_dependencies_merged,
enforce_merge_checks, and allow_auto_merge_when_builds_pass.
Different kinds of branch restrictions have different requirements:
pushandrestrict_mergesrequireusersandgroupsto be specified. Empty lists are allowed, in which case permission is denied for everybody.
The restriction applies to all branches that match. There are
two ways to match a branch. It is configured in branch_match_kind:
glob: Matches a branch against thepattern. A'*'inpatternwill expand to match zero or more characters, and every other character matches itself. For example,'foo*'will match'foo'and'foobar', but not'barfoo'.'*'will match all branches.branching_model: Matches a branch against the repository’s branching model. Thebranch_typecontrols the type of branch to match. Allowed values include:production,development,bugfix,release,featureandhotfix.
The combination of kind and match must be unique. This means that
two glob restrictions in a repository cannot have the same kind and
pattern. Additionally, two branching_model restrictions in a
repository cannot have the same kind and branch_type.
users and groups are lists of users and groups that are except from
the restriction. They can only be configured in push and
restrict_merges restrictions. The push restriction stops a user
pushing to matching branches unless that user is in users or is a
member of a group in groups. The restrict_merges stops a user
merging pull requests to matching branches unless that user is in
users or is a member of a group in groups. Adding new users or
groups to an existing restriction should be done via PUT.
Note that branch restrictions with overlapping matchers is allowed, but the resulting behavior may be surprising.
Authorizations
Section titled “ Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”This can either be the repository slug or the UUID of the repository,
surrounded by curly-braces, for example: {repository UUID}.
This can either be the workspace ID (slug) or the workspace UUID
surrounded by curly-braces, for example: {workspace UUID}.
Request Body required
Section titled “ Request Body required ”The new rule
object
object
A link to a resource related to this object.
object
The branch restriction status’ id.
The type of restriction that is being applied.
Indicates how the restriction is matched against a branch. The default is glob.
Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository.
Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
Value with kind-specific semantics:
-
require_approvals_to_mergeuses it to require a minimum number of approvals on a PR. -
require_default_reviewer_approvals_to_mergeuses it to require a minimum number of approvals from default reviewers on a PR. -
require_passing_builds_to_mergeuses it to require a minimum number of passing builds. -
require_commits_behinduses it to require the current branch is up to a maximum number of commits behind it destination.
object
Links related to an Account.
object
A link to a resource related to this object.
object
object
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
object
Links related to an Account.
object
A link to a resource related to this object.
object
object
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
The workspace’s immutable id.
The name of the workspace.
The short label that identifies this workspace.
Indicates whether the workspace is publicly accessible, or whether it is private to the members and consequently only visible to members.
Indicates whether the workspace enforces private content, or whether it allows public content.
Controls the rules for forking repositories within this workspace.
- allow_forks: unrestricted forking
- internal_only: prevents forking of private repositories outside the workspace or to public repositories
The “sluggified” version of the group’s name. This contains only ASCII characters and can therefore be slightly different than the name
The concatenation of the workspace’s slug and the group’s slug,
separated with a colon (e.g. acme:developers)
Responses
Section titled “ Responses ”A paginated list of branch restrictions
object
object
A link to a resource related to this object.
object
The branch restriction status’ id.
The type of restriction that is being applied.
Indicates how the restriction is matched against a branch. The default is glob.
Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository.
Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
Value with kind-specific semantics:
-
require_approvals_to_mergeuses it to require a minimum number of approvals on a PR. -
require_default_reviewer_approvals_to_mergeuses it to require a minimum number of approvals from default reviewers on a PR. -
require_passing_builds_to_mergeuses it to require a minimum number of passing builds. -
require_commits_behinduses it to require the current branch is up to a maximum number of commits behind it destination.
object
Links related to an Account.
object
A link to a resource related to this object.
object
object
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
object
Links related to an Account.
object
A link to a resource related to this object.
object
object
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
A link to a resource related to this object.
object
The workspace’s immutable id.
The name of the workspace.
The short label that identifies this workspace.
Indicates whether the workspace is publicly accessible, or whether it is private to the members and consequently only visible to members.
Indicates whether the workspace enforces private content, or whether it allows public content.
Controls the rules for forking repositories within this workspace.
- allow_forks: unrestricted forking
- internal_only: prevents forking of private repositories outside the workspace or to public repositories
The “sluggified” version of the group’s name. This contains only ASCII characters and can therefore be slightly different than the name
The concatenation of the workspace’s slug and the group’s slug,
separated with a colon (e.g. acme:developers)
Example
{ "kind": "push", "branch_match_kind": "branching_model", "branch_type": "feature", "groups": [ { "workspace": { "forking_mode": "allow_forks" } } ]}If the request was not authenticated
Base type for most resource objects. It defines the common type element that identifies an object’s type. It also identifies the element as Swagger’s discriminator.
object
object
Optional structured data that is endpoint-specific.
object
Example generated
{ "type": "example", "error": { "message": "example", "detail": "example", "data": {} }}If the authenticated user does not have admin access to the repository
Base type for most resource objects. It defines the common type element that identifies an object’s type. It also identifies the element as Swagger’s discriminator.
object
object
Optional structured data that is endpoint-specific.
object
Example generated
{ "type": "example", "error": { "message": "example", "detail": "example", "data": {} }}If the repository does not exist
Base type for most resource objects. It defines the common type element that identifies an object’s type. It also identifies the element as Swagger’s discriminator.
object
object
Optional structured data that is endpoint-specific.
object
Example generated
{ "type": "example", "error": { "message": "example", "detail": "example", "data": {} }}