Skip to content

Commit 64da1e9

Browse files
Merge branch '11.12' into 11.13
2 parents 7c6856b + f26dd45 commit 64da1e9

File tree

5 files changed

+101
-7
lines changed

5 files changed

+101
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [11.12.0] - 2023-10-XX
99

1010
* Add PHP 8.3 support
11-
* Add support for `environment_scope` in `Project::removeVariable`
11+
* Add `Projects::updateProtectedBranch` and `Projects::updateApprovalsConfiguration`
12+
* Add support for `environment_scope` in `Projects::removeVariable`
13+
* Add support for `filter` in `Projects::variable`
1214
* Add support for `author` in `Repositories::commits`
15+
* Add support for additional parameters in `Projects::labels` and `Groups::labels`
1316

14-
## [11.11.1] - 2023-10-XX
17+
## [11.11.1] - 2023-10-08
1518

1619
* Fixed double encoding of job name in artifacts download
1720

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ composer require "m4tthumphrey/php-gitlab-api:^11.13" \
3737
#### Laravel:
3838

3939
```bash
40-
$ composer require "graham-campbell/gitlab:^7.5"
40+
$ composer require "graham-campbell/gitlab:^7.4"
4141
```
4242

4343
#### Symfony:

src/Api/AbstractApi.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,33 @@ protected function put(string $uri, array $params = [], array $headers = [], arr
163163
return ResponseMediator::getContent($response);
164164
}
165165

166+
/**
167+
* @param string $uri
168+
* @param array<string,mixed> $params
169+
* @param array<string,string> $headers
170+
* @param array<string,string> $files
171+
*
172+
* @return mixed
173+
*/
174+
protected function patch(string $uri, array $params = [], array $headers = [], array $files = [])
175+
{
176+
if (0 < \count($files)) {
177+
$builder = $this->createMultipartStreamBuilder($params, $files);
178+
$body = self::prepareMultipartBody($builder);
179+
$headers = self::addMultipartContentType($headers, $builder);
180+
} else {
181+
$body = self::prepareJsonBody($params);
182+
183+
if (null !== $body) {
184+
$headers = self::addJsonContentType($headers);
185+
}
186+
}
187+
188+
$response = $this->client->getHttpClient()->patch(self::prepareUri($uri), $headers, $body ?? '');
189+
190+
return ResponseMediator::getContent($response);
191+
}
192+
166193
/**
167194
* @param string $uri
168195
* @param string $file

src/Api/Groups.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,36 @@ public function issues($group_id, array $parameters = [])
506506

507507
/**
508508
* @param int|string $group_id
509-
* @param array $parameters
509+
* @param array $parameters {
510+
*
511+
* @var bool $with_counts Whether or not to include issue and merge request counts. Defaults to false.
512+
* @var bool $include_ancestor_groups Include ancestor groups. Defaults to true.
513+
* @var bool $include_descendant_groups Include descendant groups. Defaults to false.
514+
* @var bool $only_group_labels Toggle to include only group labels or also project labels. Defaults to true.
515+
* @var string $search Keyword to filter labels by.
516+
* }
510517
*
511518
* @return mixed
512519
*/
513520
public function labels($group_id, array $parameters = [])
514521
{
515522
$resolver = $this->createOptionsResolver();
516523

524+
$resolver->setDefined('with_counts')
525+
->setAllowedTypes('with_counts', 'bool');
526+
527+
$resolver->setDefined('include_ancestor_groups')
528+
->setAllowedTypes('include_ancestor_groups', 'bool');
529+
530+
$resolver->setDefined('include_descendant_groups')
531+
->setAllowedTypes('include_descendant_groups', 'bool');
532+
533+
$resolver->setDefined('only_group_labels')
534+
->setAllowedTypes('only_group_labels', 'bool');
535+
536+
$resolver->setDefined('search')
537+
->setAllowedTypes('search', 'string');
538+
517539
return $this->get('groups/'.self::encodePath($group_id).'/labels', $resolver->resolve($parameters));
518540
}
519541

src/Api/Projects.php

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,14 +976,28 @@ public function events($project_id, array $parameters = [])
976976

977977
/**
978978
* @param int|string $project_id
979-
* @param array $parameters
979+
* @param array $parameters {
980+
*
981+
* @var bool $with_counts Whether or not to include issue and merge request counts. Defaults to false.
982+
* @var bool $include_ancestor_groups Include ancestor groups. Defaults to true.
983+
* @var string $search Keyword to filter labels by.
984+
* }
980985
*
981986
* @return mixed
982987
*/
983988
public function labels($project_id, array $parameters = [])
984989
{
985990
$resolver = $this->createOptionsResolver();
986991

992+
$resolver->setDefined('with_counts')
993+
->setAllowedTypes('with_counts', 'bool');
994+
995+
$resolver->setDefined('include_ancestor_groups')
996+
->setAllowedTypes('include_ancestor_groups', 'bool');
997+
998+
$resolver->setDefined('search')
999+
->setAllowedTypes('search', 'string');
1000+
9871001
return $this->get($this->getProjectPath($project_id, 'labels'), $resolver->resolve($parameters));
9881002
}
9891003

@@ -1214,12 +1228,17 @@ public function variables($project_id, array $parameters = [])
12141228
/**
12151229
* @param int|string $project_id
12161230
* @param string $key
1231+
* @param array $parameters
12171232
*
12181233
* @return mixed
12191234
*/
1220-
public function variable($project_id, string $key)
1235+
public function variable($project_id, string $key, array $parameters = [])
12211236
{
1222-
return $this->get($this->getProjectPath($project_id, 'variables/'.self::encodePath($key)));
1237+
$resolver = $this->createOptionsResolver();
1238+
$resolver->setDefined('filter')
1239+
->setAllowedTypes('filter', 'array');
1240+
1241+
return $this->get($this->getProjectPath($project_id, 'variables/'.self::encodePath($key)), $resolver->resolve($parameters));
12231242
}
12241243

12251244
/**
@@ -1527,6 +1546,18 @@ public function deleteProtectedBranch($project_id, string $branch_name)
15271546
return $this->delete($this->getProjectPath($project_id, 'protected_branches/'.self::encodePath($branch_name)));
15281547
}
15291548

1549+
/**
1550+
* @param int|string $project_id
1551+
* @param string $branch_name
1552+
* @param array $parameters
1553+
*
1554+
* @return mixed
1555+
*/
1556+
public function updateProtectedBranch($project_id, string $branch_name, array $parameters = [])
1557+
{
1558+
return $this->patch($this->getProjectPath($project_id, 'protected_branches/'.self::encodePath($branch_name)), $parameters);
1559+
}
1560+
15301561
/**
15311562
* @param int|string $project_id
15321563
*
@@ -1537,6 +1568,17 @@ public function approvalsConfiguration($project_id)
15371568
return $this->get('projects/'.self::encodePath($project_id).'/approvals');
15381569
}
15391570

1571+
/**
1572+
* @param int|string $project_id
1573+
* @param array $parameters
1574+
*
1575+
* @return mixed
1576+
*/
1577+
public function updateApprovalsConfiguration($project_id, array $parameters = [])
1578+
{
1579+
return $this->post('projects/'.self::encodePath($project_id).'/approvals', $parameters);
1580+
}
1581+
15401582
/**
15411583
* @param int|string $project_id
15421584
*

0 commit comments

Comments
 (0)