|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is part of the Bitbucket API Client. |
| 7 | + * |
| 8 | + * (c) Graham Campbell <hello@gjcampbell.co.uk> |
| 9 | + * |
| 10 | + * For the full copyright and license information, please view the LICENSE |
| 11 | + * file that was distributed with this source code. |
| 12 | + */ |
| 13 | + |
| 14 | +namespace Bitbucket\Api\Workspaces\Projects\PermissionsConfig; |
| 15 | + |
| 16 | +use Bitbucket\HttpClient\Util\UriBuilder; |
| 17 | + |
| 18 | +/** |
| 19 | + * The groups API class. |
| 20 | + * |
| 21 | + * @author Graham Campbell <hello@gjcampbell.co.uk> |
| 22 | + */ |
| 23 | +class Groups extends AbstractPermissionsConfigApi |
| 24 | +{ |
| 25 | + /** |
| 26 | + * @throws \Http\Client\Exception |
| 27 | + */ |
| 28 | + public function list(array $params = []): array |
| 29 | + { |
| 30 | + $uri = $this->buildGroupsUri(); |
| 31 | + |
| 32 | + return $this->get($uri, $params); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * @throws \Http\Client\Exception |
| 37 | + */ |
| 38 | + public function show(string $group, array $params = []): array |
| 39 | + { |
| 40 | + $uri = $this->buildGroupsUri($group); |
| 41 | + |
| 42 | + return $this->get($uri, $params); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * @throws \Http\Client\Exception |
| 47 | + */ |
| 48 | + public function update(string $group, array $params = []): array |
| 49 | + { |
| 50 | + $uri = $this->buildGroupsUri($group); |
| 51 | + |
| 52 | + return $this->put($uri, $params); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * @throws \Http\Client\Exception |
| 57 | + */ |
| 58 | + public function remove(string $group, array $params = []): array |
| 59 | + { |
| 60 | + $uri = $this->buildGroupsUri($group); |
| 61 | + |
| 62 | + return $this->delete($uri, $params); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Build the groups URI from the given parts. |
| 67 | + */ |
| 68 | + protected function buildGroupsUri(string ...$parts): string |
| 69 | + { |
| 70 | + return UriBuilder::build('workspaces', $this->workspace, 'projects', $this->project, 'permissions-config', 'groups', ...$parts); |
| 71 | + } |
| 72 | +} |
0 commit comments