Skip to content

Evref-BL/BitbucketCloud-Pharo-Api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BitbucketCloud-Pharo-Api

Continuous Coverage Status

A Pharo client for the Bitbucket Cloud REST API

If you are looking for a client targeting Bitbucket Server instead, check out: Bitbucket-Pharo-API.

Usage

Installation

From playground

Metacello new
  githubUser: 'Evref-BL' project: 'BitbucketCloud-Pharo-API' commitish: 'main' path: 'src';
  baseline: 'BitbucketCloudPharoAPI';
  onConflict: [ :ex | ex useIncoming ];
  load

Baseline dependency

  spec
    baseline: 'BitbucketCloudPharoAPI' with: [
      spec repository: 'github://Evref-BL/BitbucketCloud-Pharo-API:main'
    ]

Client

To start using the API, create a BitbucketCloudApi client instance. The API supports two authentication methods: access token or API token (with username).

Using an Access Token

bitbucketCloudApi := BitbucketCloudApi new
  host: 'api.bitbucket.org';
  accessToken: '<your-access-token>'.

Using an API Token

bitbucketCloudApi := BitbucketCloudApi new
  host: 'api.bitbucket.org';
  username: '<your-email>';
  apiToken: '<your-api-token>'.

Ressources

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

  • pullRequests
  • refs
  • repositories
  • source

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

bitbucketCloudApi repositories <method>

Example

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

Retrieve a Pull Request

Fetch a pull request by ID within a repository and workspace:

| pullRequest |
pullRequest := bitbucketCloudApi pullRequests get: <pullRequestId> inRepository: '<repoSlug>' ofWorkspace: '<workspace>'.

List Files and Directories in a Repository

Retrieve files/directories in a repository branch with parameters (e.g., depth):

| commits params |
params := { 
	'max_depth' -> '10'
} asDictionary.
bitbucketCloudApi repositories getFileOrDirectory: '' fromCommit: '<branchName>' inRepository: '<repoSlug>' ofWorkspace: '<workspace>' withParams: params.

Create a commit

Create a commit on a branch (only works with API token authentication):

| commits params |
commit := BitbucketCloudSourceCommit new
  message: 'Update README';
  branch: 'dev';
  addFile: 'README.md' withNewContent: 'This is my updated README content.'.

bitbucketCloudApi source createCommit: commit inRepository: '<repoSlug>' ofWorkspace: '<workspace>'.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors