Skip to content

Commit 4a34304

Browse files
authored
Merge pull request #66 from packagist/z/team-access-all-packages
Team: Can Access All Packages
2 parents 28985a1 + 3cdb1e1 commit 4a34304

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed

README.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* [Create a New Team](#create-a-new-team)
1616
* [Show a Team](#show-a-team)
1717
* [Edit a Team](#edit-a-team)
18+
* [Grant All Package Access](#grant-all-package-access)
19+
* [Revoke All Package Access](#revoke-all-package-access)
1820
* [Delete a Team](#delete-a-team)
1921
* [Add Member to Team (by User ID)](#add-member-to-team-by-user-id)
2022
* [Remove Member from Team](#remove-member-from-team)
@@ -126,7 +128,7 @@
126128
* [Validate incoming webhook payloads](#validate-incoming-webhook-payloads)
127129
* [License](#license)
128130

129-
<!-- Added by: glaubinix, at: Thu 9 Feb 2023 15:40:34 GMT -->
131+
<!-- Added by: zanbaldwin, at: Wed May 17 20:53:35 CEST 2023 -->
130132

131133
<!--te-->
132134

@@ -244,6 +246,20 @@ $team = $client->teams()->edit($teamId, 'Altered Team Name', $permissions);
244246
```
245247
Edits a team's name and permissions to be applied to team members. Returns the updated team.
246248

249+
#### Grant All Package Access
250+
```php
251+
$team = $client->teams()->grantAccessToAllPackages($teamId);
252+
```
253+
254+
Granting a team access to all packages will give this team access to all current and future organization packages which do not have their permissions synchronized.
255+
256+
#### Revoke All Package Access
257+
```php
258+
$team = $client->teams()->revokeAccessToAllPackages($teamId);
259+
```
260+
261+
Revoking a team's access to all packages will not remove access to packages the team can currently access, but will prevent access to new packages and allow revoking individual package access.
262+
247263
#### Delete a Team
248264
```php
249265
$client->teams()->remove($teamId);
@@ -477,7 +493,7 @@ Returns the vendor bundle.
477493
$vendorBundleId = 42;
478494
$vendorBundleData = [
479495
'name' => 'Bundle name',
480-
'minimumAccessibleStability' => 'dev',
496+
'minimumAccessibleStability' => 'dev',
481497
'versionConstraint' => '^1.0',
482498
'assignAllPackages' => true,
483499
'synchronizationIds' => [123], // A list of synchronization ids for which new packages should automatically be added to the bundle.

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"php-http/discovery": "^1.0",
1818
"psr/http-client-implementation": "^1.0",
1919
"php-http/client-common": "^1.9 || ^2.0",
20+
"php-http/message-factory": "^1.0",
2021
"composer-runtime-api": "^2.0"
2122
},
2223
"require-dev": {

src/Api/Teams.php

+10
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ public function edit($teamId, string $name, TeamPermissions $permissions): array
5555
return $this->put(sprintf('/teams/%s/', $teamId), $parameters);
5656
}
5757

58+
public function grantAccessToAllPackages($teamId): array
59+
{
60+
return $this->put(sprintf('/teams/%s/all-package-access/grant', $teamId));
61+
}
62+
63+
public function revokeAccessToAllPackages($teamId): array
64+
{
65+
return $this->put(sprintf('/teams/%s/all-package-access/revoke', $teamId));
66+
}
67+
5868
public function remove($teamId): array
5969
{
6070
return $this->delete(sprintf('/teams/%s/', $teamId));

tests/Api/TeamsTest.php

+48
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,54 @@ public function testEditTeam(): void
193193
$this->assertSame($expected, $api->edit(123, 'New Team', $permissions));
194194
}
195195

196+
public function testTeamGrant(): void
197+
{
198+
$expected = [
199+
'id' => 123,
200+
'name' => 'New Team',
201+
'permissions' => [
202+
'canEditTeamPackages' => true,
203+
'canAddPackages' => false,
204+
'canCreateSubrepositories' => false,
205+
'canViewVendorCustomers' => true,
206+
'canManageVendorCustomers' => false,
207+
],
208+
];
209+
210+
/** @var Teams&MockObject $api */
211+
$api = $this->getApiMock();
212+
$api->expects($this->once())
213+
->method('put')
214+
->with($this->equalTo('/teams/123/all-package-access/grant'), $this->equalTo([]))
215+
->willReturn($expected);
216+
217+
$this->assertSame($expected, $api->grantAccessToAllPackages(123));
218+
}
219+
220+
public function testTeamRevoke(): void
221+
{
222+
$expected = [
223+
'id' => 123,
224+
'name' => 'New Team',
225+
'permissions' => [
226+
'canEditTeamPackages' => true,
227+
'canAddPackages' => false,
228+
'canCreateSubrepositories' => false,
229+
'canViewVendorCustomers' => true,
230+
'canManageVendorCustomers' => false,
231+
],
232+
];
233+
234+
/** @var Teams&MockObject $api */
235+
$api = $this->getApiMock();
236+
$api->expects($this->once())
237+
->method('put')
238+
->with($this->equalTo('/teams/123/all-package-access/revoke'), $this->equalTo([]))
239+
->willReturn($expected);
240+
241+
$this->assertSame($expected, $api->revokeAccessToAllPackages(123));
242+
}
243+
196244
public function testDeleteTeam(): void
197245
{
198246
$expected = [];

0 commit comments

Comments
 (0)