Skip to content

Commit eaf5614

Browse files
authored
Merge branch 'master' into master
2 parents c8073db + a60b54d commit eaf5614

37 files changed

+1482
-278
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ You get the idea! Take a look around ([API methods](https://github.com/m4tthumph
9999
Framework Integrations
100100
----------------------
101101
- **Symfony** - https://github.com/Zeichen32/GitLabApiBundle
102-
- **Laravel** - https://github.com/vinkla/laravel-gitlab
102+
- **Laravel** - https://github.com/GrahamCampbell/Laravel-GitLab
103103

104104
If you have integrated GitLab into a popular PHP framework, let us know!
105105

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"require": {
2424
"php": "^5.6 || ^7.0",
2525
"ext-xml": "*",
26-
"php-http/client-common": "^1.5",
26+
"php-http/client-common": "^1.6",
2727
"php-http/client-implementation": "^1.0",
2828
"php-http/discovery": "^1.2",
2929
"php-http/httplug": "^1.1",
@@ -34,7 +34,7 @@
3434
"guzzlehttp/psr7": "^1.2",
3535
"php-http/guzzle6-adapter": "^1.0",
3636
"php-http/mock-client": "^1.0",
37-
"phpunit/phpunit": "~4.5"
37+
"phpunit/phpunit": "^5.0"
3838
},
3939
"autoload": {
4040
"psr-4": { "Gitlab\\": "lib/Gitlab/" }
@@ -44,7 +44,7 @@
4444
},
4545
"extra": {
4646
"branch-alias": {
47-
"dev-master": "9.0.x-dev"
47+
"dev-master": "9.8.x-dev"
4848
}
4949
}
5050
}

doc/customize.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ As timeout configuration is not compatible with HTTP client abstraction, you hav
2121
an explicit HTTP client implementation.
2222

2323
```php
24-
$httpClient = Http\Adapter\Guzzle6::createWithConfig([
24+
$httpClient = Http\Adapter\Guzzle6\Client::createWithConfig([
2525
'timeout' => 1.0
2626
]);
2727
$client = Gitlab\Client::createWithHttpClient($httpClient);

lib/Gitlab/Api/AbstractApi.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Http\Message\MultipartStream\MultipartStreamBuilder;
99
use Http\Message\StreamFactory;
1010
use Psr\Http\Message\ResponseInterface;
11+
use Psr\Http\Message\StreamInterface;
1112
use Symfony\Component\OptionsResolver\OptionsResolver;
1213

1314
/**
@@ -89,7 +90,7 @@ protected function post($path, array $parameters = array(), $requestHeaders = ar
8990

9091
$body = null;
9192
if (empty($files) && !empty($parameters)) {
92-
$body = $this->streamFactory->createStream(QueryStringBuilder::build($parameters));
93+
$body = $this->prepareBody($parameters);
9394
$requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
9495
} elseif (!empty($files)) {
9596
$builder = new MultipartStreamBuilder($this->streamFactory);
@@ -128,7 +129,7 @@ protected function put($path, array $parameters = array(), $requestHeaders = arr
128129

129130
$body = null;
130131
if (!empty($parameters)) {
131-
$body = $this->streamFactory->createStream(http_build_query($parameters));
132+
$body = $this->prepareBody($parameters);
132133
$requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
133134
}
134135

@@ -197,6 +198,18 @@ protected function createOptionsResolver()
197198
return $resolver;
198199
}
199200

201+
/**
202+
* @param array $parameters
203+
* @return StreamInterface
204+
*/
205+
private function prepareBody(array $parameters = [])
206+
{
207+
$raw = QueryStringBuilder::build($parameters);
208+
$stream = $this->streamFactory->createStream($raw);
209+
210+
return $stream;
211+
}
212+
200213
private function preparePath($path, array $parameters = [])
201214
{
202215
if (count($parameters) > 0) {

lib/Gitlab/Api/Environments.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,14 @@ public function remove($project_id, $environment_id)
4545
{
4646
return $this->delete($this->getProjectPath($project_id, 'environments/' . $environment_id));
4747
}
48+
49+
/**
50+
* @param int $project_id
51+
* @param string $environment_id
52+
* @return mixed
53+
*/
54+
public function stop($project_id, $environment_id)
55+
{
56+
return $this->post($this->getProjectPath($project_id, 'environments/'.$this->encodePath($environment_id).'/stop'));
57+
}
4858
}

lib/Gitlab/Api/Groups.php

Lines changed: 74 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php namespace Gitlab\Api;
22

3+
use Symfony\Component\OptionsResolver\Options;
4+
35
class Groups extends AbstractApi
46
{
57
/**
@@ -17,36 +19,7 @@ class Groups extends AbstractApi
1719
*/
1820
public function all(array $parameters = [])
1921
{
20-
$resolver = $this->createOptionsResolver();
21-
$booleanNormalizer = function ($value) {
22-
return $value ? 'true' : 'false';
23-
};
24-
25-
$resolver->setDefined('skip_groups')
26-
->setAllowedTypes('skip_groups', 'array')
27-
->setAllowedValues('skip_groups', function (array $value) {
28-
return count($value) == count(array_filter($value, 'is_int'));
29-
})
30-
;
31-
$resolver->setDefined('all_available')
32-
->setAllowedTypes('all_available', 'bool')
33-
->setNormalizer('all_available', $booleanNormalizer)
34-
;
35-
$resolver->setDefined('search');
36-
$resolver->setDefined('order_by')
37-
->setAllowedValues('order_by', ['name', 'path'])
38-
;
39-
$resolver->setDefined('sort')
40-
->setAllowedValues('sort', ['asc', 'desc'])
41-
;
42-
$resolver->setDefined('statistics')
43-
->setAllowedTypes('statistics', 'bool')
44-
->setNormalizer('statistics', $booleanNormalizer)
45-
;
46-
$resolver->setDefined('owned')
47-
->setAllowedTypes('owned', 'bool')
48-
->setNormalizer('owned', $booleanNormalizer)
49-
;
22+
$resolver = $this->getGroupSearchResolver();
5023

5124
return $this->get('groups', $resolver->resolve($parameters));
5225
}
@@ -65,16 +38,26 @@ public function show($id)
6538
* @param string $path
6639
* @param string $description
6740
* @param string $visibility
41+
* @param bool $lfs_enabled
42+
* @param bool $request_access_enabled
43+
* @param int $parent_id
44+
* @param int $shared_runners_minutes_limit
6845
* @return mixed
6946
*/
70-
public function create($name, $path, $description = null, $visibility = 'private')
47+
public function create($name, $path, $description = null, $visibility = 'private', $lfs_enabled = null, $request_access_enabled = null, $parent_id = null, $shared_runners_minutes_limit = null)
7148
{
72-
return $this->post('groups', array(
49+
$params = array(
7350
'name' => $name,
7451
'path' => $path,
7552
'description' => $description,
7653
'visibility' => $visibility,
77-
));
54+
'lfs_enabled' => $lfs_enabled,
55+
'request_access_enabled' => $request_access_enabled,
56+
'parent_id' => $parent_id,
57+
'shared_runners_minutes_limit' => $shared_runners_minutes_limit,
58+
);
59+
60+
return $this->post('groups', array_filter($params, 'strlen'));
7861
}
7962

8063
/**
@@ -180,7 +163,7 @@ public function removeMember($group_id, $user_id)
180163
public function projects($id, array $parameters = [])
181164
{
182165
$resolver = $this->createOptionsResolver();
183-
$booleanNormalizer = function ($value) {
166+
$booleanNormalizer = function (Options $resolver, $value) {
184167
return $value ? 'true' : 'false';
185168
};
186169

@@ -213,4 +196,61 @@ public function projects($id, array $parameters = [])
213196

214197
return $this->get('groups/'.$this->encodePath($id).'/projects', $resolver->resolve($parameters));
215198
}
199+
200+
/**
201+
* @param int $groupId
202+
* @param array $parameters (
203+
*
204+
* @var int[] $skip_groups Skip the group IDs passes.
205+
* @var bool $all_available Show all the groups you have access to.
206+
* @var string $search Return list of authorized groups matching the search criteria.
207+
* @var string $order_by Order groups by name or path. Default is name.
208+
* @var string $sort Order groups in asc or desc order. Default is asc.
209+
* @var bool $statistics Include group statistics (admins only).
210+
* @var bool $owned Limit by groups owned by the current user.
211+
* )
212+
* @return mixed
213+
*/
214+
public function subgroups($groupId, array $parameters = [])
215+
{
216+
$resolver = $this->getGroupSearchResolver();
217+
218+
return $this->get('groups/'.$this->encodePath($groupId).'/subgroups', $resolver->resolve($parameters));
219+
}
220+
221+
private function getGroupSearchResolver()
222+
{
223+
$resolver = $this->createOptionsResolver();
224+
$booleanNormalizer = function (Options $resolver, $value) {
225+
return $value ? 'true' : 'false';
226+
};
227+
228+
$resolver->setDefined('skip_groups')
229+
->setAllowedTypes('skip_groups', 'array')
230+
->setAllowedValues('skip_groups', function (array $value) {
231+
return count($value) == count(array_filter($value, 'is_int'));
232+
})
233+
;
234+
$resolver->setDefined('all_available')
235+
->setAllowedTypes('all_available', 'bool')
236+
->setNormalizer('all_available', $booleanNormalizer)
237+
;
238+
$resolver->setDefined('search');
239+
$resolver->setDefined('order_by')
240+
->setAllowedValues('order_by', ['name', 'path'])
241+
;
242+
$resolver->setDefined('sort')
243+
->setAllowedValues('sort', ['asc', 'desc'])
244+
;
245+
$resolver->setDefined('statistics')
246+
->setAllowedTypes('statistics', 'bool')
247+
->setNormalizer('statistics', $booleanNormalizer)
248+
;
249+
$resolver->setDefined('owned')
250+
->setAllowedTypes('owned', 'bool')
251+
->setNormalizer('owned', $booleanNormalizer)
252+
;
253+
254+
return $resolver;
255+
}
216256
}

lib/Gitlab/Api/IssueBoards.php

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,47 @@ public function all($project_id = null, array $parameters = [])
1717
return $this->get($path, $resolver->resolve($parameters));
1818
}
1919

20+
/**
21+
* @param int $project_id
22+
* @param int $board_id
23+
* @return mixed
24+
*/
25+
public function show($project_id, $board_id)
26+
{
27+
return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id)));
28+
}
29+
30+
/**
31+
* @param int $project_id
32+
* @param array $params
33+
* @return mixed
34+
*/
35+
public function create($project_id, array $params)
36+
{
37+
return $this->post($this->getProjectPath($project_id, 'boards'), $params);
38+
}
39+
40+
/**
41+
* @param int $project_id
42+
* @param int $board_id
43+
* @param array $params
44+
* @return mixed
45+
*/
46+
public function update($project_id, $board_id, array $params)
47+
{
48+
return $this->put($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id)), $params);
49+
}
50+
51+
/**
52+
* @param int $project_id
53+
* @param int $board_id
54+
* @return mixed
55+
*/
56+
public function remove($project_id, $board_id)
57+
{
58+
return $this->delete($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id)));
59+
}
60+
2061
/**
2162
* @param int $project_id
2263
* @param int $board_id
@@ -27,7 +68,6 @@ public function allLists($project_id, $board_id)
2768
return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists'));
2869
}
2970

30-
3171
/**
3272
* @param int $project_id
3373
* @param int $board_id
@@ -36,7 +76,7 @@ public function allLists($project_id, $board_id)
3676
*/
3777
public function showList($project_id, $board_id, $list_id)
3878
{
39-
return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists'.$this->encodePath($list_id)));
79+
return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists/'.$this->encodePath($list_id)));
4080
}
4181

4282
/**
@@ -48,12 +88,10 @@ public function showList($project_id, $board_id, $list_id)
4888
public function createList($project_id, $board_id, $label_id)
4989
{
5090
$params = array(
51-
'id' => $project_id,
52-
'board_id' => $board_id,
5391
'label_id' => $label_id
5492
);
5593

56-
return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists'), $params);
94+
return $this->post($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists'), $params);
5795
}
5896

5997
/**
@@ -66,9 +104,6 @@ public function createList($project_id, $board_id, $label_id)
66104
public function updateList($project_id, $board_id, $list_id, $position)
67105
{
68106
$params = array(
69-
'id' => $project_id,
70-
'board_id' => $board_id,
71-
'list_id' => $list_id,
72107
'position' => $position
73108
);
74109

lib/Gitlab/Api/Jobs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function artifacts($project_id, $job_id)
8181
public function artifactsByRefName($project_id, $ref_name, $job_name)
8282
{
8383
return $this->getAsResponse("projects/".$this->encodePath($project_id)."/jobs/artifacts/".$this->encodePath($ref_name)."/download", array(
84-
'job' => $job_name
84+
'job' => $this->encodePath($job_name)
8585
))->getBody();
8686
}
8787

0 commit comments

Comments
 (0)