Skip to content

Commit 87d2f14

Browse files
Added some new repo APIs (#49)
1 parent 4077915 commit 87d2f14

File tree

10 files changed

+465
-0
lines changed

10 files changed

+465
-0
lines changed

src/Api/Repositories/Workspaces.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Bitbucket\Api\Repositories\Workspaces\Forks;
3030
use Bitbucket\Api\Repositories\Workspaces\Hooks;
3131
use Bitbucket\Api\Repositories\Workspaces\Issues;
32+
use Bitbucket\Api\Repositories\Workspaces\MergeBases;
3233
use Bitbucket\Api\Repositories\Workspaces\Milestones;
3334
use Bitbucket\Api\Repositories\Workspaces\Patches;
3435
use Bitbucket\Api\Repositories\Workspaces\Pipelines;
@@ -281,6 +282,16 @@ public function issues(string $repo)
281282
return new Issues($this->getHttpClient(), $this->workspace, $repo);
282283
}
283284

285+
/**
286+
* @param string $repo
287+
*
288+
* @return \Bitbucket\Api\Repositories\Workspaces\Patches
289+
*/
290+
public function mergeBases(string $repo)
291+
{
292+
return new MergeBases($this->getHttpClient(), $this->workspace, $repo);
293+
}
294+
284295
/**
285296
* @param string $repo
286297
*

src/Api/Repositories/Workspaces/Commit.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Bitbucket\Api\Repositories\Workspaces\Commit\Comments;
1818
use Bitbucket\Api\Repositories\Workspaces\Commit\Properties as CommitProperties;
1919
use Bitbucket\Api\Repositories\Workspaces\Commit\PullRequests as CommitPullRequests;
20+
use Bitbucket\Api\Repositories\Workspaces\Commit\Reports;
2021
use Bitbucket\Api\Repositories\Workspaces\Commit\Statuses;
2122

2223
/**
@@ -81,6 +82,16 @@ public function pullRequests(string $commit)
8182
return new CommitPullRequests($this->getHttpClient(), $this->workspace, $this->repo, $commit);
8283
}
8384

85+
/**
86+
* @param string $commit
87+
*
88+
* @return \Bitbucket\Api\Repositories\Workspaces\Commit\Reports
89+
*/
90+
public function reports(string $commit)
91+
{
92+
return new Reports($this->getHttpClient(), $this->workspace, $this->repo, $commit);
93+
}
94+
8495
/**
8596
* @param string $commit
8697
*
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of 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\Repositories\Workspaces\Commit;
15+
16+
use Bitbucket\Api\Repositories\Workspaces\Commit\Reports\Annotations;
17+
18+
/**
19+
* The reports api class.
20+
*
21+
* @author Graham Campbell <[email protected]>
22+
*/
23+
class Reports extends AbstractCommitApi
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+
$path = $this->buildReportsPath();
35+
36+
return $this->get($path, $params);
37+
}
38+
39+
/**
40+
* @param array $params
41+
*
42+
* @throws \Http\Client\Exception
43+
*
44+
* @return array
45+
*/
46+
public function create(array $params = [])
47+
{
48+
$path = $this->buildReportsPath();
49+
50+
return $this->post($path, $params);
51+
}
52+
53+
/**
54+
* @param string $report
55+
* @param array $params
56+
*
57+
* @throws \Http\Client\Exception
58+
*
59+
* @return array
60+
*/
61+
public function show(string $report, array $params = [])
62+
{
63+
$path = $this->buildReportsPath($report);
64+
65+
return $this->get($path, $params);
66+
}
67+
68+
/**
69+
* @return \Bitbucket\Api\Repositories\Workspaces\Commit\Reports\Annotations
70+
*/
71+
public function annotations()
72+
{
73+
return new Annotations($this->getHttpClient(), $this->workspace, $this->repo, $this->commit);
74+
}
75+
76+
/**
77+
* Build the reports path from the given parts.
78+
*
79+
* @param string[] $parts
80+
*
81+
* @throws \Bitbucket\Exception\InvalidArgumentException
82+
*
83+
* @return string
84+
*/
85+
protected function buildReportsPath(string ...$parts)
86+
{
87+
return static::buildPath('repositories', $this->workspace, $this->repo, 'commit', $this->commit, 'reports', ...$parts);
88+
}
89+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of 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\Repositories\Workspaces\Commit\Reports;
15+
16+
use Bitbucket\Api\Repositories\Workspaces\Commit\AbstractCommitApi;
17+
18+
/**
19+
* The abstract reports api class.
20+
*
21+
* @author Graham Campbell <[email protected]>
22+
*/
23+
abstract class AbstractReportsApi extends AbstractCommitApi
24+
{
25+
//
26+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of 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\Repositories\Workspaces\Commit\Reports;
15+
16+
/**
17+
* The annotations api class.
18+
*
19+
* @author Graham Campbell <[email protected]>
20+
*/
21+
class Annotations extends AbstractReportsApi
22+
{
23+
/**
24+
* @param array $params
25+
*
26+
* @throws \Http\Client\Exception
27+
*
28+
* @return array
29+
*/
30+
public function list(array $params = [])
31+
{
32+
$path = $this->buildAnnotationsPath();
33+
34+
return $this->get($path, $params);
35+
}
36+
37+
/**
38+
* @param array $params
39+
*
40+
* @throws \Http\Client\Exception
41+
*
42+
* @return array
43+
*/
44+
public function create(array $params = [])
45+
{
46+
$path = $this->buildAnnotationsPath();
47+
48+
return $this->post($path, $params);
49+
}
50+
51+
/**
52+
* @param string $annotation
53+
* @param array $params
54+
*
55+
* @throws \Http\Client\Exception
56+
*
57+
* @return array
58+
*/
59+
public function show(string $annotation, array $params = [])
60+
{
61+
$path = $this->buildAnnotationsPath($annotation);
62+
63+
return $this->get($path, $params);
64+
}
65+
66+
/**
67+
* @param string $annotation
68+
* @param array $params
69+
*
70+
* @throws \Http\Client\Exception
71+
*
72+
* @return array
73+
*/
74+
public function update(string $annotation, array $params = [])
75+
{
76+
$path = $this->buildAnnotationsPath($annotation);
77+
78+
return $this->put($path, $params);
79+
}
80+
81+
/**
82+
* @param string $annotation
83+
* @param array $params
84+
*
85+
* @throws \Http\Client\Exception
86+
*
87+
* @return array
88+
*/
89+
public function remove(string $annotation, array $params = [])
90+
{
91+
$path = $this->buildAnnotationsPath($annotation);
92+
93+
return $this->delete($path, $params);
94+
}
95+
96+
/**
97+
* Annotations the build path from the given parts.
98+
*
99+
* @param string[] $parts
100+
*
101+
* @throws \Bitbucket\Exception\InvalidArgumentException
102+
*
103+
* @return string
104+
*/
105+
protected function buildAnnotationsPath(string ...$parts)
106+
{
107+
return static::buildPath('repositories', $this->workspace, $this->repo, 'commit', $this->commit, 'reports', 'annotations', ...$parts);
108+
}
109+
}

src/Api/Repositories/Workspaces/Deployments.php

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

1414
namespace Bitbucket\Api\Repositories\Workspaces;
1515

16+
use Bitbucket\Api\Repositories\Workspaces\Deployments\EnvironmentVariables;
17+
1618
/**
1719
* The deployments api class.
1820
*
@@ -49,6 +51,16 @@ public function show(string $deployments, array $params = [])
4951
return $this->get($path, $params);
5052
}
5153

54+
/**
55+
* @param string $environment
56+
*
57+
* @return \Bitbucket\Api\Repositories\Workspaces\Deployments\EnvironmentVariables
58+
*/
59+
public function environmentVariables(string $environment)
60+
{
61+
return new EnvironmentVariables($this->getHttpClient(), $this->workspace, $this->repo, $environment);
62+
}
63+
5264
/**
5365
* Build the deployments path from the given parts.
5466
*
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of 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\Repositories\Workspaces\Deployments;
15+
16+
use Bitbucket\Api\Repositories\Workspaces\AbstractWorkspacesApi;
17+
use Http\Client\Common\HttpMethodsClientInterface;
18+
19+
/**
20+
* The abstract deployments api class.
21+
*
22+
* @author Graham Campbell <[email protected]>
23+
*/
24+
abstract class AbstractDeploymentsApi extends AbstractWorkspacesApi
25+
{
26+
/**
27+
* The environment.
28+
*
29+
* @var string
30+
*/
31+
protected $environment;
32+
33+
/**
34+
* Create a new api instance.
35+
*
36+
* @param \Http\Client\Common\HttpMethodsClientInterface $client
37+
* @param string $workspace
38+
* @param string $repo
39+
* @param string $environment
40+
*/
41+
public function __construct(HttpMethodsClientInterface $client, string $workspace, string $repo, string $environment)
42+
{
43+
parent::__construct($client, $workspace, $repo);
44+
$this->environment = $environment;
45+
}
46+
}

0 commit comments

Comments
 (0)