An open API service indexing awesome lists of open source software.

https://github.com/evref-bl/bitbucket-pharo-api


https://github.com/evref-bl/bitbucket-pharo-api

Last synced: 9 months ago
JSON representation

Awesome Lists containing this project

README

          

# Bitbucket-Pharo-API

[![Continuous](https://github.com/Evref-BL/Bitbucket-Pharo-API/actions/workflows/continuous.yml/badge.svg)](https://github.com/Evref-BL/Bitbucket-Pharo-API/actions/workflows/continuous.yml)
[![Coverage Status](https://coveralls.io/repos/github/Evref-BL/Bitbucket-Pharo-API/badge.svg?branch=ci-add-coverage)](https://coveralls.io/github/Evref-BL/Bitbucket-Pharo-API?branch=develop)

This is a Pharo client for the [Bitbucket Server REST API](https://docs.atlassian.com/bitbucket-server/rest/5.9.0/bitbucket-rest.html)

## Usage

### Installation

```st
Metacello new
githubUser: 'Evref-BL' project: 'Bitbucket-Pharo-API' commitish: 'develop' path: 'src';
baseline: 'BitbucketPharoAPI';
onConflict: [ :ex | ex useIncoming ];
load
```

### Client

To start using the API, you need to create a client instance with your Bitbucket host and a Bearer token for authentication. Here’s an example:

```st
bitbucketApi := BitbucketApi new
host: 'bitbucket.org';
bearerToken: ''.
```

Replace `` with your actual Bitbucket token.

### Ressources

The API provides different resource classes to interact with different entities in Bitbucket. These resources include:

- branches
- commits
- projects
- pullRequests
- repositories
- users

Each resource provides methods for interacting with the corresponding Bitbucket resource. You can access them like this:

```st
bitbucketApi projects
```

### Example

Here are a few examples of how to interact with the API:

#### Fetch All Projects

This example retrieves all projects from Bitbucket:

```st
| projects |
projects := bitbucketApi projects all
```

#### Fetch All Commits for a Specific Branch

This example demonstrates how to fetch all commits for the dev branch within a specific repository and project, using parameters:

```st
| commits params |
params := {
#until -> 'dev'
} asDictionary.
commits := bitbucketApi commits allWithParams: params inRepository: '' ofProject: ''.
```

Replace `` with the slug of the repository and `` with the project key.