-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add project group permissions and user permissions;
- Loading branch information
Showing
4 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Bitbucket API Client. | ||
* | ||
* (c) Graham Campbell <hello@gjcampbell.co.uk> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Bitbucket\Api\Workspaces\Projects; | ||
|
||
use Bitbucket\Api\Workspaces\AbstractWorkspacesApi; | ||
use Bitbucket\Client; | ||
|
||
/** | ||
* The abstract projects API class. | ||
* | ||
* @author Patrick Barsallo <p.d.barsallo@gmail.com> | ||
*/ | ||
abstract class AbstractProjectsApi extends AbstractWorkspacesApi | ||
{ | ||
|
||
/** | ||
* The project. | ||
* | ||
* @var string | ||
*/ | ||
protected $project; | ||
|
||
/** | ||
* Create a new API instance. | ||
* | ||
* @param Client $client | ||
* @param string $project | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Client $client, string $workspace, string $project) | ||
{ | ||
parent::__construct($client, $workspace); | ||
$this->project = $project; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Bitbucket API Client. | ||
* | ||
* (c) Graham Campbell <hello@gjcampbell.co.uk> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Bitbucket\Api\Workspaces\Projects; | ||
|
||
use Bitbucket\HttpClient\Util\UriBuilder; | ||
|
||
/** | ||
* The branch restrictions API class. | ||
* | ||
* @author Graham Campbell <hello@gjcampbell.co.uk> | ||
*/ | ||
class GroupPermissions extends AbstractProjectsApi | ||
{ | ||
/** | ||
* @param array $params | ||
* | ||
* @throws \Http\Client\Exception | ||
* | ||
* @return array | ||
*/ | ||
public function list(array $params = []) | ||
{ | ||
$uri = $this->buildGroupsUri(); | ||
|
||
return $this->get($uri, $params); | ||
} | ||
|
||
/** | ||
* @param string $group | ||
* @param array $params | ||
* | ||
* @throws \Http\Client\Exception | ||
* | ||
* @return array | ||
*/ | ||
public function show(string $group, array $params = []) | ||
{ | ||
$uri = $this->buildGroupsUri($group); | ||
|
||
return $this->get($uri, $params); | ||
} | ||
|
||
/** | ||
* @param string $group | ||
* @param array $params | ||
* | ||
* @throws \Http\Client\Exception | ||
* | ||
* @return array | ||
*/ | ||
public function update(string $group, array $params = []) | ||
{ | ||
$uri = $this->buildGroupsUri($group); | ||
|
||
return $this->put($uri, $params); | ||
} | ||
|
||
/** | ||
* @param string $group | ||
* @param array $params | ||
* | ||
* @throws \Http\Client\Exception | ||
* | ||
* @return array | ||
*/ | ||
public function remove(string $group, array $params = []) | ||
{ | ||
$uri = $this->buildGroupsUri($group); | ||
|
||
return $this->delete($uri, $params); | ||
} | ||
|
||
/** | ||
* Build the groups URI from the given parts. | ||
* | ||
* @param string ...$parts | ||
* | ||
* @return string | ||
*/ | ||
public function buildGroupsUri(string ...$parts): string | ||
{ | ||
return UriBuilder::build('workspaces', $this->workspace, 'projects', $this->project, 'permissions-config/groups', ...$parts); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Bitbucket API Client. | ||
* | ||
* (c) Graham Campbell <hello@gjcampbell.co.uk> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Bitbucket\Api\Workspaces\Projects; | ||
|
||
use Bitbucket\HttpClient\Util\UriBuilder; | ||
|
||
/** | ||
* The branch restrictions API class. | ||
* | ||
* @author Graham Campbell <hello@gjcampbell.co.uk> | ||
*/ | ||
class UserPermissions extends AbstractProjectsApi | ||
{ | ||
/** | ||
* @param array $params | ||
* | ||
* @throws \Http\Client\Exception | ||
* | ||
* @return array | ||
*/ | ||
public function list(array $params = []) | ||
{ | ||
$uri = $this->buildUsersUri(); | ||
|
||
return $this->get($uri, $params); | ||
} | ||
|
||
/** | ||
* @param string $user | ||
* @param array $params | ||
* | ||
* @throws \Http\Client\Exception | ||
* | ||
* @return array | ||
*/ | ||
public function show(string $user, array $params = []) | ||
{ | ||
$uri = $this->buildUsersUri($user); | ||
|
||
return $this->get($uri, $params); | ||
} | ||
|
||
/** | ||
* @param string $user | ||
* @param array $params | ||
* | ||
* @throws \Http\Client\Exception | ||
* | ||
* @return array | ||
*/ | ||
public function create(string $user, array $params = []) | ||
{ | ||
$uri = $this->buildUsersUri($user); | ||
|
||
return $this->put($uri, $params); | ||
} | ||
|
||
/** | ||
* @param string $user | ||
* @param array $params | ||
* | ||
* @throws \Http\Client\Exception | ||
* | ||
* @return array | ||
*/ | ||
public function update(string $user, array $params = []) | ||
{ | ||
$uri = $this->buildUsersUri($user); | ||
|
||
return $this->put($uri, $params); | ||
} | ||
|
||
/** | ||
* @param string $user | ||
* @param array $params | ||
* | ||
* @throws \Http\Client\Exception | ||
* | ||
* @return array | ||
*/ | ||
public function remove(string $user, array $params = []) | ||
{ | ||
$uri = $this->buildUsersUri($user); | ||
|
||
return $this->delete($uri, $params); | ||
} | ||
|
||
/** | ||
* Build the groups URI from the given parts. | ||
* | ||
* @param string ...$parts | ||
* | ||
* @return string | ||
*/ | ||
public function buildUsersUri(string ...$parts): string | ||
{ | ||
return UriBuilder::build('workspaces', $this->workspace, 'projects', $this->project, 'permissions-config/users', ...$parts); | ||
} | ||
} |