Bitbucket Nodejs Library
This is nodejs module to use the functionalities of repository, deploy-keys, service hooks in bitbucket. Bitbucket's native REST API, both version 1 & version 2 are used for appropriate actions.
Install
To install the most recent release from npm, run:
npm install bitbucket-restA simple example to create a bitbucket client.
var bitbucket = require('bitbucket-rest');
var client = bitbucket.connectClient({username : 'user', password : 'pass'});
client.getRepoDetails({owner:'owner_name', repo_slug : 'repo_slug'}, function(res){
callback(res);
});
Documentation
Create New Repository
To create a new repository.
client.createRepo(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.namename of the repository.descriptiondescription for the repository.is_privateforking_policyfork policy values - no_public_forks, allow_forks, no_forkslanguagehas_issueshas_wikiscm
This returns following object:
{
status : 200,
data : [object]
}Get Repository Details
To get complete detail about the repository.
client.getRepoDetails(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.
This returns following object:
{
status : 200,
data : [object]
}Update Repository Details
To update the details of the repository.
client.updateRepoDetails(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.namename of the repository.descriptiondescription for the repository.is_privateforking_policyfork policy values - no_public_forks, allow_forks, no_forkslanguagescm
This returns following object:
{
status : 200,
data : [object]
}Delete a Repository
To delete a repository.
client.deleteRepo(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.
This returns following object:
{
status : 204,
data : undefined
}Fork a Repository
To fork a repository.
client.forkRepo(repo, forkRepo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.
Parameters of forkRepo:
namename of the repository - REQUIRED.descriptiondescription for the repository.is_privatelanguagescm
This returns following object:
{
status : 200,
data : [object]
}Get Fork List
To get list of forks of a repository.
client.getRepoForks(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.
This returns following object:
{
status : 200,
data : [object]
}Get Branches
To get branches of the repository.
client.getRepoBranches(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.
This returns following object:
{
status : 200,
data : [object]
}Get Main Branch
To get the main branch of a repository.
client.getRepoMainBranch(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.
This returns following object:
{
status : 200,
data : [object]
}Add Deployment-Key
To add deployment keys to a repository.
client.addRepoDeployKey(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.labellabel to represent the keykeyRSA key generated by ssh keygen - REQUIRED
This returns following object:
{
status : 200,
data : [object]
}Get Deployment-Keys
To get deployment keys of a repository.
client.getRepoDeployKeys(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.
This returns following object:
{
status : 200,
data : [object]
}Get Content of a Deployment-Key
To get the content of a deployment key of a repository.
client.getRepoDeployKeyContent(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.pkkey_id of the deployment-key - REQUIRED.
This returns following object:
{
status : 200,
data : [object]
}Delete a Deployment-Key
To delete a deployment key of a repository.
client.deleteRepoDeployKey(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.pkkey_id of the deployment-key - REQUIRED.
This returns following object:
{
status : 204,
data : undefined
}Add Hook Service
To add a hook service to a repository.
client.addRepoHook(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.typehook type ex.POST (case sensitive)URLservice url for which accepts post hook.
This returns following object:
{
status : 200,
data : [object]
}Get Hook Services
To get the list of hook services of a repository.
client.getRepoHooks(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.
This returns following object:
{
status : 200,
data : [object]
}Get Content of a Hook Service
To get the content of a single hook service of a repository.
client.getRepoHookContent(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.idhook service id - REQUIRED.
This returns following object:
{
status : 200,
data : [object]
}Update of a Hook Service
To update a hook service of a repository.
client.updateRepoHook(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.idhook service id - REQUIRED.URLservice url for which accepts post hook.
This returns following object:
{
status : 200,
data : [object]
}Delete Content of a Hook Service
To delete a hook service of a repository.
client.deleteRepoHook(repo, callback)Parameters of repo:
ownerowner of the repository - REQUIRED.repo_slugslug of the repository - REQUIRED.idhook service id - REQUIRED.
This returns following object:
{
status : 204,
data : undefined
}