branch-restrictions Resource
Overview
This resource manages the branch restrictions on a Bitbucket Cloud repository. This resource has the following fields:
Field | Description |
---|---|
pagelen | An integer representing how many items to return per page. The default value is 10 and the maximum is 50. The caller can specify this value. |
next | The URL of the next page in the series. Only returned when there is a next page. |
values | An array of restriction data. |
page | An integer representing the current page. |
previous | The URL of the previous page in the series. Only returned when there is a previous page. |
size | The total number of items. |
The values
array takes the following:
Field | Description |
---|---|
groups | An array of groups profiles corresponding to a set of groups. This field is always empty for delete and force restrictions. |
id | The URL of the next page in the series. Only returned when there is a next page. |
kind | Type of restriction. This can be one of:
|
links | An array of links for making REST calls to this resource. |
pattern | A repository pattern to match. This is only applied when kind is push. Accepts wildcards. |
users | An array of user profiles corresponding to a set of users. This field is always empty for delete and force restrictions. |
When creating POST or PUT calls, the easiest way to pass data is as a JSON structure:
{
"kind": "TYPE",
"pattern": "PATTERN",
"groups": [{"owner": {"username": "USERNAME"}, "slug": "GROUPNAME"},{"owner": {...}...}],
"users": [ { "username": "USERNAME"} ]
}
To pass this to a curl call, create a file called body.json and pass it with the --data flag to curl:
curl -v --request POST --user username https://api.bitbucket.org/2.0/repositories/{usersname}/{repo-slug}/branch-restrictions --header 'Content-Type: application/json; charset=utf-8' --data @json.data
GET the branch-restrictions
Gets the information associated with a repository's branch restrictions. This call takes the following parameters:
Parameter | Required | Description |
---|---|---|
accountname | Yes | The account owner. |
repo | Yes | The repository name. |
GET https://api.bitbucket.org/2.0/repositories/{username}/{repo-slug}/branch-restrictions
POST the branch-restrictions
Creates restrictions for the specified repository. You should specify a Content-Header with this call. This call takes the following parameters:
Parameter | Required | Description |
---|---|---|
username | Yes | The account owner (path parameter). |
repo_slug | Yes | The repository name (path parameter). |
groups | No | One or more groups. This field is always empty for delete and force restrictions. |
kind | Yes | Type of restriction. This can be one of:
|
pattern | No | A repository pattern to match. This is only required when kind is [. Accepts wildcards. |
users | No | An array of user profiles corresponding to a set of users. This field is always empty for delete and force restrictions. |
POST https://api.bitbucket.org/2.0/repositories/{username}/{repo_slug}/branch-restrictions --header 'Content-Type: application/json; charset=utf-8' --data @json.data
curl -v -u tutorials https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/branch-restrictions --header "Content-Type: application/json" --data
{
"groups": [],
"kind": "push",
"pattern": "Tutorial-test-restrict",
"users": [{
"username": "tutorials"
}]
}
{
"groups": [],
"id": 152688,
"kind": "push",
"links": {
"parent": {
"href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/branch-restrictions"
},
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/branch-restrictions/152688"
}
},
"pattern": "Tutorial-test-restrict",
"users": [
{
"display_name": "tutorials account",
"links": {
"avatar": {
"href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Nov/25/tutorials-avatar-1563784409-6_avatar.png"
},
"self": {
"href": "https://api.bitbucket.org/2.0/users/tutorials"
}
},
"username": "tutorials"
}
]
}
{
"groups": [
{
"full_slug": "tutorials:team-from-space",
"name": "team-from-space",
"owner": {
"username": "tutorials"
},
"slug": "team-from-space"
}
],
"kind": "push",
"pattern": "Tutorial-test-restrict",
"users": []
}
{
"groups": [
{
"full_slug": "tutorials:team-from-space",
"links": {
"self": {
"href": "https://api.bitbucket.org/1.0/groups/tutorials/team-from-space"
}
},
"name": "team-from-space",
"owner": {
"display_name": "tutorials account",
"links": {
"avatar": {
"href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Nov/25/tutorials-avatar-1563784409-6_avatar.png"
},
"self": {
"href": "https://api.bitbucket.org/2.0/users/tutorials"
}
},
"username": "tutorials"
},
"slug": "team-from-space"
}
],
"id": 152748,
"kind": "push",
"links": {
"parent": {
"href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/branch-restrictions"
},
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/branch-restrictions/152748"
}
},
"pattern": "Tutorial-test-restrict",
"users": []
}
GET a specific restriction
Gets the information associated with specific restriction. This call takes the following parameters:
Parameter | Required | Description |
---|---|---|
accountname | Yes | The account owner. |
repo | Yes | The repository name. |
id | Yes | The restriction's identifier. |
GET https://api.bitbucket.org/2.0/repositories/{username}/{repo-slug}/branch-restrictions/{id}
PUT a branch restriction update
Updates a specific branch restriction. You cannot change the kind
value with this call. This call takes the following parameters:
Parameter | Required | Description |
---|---|---|
accountname | Yes | The account owner. |
repo | Yes | The repository name. |
groups | No | One or more groups. This field is always empty for delete and force restrictions. |
id | Yes | The restriction identifier. |
pattern | No | A repository pattern to match. This is only required when kind is push. Accepts wildcards. |
users | No | An array of user profiles corresponding to a set of users. This field is always empty for delete and force restrictions. |
PUT https://api.bitbucket.org/2.0/repositories/{username}/{repo-slug}/branch-restrictions/{id}
DELETE the branch restriction
Deletes the specified restriction. This call takes the following parameters:
Parameter | Required | Description |
---|---|---|
accountname | Yes | The account owner. |
repo | Yes | The repository name. |
id | Yes | The restriction identifier. |