1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the bitbucket-api package. |
5
|
|
|
* |
6
|
|
|
* (c) Alexandru G. <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Bitbucket\API\Repositories\Commits; |
13
|
|
|
|
14
|
|
|
use Bitbucket\API\Api; |
15
|
|
|
use Psr\Http\Message\ResponseInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Brice M. <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class BuildStatuses extends Api |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Returns the status for specific build associated with a commit. |
24
|
|
|
* |
25
|
|
|
* @access public |
26
|
|
|
* @param string $account The team or individual account owning the repository. |
27
|
|
|
* @param string $repository The repository identifier. |
28
|
|
|
* @param string $revision A SHA1 value for the commit. |
29
|
|
|
* @param string $key The key that distinguishes the build status from others. |
30
|
|
|
* @return ResponseInterface |
31
|
|
|
* |
32
|
|
|
* @see https://confluence.atlassian.com/bitbucket/buildstatus-resource-779295267.html |
33
|
|
|
*/ |
34
|
1 |
|
public function get($account, $repository, $revision, $key) |
35
|
|
|
{ |
36
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
37
|
1 |
|
sprintf('/repositories/%s/%s/commit/%s/statuses/build/%s', $account, $repository, $revision, $key) |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Adds a build status to a commit. |
43
|
|
|
* If the build is already associated with the commit, a POST also updates the status. |
44
|
|
|
* |
45
|
|
|
* @access public |
46
|
|
|
* @param string $account The team or individual account owning the repository. |
47
|
|
|
* @param string $repository The repository identifier. |
48
|
|
|
* @param string $revision A SHA1 value for the commit. |
49
|
|
|
* @param array $params The status. |
50
|
|
|
* @return ResponseInterface |
51
|
|
|
* |
52
|
|
|
* @see https://confluence.atlassian.com/bitbucket/buildstatus-resource-779295267.html |
53
|
|
|
*/ |
54
|
1 |
|
public function create($account, $repository, $revision, $params) |
55
|
|
|
{ |
56
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->post( |
57
|
1 |
|
sprintf('/repositories/%s/%s/commit/%s/statuses/build', $account, $repository, $revision), |
58
|
1 |
|
json_encode($params), |
59
|
1 |
|
array('Content-Type' => 'application/json') |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Updates the build status for a commit. |
65
|
|
|
* |
66
|
|
|
* @access public |
67
|
|
|
* @param string $account The team or individual account owning the repository. |
68
|
|
|
* @param string $repository The repository identifier. |
69
|
|
|
* @param string $revision A SHA1 value for the commit. |
70
|
|
|
* @param string $key The key that distinguishes the build status from others. |
71
|
|
|
* @param array $params The status. |
72
|
|
|
* @return ResponseInterface |
73
|
|
|
* |
74
|
|
|
* @see https://confluence.atlassian.com/bitbucket/buildstatus-resource-779295267.html |
75
|
|
|
*/ |
76
|
1 |
|
public function update($account, $repository, $revision, $key, $params) |
77
|
|
|
{ |
78
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->put( |
79
|
1 |
|
sprintf('/repositories/%s/%s/commit/%s/statuses/build/%s', $account, $repository, $revision, $key), |
80
|
1 |
|
json_encode($params), |
81
|
1 |
|
array('Content-Type' => 'application/json') |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|