Skip to content

Commit 04abd73

Browse files
GrahamCampbellglaubinixStyleCIBot
authored
[12.1] Add group show parameters (#870)
* Add parameters to group show API Co-authored-by: Stephan Vock <442056+glaubinix@users.noreply.github.com> * Apply fixes from StyleCI --------- Co-authored-by: Stephan Vock <442056+glaubinix@users.noreply.github.com> Co-authored-by: StyleCI Bot <bot@styleci.io>
1 parent f2e1f81 commit 04abd73

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
* Add support for `without_project_bots` in `Users::all`
1818
* Add support for date filters and `finished_at` ordering in `Deployments::all`
1919
* Add support for listing merge requests associated with a deployment
20+
* Add support for `with_custom_attributes` and `with_projects` in `Groups::show`
2021

2122

2223
## [12.0.0] - 2025-02-23

src/Api/Groups.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,30 @@ public function all(array $parameters = []): mixed
6868
return $this->get('groups', $resolver->resolve($parameters));
6969
}
7070

71-
public function show(int|string $id): mixed
71+
/**
72+
* @param array $parameters {
73+
*
74+
* @var bool $with_custom_attributes include custom attributes in response
75+
* @var bool $with_projects Include details from projects that belong to the group.
76+
* }
77+
*/
78+
public function show(int|string $id, array $parameters = []): mixed
7279
{
73-
return $this->get('groups/'.self::encodePath($id));
80+
$resolver = $this->createOptionsResolver();
81+
$booleanNormalizer = function (Options $resolver, $value): string {
82+
return $value ? 'true' : 'false';
83+
};
84+
85+
$resolver->setDefined('with_custom_attributes')
86+
->setAllowedTypes('with_custom_attributes', 'bool')
87+
->setNormalizer('with_custom_attributes', $booleanNormalizer)
88+
;
89+
$resolver->setDefined('with_projects')
90+
->setAllowedTypes('with_projects', 'bool')
91+
->setNormalizer('with_projects', $booleanNormalizer)
92+
;
93+
94+
return $this->get('groups/'.self::encodePath($id), $resolver->resolve($parameters));
7495
}
7596

7697
public function create(string $name, string $path, ?string $description = null, string $visibility = 'private', ?bool $lfs_enabled = null, ?bool $request_access_enabled = null, ?int $parent_id = null, ?int $shared_runners_minutes_limit = null): mixed

tests/Api/GroupsTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,22 @@ public function shouldShowGroup(): void
143143
$this->assertEquals($expectedArray, $api->show(1));
144144
}
145145

146+
#[Test]
147+
public function shouldShowGroupWithAdditionalParameters(): void
148+
{
149+
$expectedArray = ['id' => 1, 'name' => 'A group'];
150+
$parameters = ['with_custom_attributes' => true, 'with_projects' => false];
151+
152+
$api = $this->getApiMock();
153+
$api->expects($this->once())
154+
->method('get')
155+
->with('groups/1', ['with_custom_attributes' => 'true', 'with_projects' => 'false'])
156+
->willReturn($expectedArray)
157+
;
158+
159+
$this->assertEquals($expectedArray, $api->show(1, $parameters));
160+
}
161+
146162
#[Test]
147163
public function shouldCreateGroup(): void
148164
{

0 commit comments

Comments
 (0)