bitbucketcloud-api

Java library for interfacing with the bitbucket cloud api

Лицензия

Лицензия

Группа

Группа

com.chimerapps
Идентификатор

Идентификатор

bitbucketcloud-api
Последняя версия

Последняя версия

0.1.2
Дата

Дата

Тип

Тип

pom.sha512
Описание

Описание

bitbucketcloud-api
Java library for interfacing with the bitbucket cloud api
Ссылка на сайт

Ссылка на сайт

https://github.com/Chimerapps/bitbucketcloud-api
Система контроля версий

Система контроля версий

https://github.com/Chimerapps/bitbucketcloud-api

Скачать bitbucketcloud-api

Зависимости

runtime (5)

Идентификатор библиотеки Тип Версия
com.squareup.retrofit2 : retrofit jar 2.3.0
com.squareup.okhttp3 : okhttp jar 3.9.1
com.google.code.gson : gson jar 2.8.2
com.squareup.retrofit2 : converter-gson jar 2.3.0
org.jetbrains : annotations-java5 jar 15.0

Модули Проекта

Данный проект не имеет модулей.

Bitbucket Cloud API

Java Library to acces the Bitbucket Cloud API.
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories

Supported API Calls

  • Get User
  • Get Repositories
  • Get Default Users
  • Create Pull Request

Authentication

Username

This is the name chosen when you created your account. (It can be found in the Bitbucket Settings under Account Settings)

App Token

This is a token you need to generate in your Bitbucket Settings. Go to App Passwords (under Acces Management). You can create a new App Password. This will be used instead of your 2 Step Verification.

settings

settings-config

The best option to save your Username and App Token is to save them in your System Environment (for Mac You can use EnvPane or just set them with commandline.)

Get User

Documentation

final Response<BitbucketUser> response = new Bitbucket(USERNAME, APP_TOKEN).getApi()
                             .getUser()
                             .execute();

Get Repositories

Documentation

final Response<PagedList<BitbucketRepository>> response = new Bitbucket(USERNAME, APP_TOKEN).getApi()
                            .getRepositories(user,PropertyCompare.eq("name", repoSlug))
                            .execute();

Get Default Users

Documentation

final Response<PagedList<BitbucketRepository>> response = new Bitbucket(USERNAME, APP_TOKEN).getApi()
                            .getDefaultReviewers(user, repoSlug)
                            .execute();

Create Pull Request

Documentation

Without reviewers:

final String title = "Title of your PR";
final String description = "Description of your PR";

final Destination source = new Destination("branch-name-you-want-to-merge");
final Destination destination = new Destination("branch-name-where-you-want-to-merge-to");

final PullRequest pullRequest = new PullRequest(title, description, source, destination, null);

final Response<PullRequest> response = mBitbucket.getApi()
                .postPullRequest(user, repoSlug, pullRequest)
                .execute();

With reviewers (your own username may not be included):

final Response<PagedList<DefaultReviewer>> responseDefaultReviewers = mBitbucket.getApi()
                .getDefaultReviewers(user, repoSlug)
                .execute();
                
final PagedList<DefaultReviewer> defaultReviewers = responseDefaultReviewers.body();

final List<DefaultReviewer> filteredList = defaultReviewers.getValues()
                .stream()
                .filter(r -> !r.getUsername().equals(USERNAME))
                .collect(Collectors.toList());

final String title = "Title of your PR";
final String description = "Description of your PR";

final Destination source = new Destination("branch-name-you-want-to-merge");
final Destination destination = new Destination("branch-name-where-you-want-to-merge-to");

final PullRequest pullRequest = new PullRequest(title, description, source, destination, filteredList);

final Response<PullRequest> response = mBitbucket.getApi()
                .postPullRequest(user, repoSlug, pullRequest)
                .execute();

With hardcoded reviewer:

final List<DefaultReviewer> reviewers = new ArrayList();
reviewers.add(new DefaultReviewer("username-of-the-reviewer"));

final String title = "Title of your PR";
final String description = "Description of your PR";

final Destination source = new Destination("branch-name-you-want-to-merge");
final Destination destination = new Destination("branch-name-where-you-want-to-merge-to");

final PullRequest pullRequest = new PullRequest(title, description, source, destination, reviewers);

final Response<PullRequest> response = mBitbucket.getApi()
                .postPullRequest(user, repoSlug, pullRequest)
                .execute();
com.chimerapps

Chimerapps

Версии библиотеки

Версия
0.1.2