update models with updated permission enum (#2633)

* update models with updated permission enum

* add suppress message attribute

* update integration tests

* refactor: new and legacy update teams endpint

* refactor: add new delete team endpoint

* use TeamPermission on NewTeam

* use updated delete on team context dispose

* add permission enum for team response object

* refactor: remove legacy suffix from method names

* introduce permissions object on Team

* refactor: rename enum to TeamRepositoryPermission

* fix formatting

* change Permission to string to match api specs

* add TeamRepository

* add CheckTeamPermission endpoint support

* fix convention tests

* update comments on TeamRepository props

* add two new endpoints in TeamsClient

* refactor: rename ApiUrl for TeamPermission

* fix test

* implement methods for new endpoints

* add the integration tests

* fix spelling

* update comments

* refactor: rename method name

* fix: add end tag for remarks

* refactor: remove unused method param

* fix docstring comment

* the unit tests are in finally

* add docs for teams api

* split CheckTeamPermissions into two methods

* Update ObservableTeamsClientTests.cs based on review

Co-authored-by: Keegan Campbell <me@kfcampbell.com>

* add cref to legacy update and delete endpoints

* remove editorconfig file

* Update Octokit.Tests/Clients/TeamsClientTests.cs

Co-authored-by: Keegan Campbell <me@kfcampbell.com>

* remove unused line

* rename variable based on review

* rename prop to match constructor param

* add comment to explain TeamPermission enum values on update

Co-authored-by: notauserx <notauserx@users.noreply.github.com>
Co-authored-by: Keegan Campbell <me@kfcampbell.com>
This commit is contained in:
notauserx
2023-01-21 00:48:00 +06:00
committed by GitHub
parent bf6678543f
commit 891015c39f
24 changed files with 2056 additions and 41 deletions

77
docs/teams.md Normal file
View File

@@ -0,0 +1,77 @@
# Working with Teams
To access the teams API, you need to be an authenticated member of the organization's team. OAuth access tokens require the read:org scope. The ITeamsClient houses the endpoints for the teams API.
### Create, update or delete teams
To create a new team, you need to be a member of owner of the organization.
```csharp
var newTeam = new NewTeam("team-name")
{
Description = "my cool team description",
Privacy = TeamPrivacy.Closed
};
newTeam.Maintainers.Add("maintainer-name");
newTeam.RepoNames.Add("repository-name");
var team = await github.Organization.Team.Create("organization-name", newTeam);
```
Updating and deleting a team is also possible
```csharp
var update = new UpdateTeam("team-name",)
{
Description = "my new team description",
Privacy = TeamPrivacy.Closed,
Permission = TeamPermission.Push,
};
var team = await _github.Organization.Team.Update("organization-name", "team-slug", update);
```
```csharp
var team = await _github.Organization.Team.Delete("organization-name", "team-slug");
```
### Working with repositories for the team
You can get the list of repositories for the team by following
```csharp
var allRepositories = await github.Organization.Team.GetAllRepositories(teamContext.TeamId);
```
Or check permissions for a specific repository with the CheckTeamPermissionsForARepository method.
```csharp
await github.Organization.Team.CheckTeamPermissionsForARepository(
"organization-name",
"team-slug",
"repository-owner",
"repository-name",
false);
```
The following snippet shows how to add or update team repository permissions.
Permissions can be one of pull, triage, push, maintain, admin and you can also specify a custom repository role name, if the owning organization has defined any. If no permission is specified, the team's permission attribute will be used to determine what permission to grant the team on this repository.
```csharp
await github.Organization.Team.AddOrUpdateTeamRepositoryPermissions(
"organization-name",
"team-slug",
"repository-owner",
"repository-name",
"admin");
```
To remove a repository form a team, use
```csharp
await github.Organization.Team.RemoveRepositoryFromATeam(
"organization-name",
"team-slug",
"repository-owner",
"repository-name");
```