bitbucket-api-client-lib

BranchrestrictionsApi

All URIs are relative to https://api.bitbucket.org/2.0

Method HTTP request Description
repositoriesWorkspaceRepoSlugBranchRestrictionsGet GET /repositories/{workspace}/{repo_slug}/branch-restrictions  
repositoriesWorkspaceRepoSlugBranchRestrictionsIdDelete DELETE /repositories/{workspace}/{repo_slug}/branch-restrictions/{id}  
repositoriesWorkspaceRepoSlugBranchRestrictionsIdGet GET /repositories/{workspace}/{repo_slug}/branch-restrictions/{id}  
repositoriesWorkspaceRepoSlugBranchRestrictionsIdPut PUT /repositories/{workspace}/{repo_slug}/branch-restrictions/{id}  
repositoriesWorkspaceRepoSlugBranchRestrictionsPost POST /repositories/{workspace}/{repo_slug}/branch-restrictions  

repositoriesWorkspaceRepoSlugBranchRestrictionsGet

PaginatedBranchrestrictions repositoriesWorkspaceRepoSlugBranchRestrictionsGet(repoSlug, workspace, kind, pattern)

Returns a paginated list of all branch restrictions on the repository.

Example

// Import classes:
//import com.rappi.bitbucket.client.invoker.ApiClient;
//import com.rappi.bitbucket.client.invoker.ApiException;
//import com.rappi.bitbucket.client.invoker.Configuration;
//import com.rappi.bitbucket.client.invoker.auth.*;
//import com.rappi.bitbucket.client.api.BranchrestrictionsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: api_key
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
api_key.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.setApiKeyPrefix("Token");
// Configure HTTP basic authorization: basic
HttpBasicAuth basic = (HttpBasicAuth) defaultClient.getAuthentication("basic");
basic.setUsername("YOUR USERNAME");
basic.setPassword("YOUR PASSWORD");

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

