PHP Bitbucket API

Simple Bitbucket API wrapper for PHP

Branch restrictions

Manage branch restrictions on a repository

Prepare:

// @see: https://bitbucket.org/account/user/<username or team>/api
$oauth_params = array(
    'client_id'         => 'aaa',
    'client_secret'     => 'bbb'
);

$restrictions = new \Bitbucket\API\Repositories\BranchRestrictions();
$restrictions->getClient()->addListener(
    new \Bitbucket\API\Http\Listener\OAuth2Listener($oauth_params)
);

Get the information associated with a repository's branch restrictions: (API 2.0)

$restrictions->all($account_name, $repo_slug);

Creates restrictions: (API 2.0)

Restrict push access to any branches starting with joe-and-mary- only to users joe and mary:

$restrictions->create($account_name, $repo_slug, array(
    'kind'      => 'push',
    'pattern'   => 'joe-and-mary-*',
    'users'     => array(
        array('username' => 'joe'),
        array('username' => 'mary')
    )
));

Get a specific restriction: (API 2.0)

$restrictions->get($account_name, $repo_slug, $restrictionID);

Update a specific restriction: (API 2.0)

$restrictions->update($account_name, $repo_slug, $restrictionID, array(
    'users' => array(
        array('username' => 'joe'),
        array('username' => 'mary'),
        array('username' => 'joe-work')
    )
));

Delete a specific restriction: (API 2.0)

$restrictions->delete($account_name, $repo_slug, $restrictionID);