Skip to content

Commit 9bd6ceb

Browse files
authored
Add Support for Workspace Repository Permissions APIs (#75)
1 parent fa84d7e commit 9bd6ceb

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

src/Api/Workspaces/Permissions.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313

1414
namespace Bitbucket\Api\Workspaces;
1515

16+
use Bitbucket\Api\Workspaces\Permissions\Repositories;
1617
use Bitbucket\HttpClient\Util\UriBuilder;
1718

1819
/**
1920
* The permissions API class.
2021
*
2122
* @author Graham Campbell <[email protected]>
23+
* @author Patrick Barsallo <[email protected]>
2224
*/
2325
class Permissions extends AbstractWorkspacesApi
2426
{
@@ -36,6 +38,14 @@ public function list(array $params = [])
3638
return $this->get($uri, $params);
3739
}
3840

41+
/**
42+
* @return \Bitbucket\Api\Workspaces\Permissions\Repositories
43+
*/
44+
public function repositories()
45+
{
46+
return new Repositories($this->getClient(), $this->workspace);
47+
}
48+
3949
/**
4050
* Build the permissions URI from the given parts.
4151
*
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 <[email protected]>
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\Permissions;
15+
16+
use Bitbucket\Api\Workspaces\AbstractWorkspacesApi;
17+
18+
/**
19+
* The abstract permissions API class.
20+
*
21+
* @author Patrick Barsallo <[email protected]>
22+
*/
23+
abstract class AbstractPermissionsApi extends AbstractWorkspacesApi
24+
{
25+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 <[email protected]>
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\Permissions;
15+
16+
use Bitbucket\HttpClient\Util\UriBuilder;
17+
18+
/**
19+
* The repositories API class.
20+
*
21+
* @author Patrick Barsallo <[email protected]>
22+
*/
23+
class Repositories extends AbstractPermissionsApi
24+
{
25+
/**
26+
* @param array $params
27+
*
28+
* @throws \Http\Client\Exception
29+
*
30+
* @return array
31+
*/
32+
public function list(array $params = [])
33+
{
34+
$uri = UriBuilder::appendSeparator($this->buildRepositoriesUri());
35+
36+
return $this->get($uri, $params);
37+
}
38+
39+
/**
40+
* @param string $repo
41+
* @param array $params
42+
*
43+
* @throws \Http\Client\Exception
44+
*
45+
* @return array
46+
*/
47+
public function show(string $repo, array $params = [])
48+
{
49+
$uri = $this->buildRepositoriesUri($repo);
50+
51+
return $this->get($uri, $params);
52+
}
53+
54+
/**
55+
* Build the repositories URI from the given parts.
56+
*
57+
* @param string ...$parts
58+
*
59+
* @return string
60+
*/
61+
protected function buildRepositoriesUri(string ...$parts)
62+
{
63+
return UriBuilder::build('workspaces', $this->workspace, 'permissions', 'repositories', ...$parts);
64+
}
65+
}

0 commit comments

Comments
 (0)