BranchrestrictionsApi apiInstance = new BranchrestrictionsApi();
String repoSlug = "repoSlug_example"; // String | This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`. 
String workspace = "workspace_example"; // String | This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`. 
String kind = "kind_example"; // String | Branch restrictions of this type
String pattern = "pattern_example"; // String | Branch restrictions applied to branches of this pattern
try {
    PaginatedBranchrestrictions result = apiInstance.repositoriesWorkspaceRepoSlugBranchRestrictionsGet(repoSlug, workspace, kind, pattern);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling BranchrestrictionsApi#repositoriesWorkspaceRepoSlugBranchRestrictionsGet");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
repoSlug String This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`.  
workspace String This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`.  
kind String Branch restrictions of this type [optional]
pattern String Branch restrictions applied to branches of this pattern [optional]

Return type

PaginatedBranchrestrictions

Authorization

api_keybasicoauth2

HTTP request headers

repositoriesWorkspaceRepoSlugBranchRestrictionsIdDelete

repositoriesWorkspaceRepoSlugBranchRestrictionsIdDelete(id, repoSlug, workspace)

Deletes an existing branch restriction rule.

Example

// Import classes:
//import com.rappi.bitbucket.client.invoker.ApiClient;
//import com.rappi.bitbucket.client.invoker.ApiException;
//import com.rappi.bitbucket.client.invoker.Configuration;
//import com.rappi.bitbucket.client.invoker.auth.*;
//import com.rappi.bitbucket.client.api.BranchrestrictionsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: api_key
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
api_key.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.setApiKeyPrefix("Token");
// Configure HTTP basic authorization: basic
HttpBasicAuth basic = (HttpBasicAuth) defaultClient.getAuthentication("basic");
basic.setUsername("YOUR USERNAME");
basic.setPassword("YOUR PASSWORD");

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

BranchrestrictionsApi apiInstance = new BranchrestrictionsApi();
String id = "id_example"; // String | The restriction rule's id
String repoSlug = "repoSlug_example"; // String | This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`. 
String workspace = "workspace_example"; // String | This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`. 
try {
    apiInstance.repositoriesWorkspaceRepoSlugBranchRestrictionsIdDelete(id, repoSlug, workspace);
} catch (ApiException e) {
    System.err.println("Exception when calling BranchrestrictionsApi#repositoriesWorkspaceRepoSlugBranchRestrictionsIdDelete");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
id String The restriction rule's id  
repoSlug String This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`.  
workspace String This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`.  

Return type

null (empty response body)

Authorization

api_keybasicoauth2

HTTP request headers

repositoriesWorkspaceRepoSlugBranchRestrictionsIdGet

Branchrestriction repositoriesWorkspaceRepoSlugBranchRestrictionsIdGet(id, repoSlug, workspace)

Returns a specific branch restriction rule.

Example

// Import classes:
//import com.rappi.bitbucket.client.invoker.ApiClient;
//import com.rappi.bitbucket.client.invoker.ApiException;
//import com.rappi.bitbucket.client.invoker.Configuration;
//import com.rappi.bitbucket.client.invoker.auth.*;
//import com.rappi.bitbucket.client.api.BranchrestrictionsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: api_key
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
api_key.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.setApiKeyPrefix("Token");
// Configure HTTP basic authorization: basic
HttpBasicAuth basic = (HttpBasicAuth) defaultClient.getAuthentication("basic");
basic.setUsername("YOUR USERNAME");
basic.setPassword("YOUR PASSWORD");

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

BranchrestrictionsApi apiInstance = new BranchrestrictionsApi();
String id = "id_example"; // String | The restriction rule's id
String repoSlug = "repoSlug_example"; // String | This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`. 
String workspace = "workspace_example"; // String | This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`. 
try {
    Branchrestriction result = apiInstance.repositoriesWorkspaceRepoSlugBranchRestrictionsIdGet(id, repoSlug, workspace);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling BranchrestrictionsApi#repositoriesWorkspaceRepoSlugBranchRestrictionsIdGet");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
id String The restriction rule's id  
repoSlug String This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`.  
workspace String This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`.  

Return type

Branchrestriction

Authorization

api_keybasicoauth2

HTTP request headers

repositoriesWorkspaceRepoSlugBranchRestrictionsIdPut

Branchrestriction repositoriesWorkspaceRepoSlugBranchRestrictionsIdPut(body, id, repoSlug, workspace)

Updates an existing branch restriction rule. Fields not present in the request body are ignored. See `POST` for details.

Example

// Import classes:
//import com.rappi.bitbucket.client.invoker.ApiClient;
//import com.rappi.bitbucket.client.invoker.ApiException;
//import com.rappi.bitbucket.client.invoker.Configuration;
//import com.rappi.bitbucket.client.invoker.auth.*;
//import com.rappi.bitbucket.client.api.BranchrestrictionsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: api_key
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
api_key.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.setApiKeyPrefix("Token");
// Configure HTTP basic authorization: basic
HttpBasicAuth basic = (HttpBasicAuth) defaultClient.getAuthentication("basic");
basic.setUsername("YOUR USERNAME");
basic.setPassword("YOUR PASSWORD");

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

BranchrestrictionsApi apiInstance = new BranchrestrictionsApi();
Branchrestriction body = new Branchrestriction(); // Branchrestriction | The new version of the existing rule
String id = "id_example"; // String | The restriction rule's id
String repoSlug = "repoSlug_example"; // String | This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`. 
String workspace = "workspace_example"; // String | This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`. 
try {
    Branchrestriction result = apiInstance.repositoriesWorkspaceRepoSlugBranchRestrictionsIdPut(body, id, repoSlug, workspace);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling BranchrestrictionsApi#repositoriesWorkspaceRepoSlugBranchRestrictionsIdPut");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
body Branchrestriction The new version of the existing rule  
id String The restriction rule's id  
repoSlug String This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`.  
workspace String This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`.  

Return type

Branchrestriction

Authorization

api_keybasicoauth2

HTTP request headers

repositoriesWorkspaceRepoSlugBranchRestrictionsPost

Branchrestriction repositoriesWorkspaceRepoSlugBranchRestrictionsPost(body, repoSlug, workspace)

Creates a new branch restriction rule for a repository. `kind` describes what will be restricted. Allowed values include: `push`, `force`, `delete` and `restrict_merges`. Different kinds of branch restrictions have different requirements: * `push` and `restrict_merges` require `users` and `groups` to be specified. Empty lists are allowed, in which case permission is denied for everybody. * `force` can not be specified in a Mercurial repository. The restriction applies to all branches that match. There are two ways to match a branch. It is configured in `branch_match_kind`: 1. `glob`: Matches a branch against the `pattern`. A `''` in `pattern` will 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. 2. `branching_model`: Matches a branch against the repository's branching model. The `branch_type` controls the type of branch to match. Allowed values include: `production`, `development`, `bugfix`, `release`, `feature` and `hotfix`. 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.

Example

// Import classes:
//import com.rappi.bitbucket.client.invoker.ApiClient;
//import com.rappi.bitbucket.client.invoker.ApiException;
//import com.rappi.bitbucket.client.invoker.Configuration;
//import com.rappi.bitbucket.client.invoker.auth.*;
//import com.rappi.bitbucket.client.api.BranchrestrictionsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: api_key
ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
api_key.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.setApiKeyPrefix("Token");
// Configure HTTP basic authorization: basic
HttpBasicAuth basic = (HttpBasicAuth) defaultClient.getAuthentication("basic");
basic.setUsername("YOUR USERNAME");
basic.setPassword("YOUR PASSWORD");

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

BranchrestrictionsApi apiInstance = new BranchrestrictionsApi();
Branchrestriction body = new Branchrestriction(); // Branchrestriction | The new rule
String repoSlug = "repoSlug_example"; // String | This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`. 
String workspace = "workspace_example"; // String | This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`. 
try {
    Branchrestriction result = apiInstance.repositoriesWorkspaceRepoSlugBranchRestrictionsPost(body, repoSlug, workspace);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling BranchrestrictionsApi#repositoriesWorkspaceRepoSlugBranchRestrictionsPost");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
body Branchrestriction The new rule  
repoSlug String This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`.  
workspace String This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`.  

Return type

Branchrestriction

Authorization

api_keybasicoauth2

HTTP request headers