Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -126,7 +128,7 @@
* [Validate incoming webhook payloads](#validate-incoming-webhook-payloads)
* [License](#license)

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

<!--te-->

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 10 additions & 0 deletions src/Api/Teams.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
48 changes: 48 additions & 0 deletions tests/Api/TeamsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down