diff --git a/README.md b/README.md index 28212e8..62eab6e 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ * [Create a New Team](#create-a-new-team) * [Show a Team](#show-a-team) * [Edit a Team](#edit-a-team) + * [Grant All Package Access](#grant-all-package-access) + * [Revoke All Package Access](#revoke-all-package-access) * [Delete a Team](#delete-a-team) * [Add Member to Team (by User ID)](#add-member-to-team-by-user-id) * [Remove Member from Team](#remove-member-from-team) @@ -126,7 +128,7 @@ * [Validate incoming webhook payloads](#validate-incoming-webhook-payloads) * [License](#license) - + @@ -244,6 +246,20 @@ $team = $client->teams()->edit($teamId, 'Altered Team Name', $permissions); ``` Edits a team's name and permissions to be applied to team members. Returns the updated team. +#### Grant All Package Access +```php +$team = $client->teams()->grantAccessToAllPackages($teamId); +``` + +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. + +#### Revoke All Package Access +```php +$team = $client->teams()->revokeAccessToAllPackages($teamId); +``` + +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. + #### Delete a Team ```php $client->teams()->remove($teamId); @@ -477,7 +493,7 @@ Returns the vendor bundle. $vendorBundleId = 42; $vendorBundleData = [ 'name' => 'Bundle name', - 'minimumAccessibleStability' => 'dev', + 'minimumAccessibleStability' => 'dev', 'versionConstraint' => '^1.0', 'assignAllPackages' => true, 'synchronizationIds' => [123], // A list of synchronization ids for which new packages should automatically be added to the bundle. diff --git a/composer.json b/composer.json index ab73c4b..987103d 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "php-http/discovery": "^1.0", "psr/http-client-implementation": "^1.0", "php-http/client-common": "^1.9 || ^2.0", + "php-http/message-factory": "^1.0", "composer-runtime-api": "^2.0" }, "require-dev": { diff --git a/src/Api/Teams.php b/src/Api/Teams.php index 815f9ff..f0965f4 100644 --- a/src/Api/Teams.php +++ b/src/Api/Teams.php @@ -55,6 +55,16 @@ public function edit($teamId, string $name, TeamPermissions $permissions): array return $this->put(sprintf('/teams/%s/', $teamId), $parameters); } + public function grantAccessToAllPackages($teamId): array + { + return $this->put(sprintf('/teams/%s/all-package-access/grant', $teamId)); + } + + public function revokeAccessToAllPackages($teamId): array + { + return $this->put(sprintf('/teams/%s/all-package-access/revoke', $teamId)); + } + public function remove($teamId): array { return $this->delete(sprintf('/teams/%s/', $teamId)); diff --git a/tests/Api/TeamsTest.php b/tests/Api/TeamsTest.php index 2145dc3..5981af7 100644 --- a/tests/Api/TeamsTest.php +++ b/tests/Api/TeamsTest.php @@ -193,6 +193,54 @@ public function testEditTeam(): void $this->assertSame($expected, $api->edit(123, 'New Team', $permissions)); } + public function testTeamGrant(): void + { + $expected = [ + 'id' => 123, + 'name' => 'New Team', + 'permissions' => [ + 'canEditTeamPackages' => true, + 'canAddPackages' => false, + 'canCreateSubrepositories' => false, + 'canViewVendorCustomers' => true, + 'canManageVendorCustomers' => false, + ], + ]; + + /** @var Teams&MockObject $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('put') + ->with($this->equalTo('/teams/123/all-package-access/grant'), $this->equalTo([])) + ->willReturn($expected); + + $this->assertSame($expected, $api->grantAccessToAllPackages(123)); + } + + public function testTeamRevoke(): void + { + $expected = [ + 'id' => 123, + 'name' => 'New Team', + 'permissions' => [ + 'canEditTeamPackages' => true, + 'canAddPackages' => false, + 'canCreateSubrepositories' => false, + 'canViewVendorCustomers' => true, + 'canManageVendorCustomers' => false, + ], + ]; + + /** @var Teams&MockObject $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('put') + ->with($this->equalTo('/teams/123/all-package-access/revoke'), $this->equalTo([])) + ->willReturn($expected); + + $this->assertSame($expected, $api->revokeAccessToAllPackages(123)); + } + public function testDeleteTeam(): void { $expected = [];