Skip to content

Commit 39a550d

Browse files
committed
Merge branch 'release/1.1.0'
* release/1.1.0: Implemented Pipeline support Added $params arg to Repositories:all method (issue #65)
2 parents 0445ddd + 31ce7ea commit 39a550d

File tree

8 files changed

+414
-8
lines changed

8 files changed

+414
-8
lines changed

CHANGELOG.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
6+
## 1.1.0 / 2017-11-06
7+
8+
### Added:
9+
- Implemented [Pipeline] support. ( *thanks to @marco_veenendaal* )
10+
11+
### Changed:
12+
- Added $params arg to Repositories:all method (issue #65)
13+
14+
[Pipeline]: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pipelines
15+
16+
517
## 1.0.0 / 2017-06-12
618

719
### Added:
@@ -14,21 +26,23 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1426
- Minimum required PHP version has been bumped to 5.4 from 5.3
1527
- SSL certificate verification is now enabled by default.
1628
- `Api` constructor signature was modified in order to reflect removal of transport object dependency. (_@see Removed[2]_)
17-
29+
1830
### Removed:
1931
- Removed deprecated methods from `Api` (_childFactory, processResponse, authorize_)
2032
- Removed transport object dependency from `Api`.
21-
33+
2234
### Fixed:
2335
- NormalizeArrayListener should not run on `FormRequest` (issue #62)
2436
- [Tests] Use mocked HTTP client in `OAuth2ListenerTest:testGetAccessTokenFail`
2537

38+
2639
## 0.8.4 / 2017-05-15
2740

2841
### Fixed:
2942
- Updated broken links (_.org to .io_) inside README.md
3043
- Fixed broken tests on PHP 5.3 due to short array syntax.
3144

45+
3246
## 0.8.3 / 2017-05-15
3347

3448
### Fixed:
@@ -40,6 +54,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4054
### Fixed:
4155
- Added missing polyfill for "json_last_error_msg".
4256

57+
4358
## 0.8.1 / 2016-05-08
4459

4560
### Fixed:
@@ -54,11 +69,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5469
### Fixed:
5570
- Usage of short array syntax inside one test, forced the test suite to fail on PHP 5.3
5671

72+
5773
## 0.7.1 / 2015-11-07
5874

5975
### Fixed:
6076
- HTTP Client options where not forwarded to child classes. (PR #26)
6177

78+
6279
## 0.7.0 / 2015-09-08
6380

6481
### Added:
@@ -73,12 +90,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
7390
### Fixed:
7491
- `forking_policy` parameter renamed to `fork_policy` on repository endpoint. (issue #32)
7592

93+
7694
## 0.6.2 / 2015-05-18
7795

7896
### Fixed:
7997
- Client listener propagation to child classes. (PR #23)
8098

81-
## 0.6.1 / 2015-03-24
99+
100+
## 0.6.1 / 2015-03-24
82101

83102
### Changed:
84103
- Better parameters validation and type hints.
@@ -90,6 +109,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
90109
- `Listener::delListener` did not properly deleted the listener.
91110
- Forward all available listener when a child class is requested via Api::api or Api::childClass.
92111

112+
93113
## 0.6.0 / 2014-10-21
94114

95115
### Added:
@@ -105,18 +125,21 @@ This project adheres to [Semantic Versioning](http://semver.org/).
105125

106126
[Fixes #22]: https://bitbucket.org/gentlero/bitbucket-api/issue/22/grant-account-privileges-to-repo
107127

128+
108129
## 0.5.2 / 2014-07-09
109130

110131
### Fixed:
111132
- Make tests go green again. ( *My bad and I'm sorry* ).
112133

134+
113135
## 0.5.1 / 2014-07-08
114136

115137
### Fixed:
116138
- Bug: A default content-type is added for POST and PUT, if none was given. ( [Fixes #19] )
117139

118140
[Fixes #19]: https://bitbucket.org/gentlero/bitbucket-api/issue/19
119141

142+
120143
## 0.5.0 / 2014-06-09
121144

122145
### Added:
@@ -128,13 +151,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
128151
### Fixed:
129152
- Bug: Missing content-type made `PullRequests::merge` and `PullRequests::declined` unusable.
130153

154+
131155
## 0.4.1 / 2014-06-01
132156

133157
### Fixed:
134158
- Bug: OAuthListener: Parameters may be included from the body if the content-type is urlencoded. ( [Fixes #18] )
135159

136160
[Fixes #18]: https://bitbucket.org/gentlero/bitbucket-api/issue/18
137161

162+
138163
## 0.4.0 / 2014-05-14
139164

140165
### Added:
@@ -149,6 +174,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
149174
### Changed:
150175
- Documentation updated.
151176

177+
152178
## 0.3.0 / 2014-05-12
153179

154180
Started to implement version 2.0 of the API.
@@ -189,6 +215,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
189215

190216
[Fixes #14]: https://bitbucket.org/gentlero/bitbucket-api/issue/14
191217

218+
192219
## 0.1.2 / 2013-12-24
193220

194221
### Fixed:

lib/Bitbucket/API/Http/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Client extends ClientListener implements ClientInterface
3232
'api_versions' => array('1.0', '2.0'), // supported versions
3333
'format' => 'json',
3434
'formats' => array('json', 'xml'), // supported response formats
35-
'user_agent' => 'bitbucket-api-php/1.0.0 (https://bitbucket.org/gentlero/bitbucket-api)',
35+
'user_agent' => 'bitbucket-api-php/1.1.0 (https://bitbucket.org/gentlero/bitbucket-api)',
3636
'timeout' => 10,
3737
'verify_peer' => true
3838
);
@@ -268,7 +268,7 @@ protected function createRequest($method, $url)
268268
}
269269

270270
// change the response format
271-
if (strpos($url, 'format=') === false) {
271+
if ($this->getApiVersion() === '1.0' && strpos($url, 'format=') === false) {
272272
$url .= (strpos($url, '?') === false ? '?' : '&').'format='.$this->getResponseFormat();
273273
}
274274

lib/Bitbucket/API/Repositories.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,21 @@ class Repositories extends Api
2626
* - If `$owner` is omitted, will return a list of all public repositories on Bitbucket.
2727
*
2828
* @access public
29-
* @param string $owner The account of the repo owner.
29+
* @param string $owner The account of the repo owner.
30+
* @param array $params Additional parameters
3031
* @return MessageInterface
3132
*
3233
* @api 2.0
3334
* @since Method available since 0.2.0
3435
*/
35-
public function all($owner = null)
36+
public function all($owner = null, array $params = array())
3637
{
3738
$endpoint = 'repositories';
3839

3940
if (!is_null($owner)) {
4041
$endpoint = sprintf('repositories/%s', $owner);
4142
}
4243

43-
return $this->getClient()->setApiVersion('2.0')->get($endpoint);
44+
return $this->getClient()->setApiVersion('2.0')->get($endpoint, $params);
4445
}
4546
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the bitbucket-api package.
5+
*
6+
* (c) Alexandru G. <alex@gentle.ro>
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;
13+
14+
use Bitbucket\API\Api;
15+
use Buzz\Message\MessageInterface;
16+
17+
/**
18+
* Manage the pipelines of a repository
19+
*
20+
* @author Marco Veenendaal <marco@deinternetjongens.nl>
21+
*/
22+
class Pipelines extends Api
23+
{
24+
/**
25+
* Get the information associated with a repository's pipelines
26+
*
27+
* @access public
28+
* @param string $account The team or individual account owning the repository.
29+
* @param string $repo The repository identifier.
30+
* @return MessageInterface
31+
*/
32+
public function all($account, $repo)
33+
{
34+
return $this->getClient()->setApiVersion('2.0')->get(
35+
sprintf('repositories/%s/%s/pipelines/', $account, $repo)
36+
);
37+
}
38+
39+
/**
40+
* Creates a pipeline for the specified repository.
41+
*
42+
* @access public
43+
* @param string $account The team or individual account owning the repository.
44+
* @param string $repo The repository identifier.
45+
* @param array|string $params Additional parameters as array or JSON string
46+
* @return MessageInterface
47+
*/
48+
public function create($account, $repo, $params = array())
49+
{
50+
// allow developer to directly specify params as json if (s)he wants.
51+
if ('array' !== gettype($params)) {
52+
if (empty($params)) {
53+
throw new \InvalidArgumentException('Invalid JSON provided.');
54+
}
55+
56+
$params = $this->decodeJSON($params);
57+
}
58+
59+
return $this->getClient()->setApiVersion('2.0')->post(
60+
sprintf('repositories/%s/%s/pipelines/', $account, $repo),
61+
json_encode($params),
62+
array('Content-Type' => 'application/json')
63+
);
64+
}
65+
66+
/**
67+
* Get a specific pipeline
68+
*
69+
* @access public
70+
* @param string $account The team or individual account owning the repository.
71+
* @param string $repo The repository identifier.
72+
* @param string $uuid The pipeline's identifier.
73+
* @return MessageInterface
74+
*/
75+
public function get($account, $repo, $uuid)
76+
{
77+
return $this->getClient()->setApiVersion('2.0')->get(
78+
sprintf('repositories/%s/%s/pipelines/%s', $account, $repo, $uuid)
79+
);
80+
}
81+
82+
/**
83+
* Stop a specific pipeline
84+
*
85+
* @access public
86+
* @param string $account The team or individual account owning the repository.
87+
* @param string $repo The repository identifier.
88+
* @param string $uuid The pipeline's identifier.
89+
* @return MessageInterface
90+
*/
91+
public function stopPipeline($account, $repo, $uuid)
92+
{
93+
return $this->getClient()->setApiVersion('2.0')->post(
94+
sprintf('repositories/%s/%s/pipelines/%s/stopPipeline', $account, $repo, $uuid)
95+
);
96+
}
97+
98+
/**
99+
* Get steps
100+
*
101+
* @access public
102+
* @return Pipelines\Steps
103+
*
104+
* @throws \InvalidArgumentException
105+
* @codeCoverageIgnore
106+
*/
107+
public function steps()
108+
{
109+
return $this->api('Repositories\\Pipelines\\Steps');
110+
}
111+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the bitbucket-api package.
5+
*
6+
* (c) Alexandru G. <alex@gentle.ro>
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\Pipelines;
13+
14+
use Bitbucket\API;
15+
use Buzz\Message\MessageInterface;
16+
17+
/**
18+
* Manage the steps of a pipeline.
19+
*
20+
* @author Marco Veenendaal <marco@deinternetjongens.nl>
21+
*/
22+
class Steps extends API\Api
23+
{
24+
/**
25+
* Get a list of all pipeline steps
26+
*
27+
* @access public
28+
* @param string $account The team or individual account owning the repository.
29+
* @param string $repo The repository identifier.
30+
* @param string $pipelineUuid UUID of the pipeline.
31+
* @return MessageInterface
32+
*/
33+
public function all($account, $repo, $pipelineUuid)
34+
{
35+
return $this->getClient()->setApiVersion('2.0')->get(
36+
sprintf('repositories/%s/%s/pipelines/%s/steps/', $account, $repo, $pipelineUuid)
37+
);
38+
}
39+
40+
/**
41+
* Get an individual pipeline step
42+
*
43+
* @access public
44+
* @param string $account The team or individual account owning the repository.
45+
* @param string $repo The repository identifier.
46+
* @param string $pipelineUuid UUID of the pipeline.
47+
* @param string $stepUuid UUID of the step.
48+
* @return MessageInterface
49+
*/
50+
public function get($account, $repo, $pipelineUuid, $stepUuid)
51+
{
52+
return $this->getClient()->setApiVersion('2.0')->get(
53+
sprintf('repositories/%s/%s/pipelines/%s/steps/%s', $account, $repo, $pipelineUuid, $stepUuid)
54+
);
55+
}
56+
57+
/**
58+
* Get the log of an individual pipeline step
59+
*
60+
* @access public
61+
* @param string $account The team or individual account owning the repository.
62+
* @param string $repo The repository identifier.
63+
* @param string $pipelineUuid UUID of the pipeline.
64+
* @param string $stepUuid UUID of the step.
65+
* @return MessageInterface
66+
*/
67+
public function log($account, $repo, $pipelineUuid, $stepUuid)
68+
{
69+
return $this->getClient()->setApiVersion('2.0')->get(
70+
sprintf('repositories/%s/%s/pipelines/%s/steps/%s/log', $account, $repo, $pipelineUuid, $stepUuid)
71+
);
72+
}
73+
}

0 commit comments

Comments
 (0)