mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +00:00
* 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>
127 lines
4.1 KiB
C#
127 lines
4.1 KiB
C#
using System.Diagnostics;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Globalization;
|
|
using Octokit.Internal;
|
|
|
|
namespace Octokit
|
|
{
|
|
/// <summary>
|
|
/// Used to describe a permission level.
|
|
/// </summary>
|
|
[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
|
|
public enum Permission
|
|
{
|
|
/// <summary>
|
|
/// team members can pull, push and administer these repositories.
|
|
/// </summary>
|
|
[Parameter(Value = "admin")]
|
|
Admin,
|
|
|
|
/// <summary>
|
|
/// team members can manage the repository without access to sensitive or destructive actions. Recommended for project managers. Only applies to repositories owned by organizations.
|
|
/// </summary>
|
|
[Parameter(Value = "maintain")]
|
|
Maintain,
|
|
|
|
/// <summary>
|
|
/// team members can proactively manage issues and pull requests without write access. Recommended for contributors who triage a repository. Only applies to repositories owned by organizations.
|
|
/// </summary>
|
|
[Parameter(Value = "triage")]
|
|
Triage,
|
|
|
|
/// <summary>
|
|
/// team members can pull and push, but not administer these repositories
|
|
/// </summary>
|
|
[Parameter(Value = "push")]
|
|
Push,
|
|
|
|
/// <summary>
|
|
/// team members can pull, but not push to or administer these repositories
|
|
/// </summary>
|
|
[Parameter(Value = "pull")]
|
|
Pull
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deprecated. The permission that new repositories will be added to the team with when none is specified
|
|
/// Default: pull
|
|
/// Can be one of: pull, push
|
|
/// </summary>
|
|
[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
|
|
public enum TeamPermission
|
|
{
|
|
/// <summary>
|
|
/// team members can pull, but not push to these repositories
|
|
/// </summary>
|
|
[Parameter(Value = "pull")]
|
|
Pull,
|
|
|
|
/// <summary>
|
|
/// team members can pull and push to these repositories
|
|
/// </summary>
|
|
[Parameter(Value = "push")]
|
|
Push
|
|
}
|
|
|
|
/// <summary>
|
|
/// Object for team repository permissions
|
|
/// </summary>
|
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
|
public class TeamRepositoryPermissions
|
|
{
|
|
public TeamRepositoryPermissions() { }
|
|
public TeamRepositoryPermissions(bool pull, bool triage, bool push, bool maintain, bool admin)
|
|
{
|
|
Pull = pull;
|
|
Triage = triage;
|
|
Push = push;
|
|
Maintain = maintain;
|
|
Admin = admin;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Can read and clone repository.
|
|
/// Can also open and comment on issues and pull requests.
|
|
/// Required
|
|
/// </summary>
|
|
public bool Pull { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Can read and clone repository.
|
|
/// Can also manage issues and pull requests.
|
|
/// Required
|
|
/// </summary>
|
|
public bool Triage { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Can read, clone, and push to repository.
|
|
/// Can also manage issues and pull requests.
|
|
/// Required
|
|
/// </summary>
|
|
public bool Push { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Can read, clone, and push to repository.
|
|
/// They can also manage issues, pull requests, and some repository settings.
|
|
/// Required
|
|
/// </summary>
|
|
public bool Maintain { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Can read, clone, and push to repository.
|
|
/// Can also manage issues, pull requests, and repository settings, including adding collaborators.
|
|
/// Required
|
|
/// </summary>
|
|
public bool Admin { get; private set; }
|
|
|
|
internal string DebuggerDisplay
|
|
{
|
|
get
|
|
{
|
|
return string.Format(CultureInfo.InvariantCulture,
|
|
$"Permissions: Pull: {Pull}, Triage: {Triage}, Push: {Push}, Maintain: {Maintain}, Admin: {Admin}");
|
|
}
|
|
}
|
|
}
|
|
}
|