Skip to content

Commit

Permalink
Merge branch '11.12' into 11.13
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Oct 8, 2023
2 parents 7c6856b + f26dd45 commit 64da1e9
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 7 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [11.12.0] - 2023-10-XX

* Add PHP 8.3 support
* Add support for `environment_scope` in `Project::removeVariable`
* Add `Projects::updateProtectedBranch` and `Projects::updateApprovalsConfiguration`
* Add support for `environment_scope` in `Projects::removeVariable`
* Add support for `filter` in `Projects::variable`
* Add support for `author` in `Repositories::commits`
* Add support for additional parameters in `Projects::labels` and `Groups::labels`

## [11.11.1] - 2023-10-XX
## [11.11.1] - 2023-10-08

* Fixed double encoding of job name in artifacts download

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ composer require "m4tthumphrey/php-gitlab-api:^11.13" \
#### Laravel:

```bash
$ composer require "graham-campbell/gitlab:^7.5"
$ composer require "graham-campbell/gitlab:^7.4"
```

#### Symfony:
Expand Down
27 changes: 27 additions & 0 deletions src/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,33 @@ protected function put(string $uri, array $params = [], array $headers = [], arr
return ResponseMediator::getContent($response);
}

/**
* @param string $uri
* @param array<string,mixed> $params
* @param array<string,string> $headers
* @param array<string,string> $files
*
* @return mixed
*/
protected function patch(string $uri, array $params = [], array $headers = [], array $files = [])
{
if (0 < \count($files)) {
$builder = $this->createMultipartStreamBuilder($params, $files);
$body = self::prepareMultipartBody($builder);
$headers = self::addMultipartContentType($headers, $builder);
} else {
$body = self::prepareJsonBody($params);

if (null !== $body) {
$headers = self::addJsonContentType($headers);
}
}

$response = $this->client->getHttpClient()->patch(self::prepareUri($uri), $headers, $body ?? '');

return ResponseMediator::getContent($response);
}

/**
* @param string $uri
* @param string $file
Expand Down
24 changes: 23 additions & 1 deletion src/Api/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,14 +506,36 @@ public function issues($group_id, array $parameters = [])

/**
* @param int|string $group_id
* @param array $parameters
* @param array $parameters {
*
* @var bool $with_counts Whether or not to include issue and merge request counts. Defaults to false.
* @var bool $include_ancestor_groups Include ancestor groups. Defaults to true.
* @var bool $include_descendant_groups Include descendant groups. Defaults to false.
* @var bool $only_group_labels Toggle to include only group labels or also project labels. Defaults to true.
* @var string $search Keyword to filter labels by.
* }
*
* @return mixed
*/
public function labels($group_id, array $parameters = [])
{
$resolver = $this->createOptionsResolver();

$resolver->setDefined('with_counts')
->setAllowedTypes('with_counts', 'bool');

$resolver->setDefined('include_ancestor_groups')
->setAllowedTypes('include_ancestor_groups', 'bool');

$resolver->setDefined('include_descendant_groups')
->setAllowedTypes('include_descendant_groups', 'bool');

$resolver->setDefined('only_group_labels')
->setAllowedTypes('only_group_labels', 'bool');

$resolver->setDefined('search')
->setAllowedTypes('search', 'string');

return $this->get('groups/'.self::encodePath($group_id).'/labels', $resolver->resolve($parameters));
}

Expand Down
48 changes: 45 additions & 3 deletions src/Api/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -976,14 +976,28 @@ public function events($project_id, array $parameters = [])

/**
* @param int|string $project_id
* @param array $parameters
* @param array $parameters {
*
* @var bool $with_counts Whether or not to include issue and merge request counts. Defaults to false.
* @var bool $include_ancestor_groups Include ancestor groups. Defaults to true.
* @var string $search Keyword to filter labels by.
* }
*
* @return mixed
*/
public function labels($project_id, array $parameters = [])
{
$resolver = $this->createOptionsResolver();

$resolver->setDefined('with_counts')
->setAllowedTypes('with_counts', 'bool');

$resolver->setDefined('include_ancestor_groups')
->setAllowedTypes('include_ancestor_groups', 'bool');

$resolver->setDefined('search')
->setAllowedTypes('search', 'string');

return $this->get($this->getProjectPath($project_id, 'labels'), $resolver->resolve($parameters));
}

Expand Down Expand Up @@ -1214,12 +1228,17 @@ public function variables($project_id, array $parameters = [])
/**
* @param int|string $project_id
* @param string $key
* @param array $parameters
*
* @return mixed
*/
public function variable($project_id, string $key)
public function variable($project_id, string $key, array $parameters = [])
{
return $this->get($this->getProjectPath($project_id, 'variables/'.self::encodePath($key)));
$resolver = $this->createOptionsResolver();
$resolver->setDefined('filter')
->setAllowedTypes('filter', 'array');

return $this->get($this->getProjectPath($project_id, 'variables/'.self::encodePath($key)), $resolver->resolve($parameters));
}

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

/**
* @param int|string $project_id
* @param string $branch_name
* @param array $parameters
*
* @return mixed
*/
public function updateProtectedBranch($project_id, string $branch_name, array $parameters = [])
{
return $this->patch($this->getProjectPath($project_id, 'protected_branches/'.self::encodePath($branch_name)), $parameters);
}

/**
* @param int|string $project_id
*
Expand All @@ -1537,6 +1568,17 @@ public function approvalsConfiguration($project_id)
return $this->get('projects/'.self::encodePath($project_id).'/approvals');
}

/**
* @param int|string $project_id
* @param array $parameters
*
* @return mixed
*/
public function updateApprovalsConfiguration($project_id, array $parameters = [])
{
return $this->post('projects/'.self::encodePath($project_id).'/approvals', $parameters);
}

/**
* @param int|string $project_id
*
Expand Down

0 comments on commit 64da1e9

Please sign in to comment.