[FEAT] Updates permissions for App Installations and Collaborators endpoints

This commit is contained in:
notauserx
2023-03-08 22:27:29 +06:00
committed by GitHub
parent b5cf402032
commit 1300427bdd
27 changed files with 736 additions and 461 deletions

View File

@@ -547,20 +547,20 @@ namespace Octokit.AsyncPaginationExtension
=> pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(repositoryId, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
/// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, ApiOptions)"/>
public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
public static IPaginatedList<Collaborator> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<Collaborator>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
/// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, ApiOptions)"/>
public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
public static IPaginatedList<Collaborator> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<Collaborator>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
/// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, RepositoryCollaboratorListRequest, ApiOptions)"/>
public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
public static IPaginatedList<Collaborator> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<Collaborator>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
/// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, RepositoryCollaboratorListRequest, ApiOptions)"/>
public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
public static IPaginatedList<Collaborator> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<Collaborator>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
/// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(ApiOptions)"/>
public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, int pageSize = DEFAULT_PAGE_SIZE)

View File

@@ -4,10 +4,10 @@ using System.Reactive;
namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Collaborators on a Repository.
/// A client for GitHub's Collaborators API.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28">Collaborators API documentation</a> for more details.
/// </remarks>
public interface IObservableRepoCollaboratorsClient
{
@@ -15,99 +15,99 @@ namespace Octokit.Reactive
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
IObservable<User> GetAll(string owner, string name);
IObservable<Collaborator> GetAll(string owner, string name);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
IObservable<User> GetAll(long repositoryId);
IObservable<Collaborator> GetAll(long repositoryId);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
IObservable<User> GetAll(string owner, string name, ApiOptions options);
IObservable<Collaborator> GetAll(string owner, string name, ApiOptions options);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
IObservable<User> GetAll(long repositoryId, ApiOptions options);
IObservable<Collaborator> GetAll(long repositoryId, ApiOptions options);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
IObservable<User> GetAll(string owner, string name, RepositoryCollaboratorListRequest request);
IObservable<Collaborator> GetAll(string owner, string name, RepositoryCollaboratorListRequest request);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
IObservable<User> GetAll(long repositoryId, RepositoryCollaboratorListRequest request);
IObservable<Collaborator> GetAll(long repositoryId, RepositoryCollaboratorListRequest request);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
IObservable<User> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options);
IObservable<Collaborator> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
IObservable<User> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options);
IObservable<Collaborator> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options);
/// <summary>
/// Checks if a user is a collaborator on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#get">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
@@ -136,7 +136,7 @@ namespace Octokit.Reactive
/// <param name="name">The name of the repository</param>
/// <param name="user">Username of the collaborator to check permission for</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
IObservable<CollaboratorPermission> ReviewPermission(string owner, string name, string user);
IObservable<CollaboratorPermissionResponse> ReviewPermission(string owner, string name, string user);
/// <summary>
/// Review a user's permission level in a repository
@@ -147,13 +147,13 @@ namespace Octokit.Reactive
/// <param name="repositoryId">The id of the repository</param>
/// <param name="user">Username of the collaborator to check permission for</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
IObservable<CollaboratorPermission> ReviewPermission(long repositoryId, string user);
IObservable<CollaboratorPermissionResponse> ReviewPermission(long repositoryId, string user);
/// <summary>
/// Adds a new collaborator to the repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#add-collaborator">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
@@ -165,7 +165,7 @@ namespace Octokit.Reactive
/// Adds a new collaborator to the repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#add-collaborator">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
@@ -247,7 +247,7 @@ namespace Octokit.Reactive
/// Deletes a collaborator from the repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#remove-collaborator">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>

View File

@@ -6,10 +6,10 @@ using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Collaborators on a Repository.
/// A client for GitHub's Collaborators API.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28">Collaborators API documentation</a> for more details.
/// </remarks>
public class ObservableRepoCollaboratorsClient : IObservableRepoCollaboratorsClient
{
@@ -32,12 +32,12 @@ namespace Octokit.Reactive
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public IObservable<User> GetAll(string owner, string name)
public IObservable<Collaborator> GetAll(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
@@ -49,11 +49,11 @@ namespace Octokit.Reactive
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public IObservable<User> GetAll(long repositoryId)
public IObservable<Collaborator> GetAll(long repositoryId)
{
return GetAll(repositoryId, ApiOptions.None);
}
@@ -62,13 +62,13 @@ namespace Octokit.Reactive
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public IObservable<User> GetAll(string owner, string name, ApiOptions options)
public IObservable<Collaborator> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
@@ -81,12 +81,12 @@ namespace Octokit.Reactive
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public IObservable<User> GetAll(long repositoryId, ApiOptions options)
public IObservable<Collaborator> GetAll(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
@@ -97,13 +97,13 @@ namespace Octokit.Reactive
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public IObservable<User> GetAll(string owner, string name, RepositoryCollaboratorListRequest request)
public IObservable<Collaborator> GetAll(string owner, string name, RepositoryCollaboratorListRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
@@ -116,12 +116,12 @@ namespace Octokit.Reactive
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public IObservable<User> GetAll(long repositoryId, RepositoryCollaboratorListRequest request)
public IObservable<Collaborator> GetAll(long repositoryId, RepositoryCollaboratorListRequest request)
{
Ensure.ArgumentNotNull(request, nameof(request));
@@ -132,46 +132,46 @@ namespace Octokit.Reactive
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public IObservable<User> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options)
public IObservable<Collaborator> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<User>(ApiUrls.RepoCollaborators(owner, name), request.ToParametersDictionary(), options);
return _connection.GetAndFlattenAllPages<Collaborator>(ApiUrls.RepoCollaborators(owner, name), request.ToParametersDictionary(), options);
}
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public IObservable<User> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options)
public IObservable<Collaborator> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options)
{
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<User>(ApiUrls.RepoCollaborators(repositoryId), request.ToParametersDictionary(), options);
return _connection.GetAndFlattenAllPages<Collaborator>(ApiUrls.RepoCollaborators(repositoryId), request.ToParametersDictionary(), options);
}
/// <summary>
/// Checks if a user is a collaborator on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#get">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
@@ -212,7 +212,7 @@ namespace Octokit.Reactive
/// <param name="name">The name of the repository</param>
/// <param name="user">Username of the collaborator to check permission for</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public IObservable<CollaboratorPermission> ReviewPermission(string owner, string name, string user)
public IObservable<CollaboratorPermissionResponse> ReviewPermission(string owner, string name, string user)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
@@ -230,7 +230,7 @@ namespace Octokit.Reactive
/// <param name="repositoryId">The id of the repository</param>
/// <param name="user">Username of the collaborator to check permission for</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
public IObservable<CollaboratorPermission> ReviewPermission(long repositoryId, string user)
public IObservable<CollaboratorPermissionResponse> ReviewPermission(long repositoryId, string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, nameof(user));
@@ -297,7 +297,7 @@ namespace Octokit.Reactive
/// Adds a new collaborator to the repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#add-collaborator">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="user">Username of the new collaborator</param>
@@ -315,7 +315,7 @@ namespace Octokit.Reactive
/// Invites a user as a collaborator to a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#add-collaborator">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
@@ -333,7 +333,7 @@ namespace Octokit.Reactive
/// Invites a user as a collaborator to a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#add-collaborator">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
@@ -353,7 +353,7 @@ namespace Octokit.Reactive
/// Invites a user as a collaborator to a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#add-collaborator">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="user">The username of the prospective collaborator</param>
@@ -369,7 +369,7 @@ namespace Octokit.Reactive
/// Invites a user as a collaborator to a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#add-collaborator">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="user">The username of the prospective collaborator</param>
@@ -386,7 +386,7 @@ namespace Octokit.Reactive
/// Deletes a collaborator from the repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#remove-collaborator">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>

View File

@@ -71,7 +71,7 @@ namespace Octokit.Tests.Integration.Clients
Assert.Equal(Helper.GitHubAppId, installation.AppId);
Assert.NotNull(installation.Account);
Assert.NotNull(installation.Permissions);
Assert.Equal(InstallationPermissionLevel.Read, installation.Permissions.Metadata);
Assert.Equal(InstallationReadWritePermissionLevel.Read, installation.Permissions.Metadata);
Assert.False(string.IsNullOrEmpty(installation.HtmlUrl));
Assert.NotEqual(0, installation.TargetId);
}
@@ -101,7 +101,7 @@ namespace Octokit.Tests.Integration.Clients
Assert.Equal(Helper.GitHubAppId, result.AppId);
Assert.NotNull(result.Account);
Assert.NotNull(result.Permissions);
Assert.Equal(InstallationPermissionLevel.Read, result.Permissions.Metadata);
Assert.Equal(InstallationReadWritePermissionLevel.Read, result.Permissions.Metadata);
Assert.False(string.IsNullOrEmpty(result.HtmlUrl));
Assert.NotEqual(0, result.TargetId);
}

View File

@@ -1241,7 +1241,7 @@ namespace Octokit.Tests.Integration.Clients
team2.TeamId,
repoContext.RepositoryOwner,
repoContext.RepositoryName,
new RepositoryPermissionRequest(Permission.Push));
new RepositoryPermissionRequest(TeamPermissionLegacy.Push));
var newTeam = new BranchProtectionTeamCollection() { team2.TeamName };
var restrictions = await _github.Repository.Branch.UpdateProtectedBranchTeamRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, newTeam);
@@ -1265,7 +1265,7 @@ namespace Octokit.Tests.Integration.Clients
team2.TeamId,
repoContext.RepositoryOwner,
repoContext.RepositoryName,
new RepositoryPermissionRequest(Permission.Push));
new RepositoryPermissionRequest(TeamPermissionLegacy.Push));
var newTeam = new BranchProtectionTeamCollection() { team2.TeamName };
var restrictions = await _github.Repository.Branch.UpdateProtectedBranchTeamRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, newTeam);
@@ -1292,7 +1292,7 @@ namespace Octokit.Tests.Integration.Clients
team2.TeamId,
repoContext.RepositoryOwner,
repoContext.RepositoryName,
new RepositoryPermissionRequest(Permission.Push));
new RepositoryPermissionRequest(TeamPermissionLegacy.Push));
var newTeam = new BranchProtectionTeamCollection() { team2.TeamName };
var restrictions = await _github.Repository.Branch.AddProtectedBranchTeamRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, newTeam);
@@ -1316,7 +1316,7 @@ namespace Octokit.Tests.Integration.Clients
team2.TeamId,
repoContext.RepositoryOwner,
repoContext.RepositoryName,
new RepositoryPermissionRequest(Permission.Push));
new RepositoryPermissionRequest(TeamPermissionLegacy.Push));
var newTeam = new BranchProtectionTeamCollection() { team2.TeamName };
var restrictions = await _github.Repository.Branch.AddProtectedBranchTeamRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, newTeam);

View File

@@ -2,8 +2,8 @@
using System.Threading.Tasks;
using Octokit;
using Octokit.Tests.Integration;
using Xunit;
using Octokit.Tests.Integration.Helpers;
using Xunit;
public class RepositoryCollaboratorClientTests
{
@@ -19,14 +19,29 @@ public class RepositoryCollaboratorClientTests
{
var fixture = github.Repository.Collaborator;
// add a collaborator
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName);
Assert.NotNull(collaborators);
Assert.Equal(2, collaborators.Count);
Assert.NotNull(collaborators[0].Permissions);
Assert.NotNull(collaborators[1].Permissions);
Assert.Equal(1, collaborators.Count);
}
}
[IntegrationTest]
public async Task ReturnsCollaboratorsWithPermissionFilter()
{
var github = Helper.GetAuthenticatedClient();
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var collaborators = await fixture.GetAll(context.RepositoryOwner,
context.RepositoryName,
new RepositoryCollaboratorListRequest() { Permission = CollaboratorPermission.Admin });
Assert.NotNull(collaborators);
Assert.Equal(1, collaborators.Count);
}
}
@@ -40,12 +55,10 @@ public class RepositoryCollaboratorClientTests
{
var fixture = github.Repository.Collaborator;
// add a collaborator
await fixture.Add(context.Repository.Id, "m-zuber-octokit-integration-tests");
var collaborators = await fixture.GetAll(context.Repository.Id);
Assert.NotNull(collaborators);
Assert.Equal(2, collaborators.Count);
Assert.Equal(1, collaborators.Count);
}
}
@@ -59,9 +72,6 @@ public class RepositoryCollaboratorClientTests
{
var fixture = github.Repository.Collaborator;
// add some collaborators
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var options = new ApiOptions
{
PageSize = 1,
@@ -69,6 +79,7 @@ public class RepositoryCollaboratorClientTests
};
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options);
Assert.NotNull(collaborators);
Assert.Equal(1, collaborators.Count);
}
@@ -84,9 +95,6 @@ public class RepositoryCollaboratorClientTests
{
var fixture = github.Repository.Collaborator;
// add some collaborators
await fixture.Add(context.Repository.Id, "m-zuber-octokit-integration-tests");
var options = new ApiOptions
{
PageSize = 1,
@@ -94,6 +102,7 @@ public class RepositoryCollaboratorClientTests
};
var collaborators = await fixture.GetAll(context.Repository.Id, options);
Assert.NotNull(collaborators);
Assert.Equal(1, collaborators.Count);
}
@@ -109,9 +118,6 @@ public class RepositoryCollaboratorClientTests
{
var fixture = github.Repository.Collaborator;
// add some collaborators
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var options = new ApiOptions
{
PageSize = 1,
@@ -120,8 +126,9 @@ public class RepositoryCollaboratorClientTests
};
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options);
Assert.NotNull(collaborators);
Assert.Equal(1, collaborators.Count);
Assert.Equal(0, collaborators.Count);
}
}
@@ -135,9 +142,6 @@ public class RepositoryCollaboratorClientTests
{
var fixture = github.Repository.Collaborator;
// add some collaborators
await fixture.Add(context.Repository.Id, "m-zuber-octokit-integration-tests");
var options = new ApiOptions
{
PageSize = 1,
@@ -146,8 +150,9 @@ public class RepositoryCollaboratorClientTests
};
var collaborators = await fixture.GetAll(context.Repository.Id, options);
Assert.NotNull(collaborators);
Assert.Equal(1, collaborators.Count);
Assert.Equal(0, collaborators.Count);
}
}
@@ -161,9 +166,6 @@ public class RepositoryCollaboratorClientTests
{
var fixture = github.Repository.Collaborator;
// add some collaborators
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var startOptions = new ApiOptions
{
PageSize = 1,
@@ -181,7 +183,8 @@ public class RepositoryCollaboratorClientTests
var secondPage = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, skipStartOptions);
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
Assert.Equal(1, firstPage.Count);
Assert.Equal(0, secondPage.Count);
}
}
@@ -195,9 +198,6 @@ public class RepositoryCollaboratorClientTests
{
var fixture = github.Repository.Collaborator;
// add some collaborators
await fixture.Add(context.Repository.Id, "m-zuber-octokit-integration-tests");
var startOptions = new ApiOptions
{
PageSize = 1,
@@ -215,7 +215,8 @@ public class RepositoryCollaboratorClientTests
var secondPage = await fixture.GetAll(context.Repository.Id, skipStartOptions);
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
Assert.Equal(1, firstPage.Count);
Assert.Equal(0, secondPage.Count);
}
}
}
@@ -232,10 +233,7 @@ public class RepositoryCollaboratorClientTests
{
var fixture = github.Repository.Collaborator;
// add a collaborator
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner);
Assert.True(isCollab);
}
@@ -251,10 +249,7 @@ public class RepositoryCollaboratorClientTests
{
var fixture = github.Repository.Collaborator;
// add a collaborator
await fixture.Add(context.Repository.Id, "m-zuber-octokit-integration-tests");
var isCollab = await fixture.IsCollaborator(context.Repository.Id, "m-zuber-octokit-integration-tests");
var isCollab = await fixture.IsCollaborator(context.Repository.Id, context.RepositoryOwner);
Assert.True(isCollab);
}
@@ -275,7 +270,7 @@ public class RepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1");
Assert.Equal(PermissionLevel.Read, permission.Permission);
Assert.Equal("read", permission.Permission);
}
}
@@ -291,12 +286,12 @@ public class RepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1");
Assert.Equal(PermissionLevel.Read, permission.Permission);
Assert.Equal("read", permission.Permission);
}
}
[IntegrationTest]
public async Task ReturnsWritePermissionForCollaborator()
public async Task ReturnsWritePermissionForCollaboratorInvitation()
{
var github = Helper.GetAuthenticatedClient();
var repoName = Helper.MakeNameWithTimestamp("public-repo");
@@ -306,16 +301,15 @@ public class RepositoryCollaboratorClientTests
var fixture = github.Repository.Collaborator;
// add a collaborator
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1");
var invitation = await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1", new CollaboratorRequest("write"));
var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1");
Assert.Equal(PermissionLevel.Write, permission.Permission);
Assert.Equal(InvitationPermissionType.Write, invitation.Permissions);
}
}
[IntegrationTest]
public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId()
public async Task ReturnsWritePermissionForCollaboratorInvitationWithRepositoryId()
{
var github = Helper.GetAuthenticatedClient();
var repoName = Helper.MakeNameWithTimestamp("public-repo");
@@ -325,11 +319,9 @@ public class RepositoryCollaboratorClientTests
var fixture = github.Repository.Collaborator;
// add a collaborator
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1");
var invitation = await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1", new CollaboratorRequest("write"));
var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1");
Assert.Equal(PermissionLevel.Write, permission.Permission);
Assert.Equal(InvitationPermissionType.Write, invitation.Permissions);
}
}
@@ -345,7 +337,7 @@ public class RepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner);
Assert.Equal(PermissionLevel.Admin, permission.Permission);
Assert.Equal("admin", permission.Permission);
}
}
@@ -361,7 +353,7 @@ public class RepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryId, context.RepositoryOwner);
Assert.Equal(PermissionLevel.Admin, permission.Permission);
Assert.Equal("admin", permission.Permission);
}
}
@@ -382,7 +374,7 @@ public class RepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1");
Assert.Equal(PermissionLevel.None, permission.Permission);
Assert.Equal("none", permission.Permission);
}
}
@@ -403,14 +395,14 @@ public class RepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1");
Assert.Equal(PermissionLevel.None, permission.Permission);
Assert.Equal("none", permission.Permission);
}
}
}
public class TheDeleteMethod
{
[IntegrationTest]
[Fact(Skip = "Adding a collaborator sends an invitation, need to figure out a way to test the remove method.")]
public async Task CheckDeleteMethod()
{
var github = Helper.GetAuthenticatedClient();
@@ -432,7 +424,7 @@ public class RepositoryCollaboratorClientTests
}
}
[IntegrationTest]
[Fact(Skip = "Adding a collaborator sends an invitation, need to figure out a way to test the remove method.")]
public async Task CheckDeleteMethodWithRepositoryId()
{
var github = Helper.GetAuthenticatedClient();
@@ -466,7 +458,7 @@ public class RepositoryCollaboratorClientTests
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator
var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, "octokat", permission);

View File

@@ -20,7 +20,7 @@ public class RepositoryInvitationsClientTests
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator
var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, collaborator, permission);
@@ -50,7 +50,7 @@ public class RepositoryInvitationsClientTests
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator
var response1 = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, collaborator1, permission);
@@ -86,7 +86,7 @@ public class RepositoryInvitationsClientTests
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator
var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, collaborator, permission);
@@ -116,7 +116,7 @@ public class RepositoryInvitationsClientTests
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator
var response1 = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, collaborator1, permission);
@@ -161,7 +161,7 @@ public class RepositoryInvitationsClientTests
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator
var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);
@@ -195,7 +195,7 @@ public class RepositoryInvitationsClientTests
contexts.Add(await github.CreateRepositoryContext(new NewRepository(repoName)));
}
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator to all repos
foreach (var context in contexts)
@@ -243,7 +243,7 @@ public class RepositoryInvitationsClientTests
contexts.Add(await github.CreateRepositoryContext(new NewRepository(repoName)));
}
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator to all repos
foreach (var context in contexts)
@@ -290,7 +290,7 @@ public class RepositoryInvitationsClientTests
contexts.Add(await github.CreateRepositoryContext(new NewRepository(repoName)));
}
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator to all repos
foreach (var context in contexts)
@@ -351,7 +351,7 @@ public class RepositoryInvitationsClientTests
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator
var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);
@@ -378,7 +378,7 @@ public class RepositoryInvitationsClientTests
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator
var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);
@@ -406,7 +406,7 @@ public class RepositoryInvitationsClientTests
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator
var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);
@@ -433,7 +433,7 @@ public class RepositoryInvitationsClientTests
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
{
var fixture = github.Repository.Collaborator;
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
// invite a collaborator
var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission);

View File

@@ -326,7 +326,7 @@ public class TeamsClientTests
var team = teamContext.Team;
var repo = repoContext.Repository;
var addRepo = await _github.Organization.Team.AddRepository(team.Id, team.Organization.Login, repo.Name, new RepositoryPermissionRequest(Permission.Admin));
var addRepo = await _github.Organization.Team.AddRepository(team.Id, team.Organization.Login, repo.Name, new RepositoryPermissionRequest(TeamPermissionLegacy.Admin));
Assert.True(addRepo);

View File

@@ -73,7 +73,7 @@ namespace Octokit.Tests.Integration.Helpers
team.TeamId,
repoContext.RepositoryOwner,
repoContext.RepositoryName,
new RepositoryPermissionRequest(Permission.Push));
new RepositoryPermissionRequest(TeamPermissionLegacy.Push));
// Protect default branch
var protection = new BranchProtectionSettingsUpdate(
@@ -100,7 +100,7 @@ namespace Octokit.Tests.Integration.Helpers
contextOrgTeam.TeamId,
contextOrgRepo.RepositoryOwner,
contextOrgRepo.RepositoryName,
new RepositoryPermissionRequest(Permission.Push));
new RepositoryPermissionRequest(TeamPermissionLegacy.Push));
// Protect default branch
var protection = new BranchProtectionSettingsUpdate(

View File

@@ -73,7 +73,7 @@ namespace Octokit.Tests.Integration.Clients
Assert.Equal(Helper.GitHubAppId, installation.AppId);
Assert.NotNull(installation.Account);
Assert.NotNull(installation.Permissions);
Assert.Equal(InstallationPermissionLevel.Read, installation.Permissions.Metadata);
Assert.Equal(InstallationReadWritePermissionLevel.Read, installation.Permissions.Metadata);
Assert.False(string.IsNullOrEmpty(installation.HtmlUrl));
Assert.NotEqual(0, installation.TargetId);
}
@@ -103,7 +103,7 @@ namespace Octokit.Tests.Integration.Clients
Assert.Equal(Helper.GitHubAppId, result.AppId);
Assert.NotNull(result.Account);
Assert.NotNull(result.Permissions);
Assert.Equal(InstallationPermissionLevel.Read, result.Permissions.Metadata);
Assert.Equal(InstallationReadWritePermissionLevel.Read, result.Permissions.Metadata);
Assert.False(string.IsNullOrEmpty(result.HtmlUrl));
Assert.NotEqual(0, result.TargetId);
}

View File

@@ -4,8 +4,8 @@ using System.Threading.Tasks;
using Octokit;
using Octokit.Reactive;
using Octokit.Tests.Integration;
using Xunit;
using Octokit.Tests.Integration.Helpers;
using Xunit;
public class ObservableRepositoryCollaboratorClientTests
{
@@ -21,14 +21,10 @@ public class ObservableRepositoryCollaboratorClientTests
{
var fixture = new ObservableRepoCollaboratorsClient(github);
// add a collaborator
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName).ToList();
Assert.NotNull(collaborators);
Assert.Equal(2, collaborators.Count);
Assert.NotNull(collaborators[0].Permissions);
Assert.NotNull(collaborators[1].Permissions);
Assert.Equal(1, collaborators.Count);
}
}
@@ -42,9 +38,6 @@ public class ObservableRepositoryCollaboratorClientTests
{
var fixture = new ObservableRepoCollaboratorsClient(github);
// add some collaborators
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var options = new ApiOptions
{
PageSize = 1,
@@ -52,6 +45,7 @@ public class ObservableRepositoryCollaboratorClientTests
};
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options).ToList();
Assert.NotNull(collaborators);
Assert.Equal(1, collaborators.Count);
}
@@ -67,9 +61,6 @@ public class ObservableRepositoryCollaboratorClientTests
{
var fixture = new ObservableRepoCollaboratorsClient(github);
// add some collaborators
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var options = new ApiOptions
{
PageSize = 1,
@@ -78,8 +69,9 @@ public class ObservableRepositoryCollaboratorClientTests
};
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options).ToList();
Assert.NotNull(collaborators);
Assert.Equal(1, collaborators.Count);
Assert.Equal(0, collaborators.Count);
}
}
@@ -93,9 +85,6 @@ public class ObservableRepositoryCollaboratorClientTests
{
var fixture = new ObservableRepoCollaboratorsClient(github);
// add some collaborators
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var startOptions = new ApiOptions
{
PageSize = 1,
@@ -113,7 +102,8 @@ public class ObservableRepositoryCollaboratorClientTests
var secondPage = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, skipStartOptions).ToList();
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
Assert.Equal(1, firstPage.Count);
Assert.Equal(0, secondPage.Count);
}
}
}
@@ -130,10 +120,7 @@ public class ObservableRepositoryCollaboratorClientTests
{
var fixture = new ObservableRepoCollaboratorsClient(github);
// add a collaborator
fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner);
Assert.True(isCollab);
}
@@ -153,7 +140,7 @@ public class ObservableRepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1");
Assert.Equal(PermissionLevel.Read, permission.Permission);
Assert.Equal("read", permission.Permission);
}
}
@@ -169,12 +156,12 @@ public class ObservableRepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1");
Assert.Equal(PermissionLevel.Read, permission.Permission);
Assert.Equal("read", permission.Permission);
}
}
[IntegrationTest]
public async Task ReturnsWritePermissionForCollaborator()
public async Task ReturnsWritePermissionForCollaboratorInvitation()
{
var github = Helper.GetAuthenticatedClient();
var repoName = Helper.MakeNameWithTimestamp("public-repo");
@@ -184,16 +171,14 @@ public class ObservableRepositoryCollaboratorClientTests
var fixture = new ObservableRepoCollaboratorsClient(github);
// add a collaborator
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1");
var invitation = await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1", new CollaboratorRequest("write"));
var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1");
Assert.Equal(PermissionLevel.Write, permission.Permission);
Assert.Equal(InvitationPermissionType.Write, invitation.Permissions);
}
}
[IntegrationTest]
public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId()
public async Task ReturnsWritePermissionForCollaboratorInvitationWithRepositoryId()
{
var github = Helper.GetAuthenticatedClient();
var repoName = Helper.MakeNameWithTimestamp("public-repo");
@@ -203,11 +188,9 @@ public class ObservableRepositoryCollaboratorClientTests
var fixture = new ObservableRepoCollaboratorsClient(github);
// add a collaborator
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1");
var invitation = await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1", new CollaboratorRequest("write"));
var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1");
Assert.Equal(PermissionLevel.Write, permission.Permission);
Assert.Equal(InvitationPermissionType.Write, invitation.Permissions);
}
}
@@ -223,7 +206,7 @@ public class ObservableRepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner);
Assert.Equal(PermissionLevel.Admin, permission.Permission);
Assert.Equal("admin", permission.Permission);
}
}
@@ -239,7 +222,7 @@ public class ObservableRepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryId, context.RepositoryOwner);
Assert.Equal(PermissionLevel.Admin, permission.Permission);
Assert.Equal("admin", permission.Permission);
}
}
@@ -260,7 +243,7 @@ public class ObservableRepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1");
Assert.Equal(PermissionLevel.None, permission.Permission);
Assert.Equal("none", permission.Permission);
}
}
@@ -281,7 +264,7 @@ public class ObservableRepositoryCollaboratorClientTests
var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1");
Assert.Equal(PermissionLevel.None, permission.Permission);
Assert.Equal("none", permission.Permission);
}
}
}

View File

@@ -35,7 +35,7 @@ namespace Octokit.Tests.Clients
client.GetAll("owner", "test");
connection.Received().GetAll<User>(
connection.Received().GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Any<Dictionary<string, string>>(),
Args.ApiOptions);
@@ -49,7 +49,7 @@ namespace Octokit.Tests.Clients
client.GetAll(1);
connection.Received().GetAll<User>(
connection.Received().GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Any<Dictionary<string, string>>(),
Args.ApiOptions);
@@ -71,7 +71,7 @@ namespace Octokit.Tests.Clients
client.GetAll("owner", "test", options);
connection.Received()
.GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
.GetAll<Collaborator>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Any<Dictionary<string, string>>(),
options);
}
@@ -87,7 +87,7 @@ namespace Octokit.Tests.Clients
client.GetAll("owner", "test", request);
connection.Received()
.GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
.GetAll<Collaborator>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "all"),
Args.ApiOptions);
@@ -99,7 +99,7 @@ namespace Octokit.Tests.Clients
client.GetAll("owner", "test", request);
connection.Received()
.GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
.GetAll<Collaborator>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "direct"),
Args.ApiOptions);
@@ -111,11 +111,93 @@ namespace Octokit.Tests.Clients
client.GetAll("owner", "test", request);
connection.Received()
.GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
.GetAll<Collaborator>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "outside"),
Args.ApiOptions);
}
[Fact]
public void RequestsCorrectUrlWithPermissionFilter()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepoCollaboratorsClient(connection);
var request = new RepositoryCollaboratorListRequest();
client.GetAll("owner", "test", request);
connection.Received()
.GetAll<Collaborator>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Is<Dictionary<string, string>>(d => !d.ContainsKey("permission")),
Args.ApiOptions);
request = new RepositoryCollaboratorListRequest
{
Permission = CollaboratorPermission.Admin
};
client.GetAll("owner", "test", request);
connection.Received()
.GetAll<Collaborator>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["permission"] == "admin"),
Args.ApiOptions);
request = new RepositoryCollaboratorListRequest
{
Permission = CollaboratorPermission.Maintain
};
client.GetAll("owner", "test", request);
connection.Received()
.GetAll<Collaborator>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["permission"] == "maintain"),
Args.ApiOptions);
}
[Fact]
public void RequestsCorrectUrlWithCollaboratorFilterAndPermissionFilter()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepoCollaboratorsClient(connection);
var request = new RepositoryCollaboratorListRequest();
client.GetAll("owner", "test", request);
connection.Received()
.GetAll<Collaborator>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "all" && !d.ContainsKey("permission")),
Args.ApiOptions);
request = new RepositoryCollaboratorListRequest
{
Affiliation = CollaboratorAffiliation.Direct,
Permission = CollaboratorPermission.Admin
};
client.GetAll("owner", "test", request);
connection.Received()
.GetAll<Collaborator>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "direct" && d["permission"] == "admin"),
Args.ApiOptions);
request = new RepositoryCollaboratorListRequest
{
Affiliation = CollaboratorAffiliation.Outside,
Permission = CollaboratorPermission.Pull
};
client.GetAll("owner", "test", request);
connection.Received()
.GetAll<Collaborator>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "outside" && d["permission"] == "pull"),
Args.ApiOptions);
}
[Fact]
public void RequestsCorrectUrlWithApiOptionsAndRepositoryId()
{
@@ -132,7 +214,7 @@ namespace Octokit.Tests.Clients
client.GetAll(1, options);
connection.Received()
.GetAll<User>(
.GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Any<Dictionary<string, string>>(),
options);
@@ -149,7 +231,7 @@ namespace Octokit.Tests.Clients
client.GetAll(1, request);
connection.Received()
.GetAll<User>(
.GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "all"),
Args.ApiOptions);
@@ -162,7 +244,7 @@ namespace Octokit.Tests.Clients
client.GetAll(1, request);
connection.Received()
.GetAll<User>(
.GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "direct"),
Args.ApiOptions);
@@ -175,12 +257,100 @@ namespace Octokit.Tests.Clients
client.GetAll(1, request);
connection.Received()
.GetAll<User>(
.GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "outside"),
Args.ApiOptions);
}
[Fact]
public void RequestsCorrectUrlWithPermissionFilterAndRepositoryId()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepoCollaboratorsClient(connection);
var request = new RepositoryCollaboratorListRequest();
client.GetAll(1, request);
connection.Received()
.GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Is<Dictionary<string, string>>(d => !d.ContainsKey("permission")),
Args.ApiOptions);
request = new RepositoryCollaboratorListRequest
{
Permission = CollaboratorPermission.Triage
};
client.GetAll(1, request);
connection.Received()
.GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["permission"] == "triage"),
Args.ApiOptions);
request = new RepositoryCollaboratorListRequest
{
Permission = CollaboratorPermission.Push
};
client.GetAll(1, request);
connection.Received()
.GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["permission"] == "push"),
Args.ApiOptions);
}
[Fact]
public void RequestsCorrectUrlWithCollaboratorFilterPermissionFilterAndRepositoryId()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepoCollaboratorsClient(connection);
var request = new RepositoryCollaboratorListRequest();
client.GetAll(1, request);
connection.Received()
.GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "all" && !d.ContainsKey("permission")),
Args.ApiOptions);
request = new RepositoryCollaboratorListRequest
{
Affiliation = CollaboratorAffiliation.Direct,
Permission = CollaboratorPermission.Triage
};
client.GetAll(1, request);
connection.Received()
.GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "direct" && d["permission"] == "triage"),
Args.ApiOptions);
request = new RepositoryCollaboratorListRequest
{
Affiliation = CollaboratorAffiliation.Outside,
Permission = CollaboratorPermission.Push
};
client.GetAll(1, request);
connection.Received()
.GetAll<Collaborator>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"),
Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "outside" && d["permission"] == "push"),
Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
@@ -301,7 +471,7 @@ namespace Octokit.Tests.Clients
var client = new RepoCollaboratorsClient(connection);
client.ReviewPermission("owner", "test", "user1");
connection.Received().Get<CollaboratorPermission>(
connection.Received().Get<CollaboratorPermissionResponse>(
Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators/user1/permission"),
Arg.Any<Dictionary<string, string>>());
}
@@ -313,7 +483,7 @@ namespace Octokit.Tests.Clients
var client = new RepoCollaboratorsClient(connection);
client.ReviewPermission(1L, "user1");
connection.Received().Get<CollaboratorPermission>(
connection.Received().Get<CollaboratorPermissionResponse>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators/user1/permission"),
Arg.Any<Dictionary<string, string>>());
}
@@ -393,8 +563,8 @@ namespace Octokit.Tests.Clients
connection.Put<RepositoryInvitation>(Arg.Any<Uri>(), Arg.Any<object>()).ThrowsAsync(new AuthorizationException());
await Assert.ThrowsAsync<AuthorizationException>(() => client.Add("owner", "test", "user1", new CollaboratorRequest(Permission.Pull)));
await Assert.ThrowsAsync<AuthorizationException>(() => client.Add(1, "user1", new CollaboratorRequest(Permission.Pull)));
await Assert.ThrowsAsync<AuthorizationException>(() => client.Add("owner", "test", "user1", new CollaboratorRequest("pull")));
await Assert.ThrowsAsync<AuthorizationException>(() => client.Add(1, "user1", new CollaboratorRequest("pull")));
}
}
@@ -406,7 +576,7 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For<IApiConnection>();
var client = new RepoCollaboratorsClient(connection);
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
client.Invite("owner", "test", "user1", permission);
connection.Received().Put<RepositoryInvitation>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators/user1"), Arg.Is<CollaboratorRequest>(permission));
@@ -416,7 +586,7 @@ namespace Octokit.Tests.Clients
public async Task EnsuresNonNullArguments()
{
var client = new RepoCollaboratorsClient(Substitute.For<IApiConnection>());
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Invite(null, "test", "user1", permission));
await Assert.ThrowsAsync<ArgumentException>(() => client.Invite("", "test", "user1", permission));

View File

@@ -416,7 +416,7 @@ namespace Octokit.Tests.Clients
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
var newPermission = new RepositoryPermissionRequest(Permission.Admin);
var newPermission = new RepositoryPermissionRequest(TeamPermissionLegacy.Admin);
await client.AddRepository(1, "org", "repo", newPermission);

View File

@@ -68,7 +68,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(owner, name);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1));
}
@@ -79,7 +79,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(repositoryId);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1));
}
@@ -98,7 +98,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(owner, name, options);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 3));
// StartPage is setted => only 1 option (StartPage) in dictionary
@@ -109,7 +109,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(owner, name, options);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2));
// PageCount is setted => none of options in dictionary
@@ -120,7 +120,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(owner, name, options);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1));
}
@@ -133,7 +133,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(owner, name, request);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "all"));
request = new RepositoryCollaboratorListRequest
@@ -143,7 +143,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(owner, name, request);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "direct"));
// PageCount is setted => none of options in dictionary
@@ -154,7 +154,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(owner, name, request);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "outside"));
}
@@ -173,7 +173,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(repositoryId, options);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 3));
// StartPage is setted => only 1 option (StartPage) in dictionary
@@ -184,7 +184,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(repositoryId, options);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2));
// PageCount is setted => none of options in dictionary
@@ -195,7 +195,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(repositoryId, options);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1));
}
@@ -208,7 +208,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(repositoryId, request);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "all"));
request = new RepositoryCollaboratorListRequest
@@ -218,7 +218,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(repositoryId, request);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "direct"));
request = new RepositoryCollaboratorListRequest
@@ -228,7 +228,7 @@ namespace Octokit.Tests.Reactive
_client.GetAll(repositoryId, request);
_githubClient.Connection.Received(1)
.Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
.Get<List<Collaborator>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "outside"));
}
}
@@ -507,7 +507,7 @@ namespace Octokit.Tests.Reactive
public void EnsuresNonNullArguments()
{
SetupWithNonReactiveClient();
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
Assert.Throws<ArgumentNullException>(() => _client.Invite(null, "repo", "user", permission));
Assert.Throws<ArgumentNullException>(() => _client.Invite("owner", null, "user", permission));
@@ -519,7 +519,7 @@ namespace Octokit.Tests.Reactive
public void EnsuresNonEmptyArguments()
{
SetupWithNonReactiveClient();
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
Assert.Throws<ArgumentException>(() => _client.Invite("", "repo", "user", permission));
Assert.Throws<ArgumentException>(() => _client.Invite("owner", "", "user", permission));
@@ -530,7 +530,7 @@ namespace Octokit.Tests.Reactive
public async Task EnsuresNonWhitespaceArguments()
{
SetupWithNonReactiveClient();
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
await AssertEx.ThrowsWhenGivenWhitespaceArgument(
async whitespace => await _client.Invite(whitespace, "repo", "user", permission));
@@ -544,7 +544,7 @@ namespace Octokit.Tests.Reactive
public void CallsInviteOnRegularDeploymentsClient()
{
SetupWithoutNonReactiveClient();
var permission = new CollaboratorRequest(Permission.Push);
var permission = new CollaboratorRequest("push");
_client.Invite("owner", "repo", "user", permission);

View File

@@ -4,10 +4,10 @@ using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Collaborators on a Repository.
/// A client for GitHub's Collaborators API.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28">Collaborators API documentation</a> for more details.
/// </remarks>
public interface IRepoCollaboratorsClient
{
@@ -15,93 +15,93 @@ namespace Octokit
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<IReadOnlyList<User>> GetAll(string owner, string name);
Task<IReadOnlyList<Collaborator>> GetAll(string owner, string name);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<IReadOnlyList<User>> GetAll(long repositoryId);
Task<IReadOnlyList<Collaborator>> GetAll(long repositoryId);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<IReadOnlyList<User>> GetAll(string owner, string name, ApiOptions options);
Task<IReadOnlyList<Collaborator>> GetAll(string owner, string name, ApiOptions options);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<IReadOnlyList<User>> GetAll(long repositoryId, ApiOptions options);
Task<IReadOnlyList<Collaborator>> GetAll(long repositoryId, ApiOptions options);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<IReadOnlyList<User>> GetAll(string owner, string name, RepositoryCollaboratorListRequest request);
Task<IReadOnlyList<Collaborator>> GetAll(string owner, string name, RepositoryCollaboratorListRequest request);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<IReadOnlyList<User>> GetAll(long repositoryId, RepositoryCollaboratorListRequest request);
Task<IReadOnlyList<Collaborator>> GetAll(long repositoryId, RepositoryCollaboratorListRequest request);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<IReadOnlyList<User>> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options);
Task<IReadOnlyList<Collaborator>> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options);
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<IReadOnlyList<User>> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options);
Task<IReadOnlyList<Collaborator>> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options);
/// <summary>
/// Checks if a user is a collaborator on a repository.
@@ -136,7 +136,7 @@ namespace Octokit
/// <param name="name">The name of the repository</param>
/// <param name="user">Username of the collaborator to check permission for</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<CollaboratorPermission> ReviewPermission(string owner, string name, string user);
Task<CollaboratorPermissionResponse> ReviewPermission(string owner, string name, string user);
/// <summary>
/// Review a user's permission level in a repository
@@ -147,7 +147,7 @@ namespace Octokit
/// <param name="repositoryId">The id of the repository</param>
/// <param name="user">Username of the collaborator to check permission for</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<CollaboratorPermission> ReviewPermission(long repositoryId, string user);
Task<CollaboratorPermissionResponse> ReviewPermission(long repositoryId, string user);
/// <summary>
/// Adds a new collaborator to the repository.

View File

@@ -4,10 +4,10 @@ using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Collaborators on a Repository.
/// A client for GitHub's Collaborators API.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28">Collaborators API documentation</a> for more details.
/// </remarks>
public class RepoCollaboratorsClient : ApiClient, IRepoCollaboratorsClient
{
@@ -24,13 +24,13 @@ namespace Octokit
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
[ManualRoute("GET", "/repos/{owner}/{repo}/collaborators")]
public Task<IReadOnlyList<User>> GetAll(string owner, string name)
public Task<IReadOnlyList<Collaborator>> GetAll(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
@@ -42,12 +42,12 @@ namespace Octokit
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
[ManualRoute("GET", "/repository/{id}/collaborators")]
public Task<IReadOnlyList<User>> GetAll(long repositoryId)
public Task<IReadOnlyList<Collaborator>> GetAll(long repositoryId)
{
return GetAll(repositoryId, ApiOptions.None);
}
@@ -56,14 +56,14 @@ namespace Octokit
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
[ManualRoute("GET", "/repos/{owner}/{repo}/collaborators")]
public Task<IReadOnlyList<User>> GetAll(string owner, string name, ApiOptions options)
public Task<IReadOnlyList<Collaborator>> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
@@ -76,13 +76,13 @@ namespace Octokit
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
[ManualRoute("GET", "/repository/{id}/collaborators")]
public Task<IReadOnlyList<User>> GetAll(long repositoryId, ApiOptions options)
public Task<IReadOnlyList<Collaborator>> GetAll(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
@@ -93,14 +93,14 @@ namespace Octokit
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
[ManualRoute("GET", "/repos/{owner}/{repo}/collaborators")]
public Task<IReadOnlyList<User>> GetAll(string owner, string name, RepositoryCollaboratorListRequest request)
public Task<IReadOnlyList<Collaborator>> GetAll(string owner, string name, RepositoryCollaboratorListRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
@@ -113,13 +113,13 @@ namespace Octokit
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
[ManualRoute("GET", "/repository/{id}/collaborators")]
public Task<IReadOnlyList<User>> GetAll(long repositoryId, RepositoryCollaboratorListRequest request)
public Task<IReadOnlyList<Collaborator>> GetAll(long repositoryId, RepositoryCollaboratorListRequest request)
{
Ensure.ArgumentNotNull(request, nameof(request));
@@ -130,7 +130,7 @@ namespace Octokit
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
@@ -138,14 +138,14 @@ namespace Octokit
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
[ManualRoute("GET", "/repos/{owner}/{repo}/collaborators")]
public Task<IReadOnlyList<User>> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options)
public Task<IReadOnlyList<Collaborator>> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll<User>(ApiUrls.RepoCollaborators(owner, name), request.ToParametersDictionary(), options);
return ApiConnection.GetAll<Collaborator>(ApiUrls.RepoCollaborators(owner, name), request.ToParametersDictionary(), options);
}
@@ -153,19 +153,19 @@ namespace Octokit
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="request">Used to request and filter a list of repository collaborators</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
[ManualRoute("GET", "/repository/{id}/collaborators")]
public Task<IReadOnlyList<User>> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options)
public Task<IReadOnlyList<Collaborator>> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options)
{
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll<User>(ApiUrls.RepoCollaborators(repositoryId), request.ToParametersDictionary(), options);
return ApiConnection.GetAll<Collaborator>(ApiUrls.RepoCollaborators(repositoryId), request.ToParametersDictionary(), options);
}
/// <summary>
@@ -232,14 +232,14 @@ namespace Octokit
/// <param name="user">Username of the collaborator to check permission for</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
[ManualRoute("GET", "/repos/{owner}/{repo}/collaborators/{username}/permission")]
public Task<CollaboratorPermission> ReviewPermission(string owner, string name, string user)
public Task<CollaboratorPermissionResponse> ReviewPermission(string owner, string name, string user)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(user, nameof(user));
return ApiConnection
.Get<CollaboratorPermission>(ApiUrls.RepoCollaboratorPermission(owner, name, user), null);
.Get<CollaboratorPermissionResponse>(ApiUrls.RepoCollaboratorPermission(owner, name, user), null);
}
/// <summary>
@@ -252,12 +252,12 @@ namespace Octokit
/// <param name="user">Username of the collaborator to check permission for</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
[ManualRoute("GET", "/repository/{id}/collaborators/{username}/permission")]
public Task<CollaboratorPermission> ReviewPermission(long repositoryId, string user)
public Task<CollaboratorPermissionResponse> ReviewPermission(long repositoryId, string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, nameof(user));
return ApiConnection
.Get<CollaboratorPermission>(ApiUrls.RepoCollaboratorPermission(repositoryId, user), null);
.Get<CollaboratorPermissionResponse>(ApiUrls.RepoCollaboratorPermission(repositoryId, user), null);
}
/// <summary>

View File

@@ -1,45 +1,53 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Octokit.Internal;
// Permission.cs file houses all permission-related enums / classes
// This file was created based on this suggestion https://github.com/octokit/octokit.net/issues/2323#issuecomment-1322766701
namespace Octokit
{
/// <summary>
/// Used to describe a permission level.
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public enum Permission
public enum InstallationReadWritePermissionLevel
{
/// <summary>
/// team members can pull, push and administer these repositories.
/// </summary>
[Parameter(Value = "read")]
Read,
[Parameter(Value = "write")]
Write
}
public enum InstallationReadWriteAdminPermissionLevel
{
[Parameter(Value = "read")]
Read,
[Parameter(Value = "write")]
Write,
[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>
Admin
}
public enum InstallationWritePermissionLevel
{
[Parameter(Value = "write")]
Write
}
public enum InstallationReadPermissionLevel
{
[Parameter(Value = "read")]
Read
}
/// <summary>
/// The permission to grant the team on this repository(Legacy).
/// </summary>
public enum TeamPermissionLegacy
{
[Parameter(Value = "pull")]
Pull,
[Parameter(Value = "push")]
Push,
/// <summary>
/// team members can pull, but not push to or administer these repositories
/// </summary>
[Parameter(Value = "pull")]
Pull
[Parameter(Value = "admin")]
Admin
}
/// <summary>
@@ -47,7 +55,6 @@ namespace Octokit
/// Default: pull
/// Can be one of: pull, push
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public enum TeamPermission
{
/// <summary>
@@ -63,6 +70,37 @@ namespace Octokit
Push
}
/// <summary>
/// The permission associated with the invitation for a collaborator in a repository
/// </summary>
public enum InvitationPermissionType
{
[Parameter(Value = "read")]
Read,
[Parameter(Value = "write")]
Write,
[Parameter(Value = "admin")]
Admin,
[Parameter(Value = "triage")]
Triage,
[Parameter(Value = "maintain")]
Maintain
}
public enum CollaboratorPermission
{
[Parameter(Value = "pull")]
Pull,
[Parameter(Value = "triage")]
Triage,
[Parameter(Value = "push")]
Push,
[Parameter(Value = "maintain")]
Maintain,
[Parameter(Value = "admin")]
Admin
}
/// <summary>
/// Object for team repository permissions
/// </summary>
@@ -114,13 +152,37 @@ namespace Octokit
/// </summary>
public bool Admin { get; private set; }
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture,
internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture,
$"Permissions: Pull: {Pull}, Triage: {Triage}, Push: {Push}, Maintain: {Maintain}, Admin: {Admin}");
}
}
/// <summary>
/// Object for collaborator permissions
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class CollaboratorPermissions
{
public CollaboratorPermissions() { }
public CollaboratorPermissions(bool pull, bool? triage, bool push, bool? maintain, bool admin)
{
Pull = pull;
Triage = triage;
Push = push;
Maintain = maintain;
Admin = admin;
}
public bool Pull { get; private set; }
public bool? Triage { get; private set; }
public bool Push { get; private set; }
public bool? Maintain { get; private set; }
public bool Admin { get; private set; }
internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture,
$"Permissions: Pull: {Pull}, Triage: {Triage}, Push: {Push}, Maintain: {Maintain}, Admin: {Admin}");
}
}

View File

@@ -9,22 +9,19 @@ namespace Octokit
/// <summary>
/// Used to set the permission for a collaborator.
/// </summary>
public CollaboratorRequest(Permission permissions)
public CollaboratorRequest(string permission)
{
Permission = permissions;
Permission = permission;
}
/// <summary>
/// The permission to grant the collaborator on this repository.
/// Only valid on organization-owned repositories. We accept the following permissions to be set:
/// pull, triage, push, maintain, admin and you can also specify a custom repository role name,
/// if the owning organization has defined any.
/// </summary>
public Permission Permission { get; private set; }
public string Permission { get; private set; }
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture, "Permission: {0}", Permission);
}
}
internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, $"Permission: {Permission}");
}
}

View File

@@ -26,10 +26,12 @@ namespace Octokit
/// </value>
public CollaboratorAffiliation Affiliation { get; set; }
internal string DebuggerDisplay
{
get { return string.Format(CultureInfo.InvariantCulture, "Affiliation: {0}", Affiliation); }
}
/// <summary>
/// Filter collaborators by the permissions they have on the repository. If not specified, all collaborators will be returned.
/// </summary>
public CollaboratorPermission? Permission { get; set; }
internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, $"Affiliation: {Affiliation} Permission: {Permission}");
}
/// <summary>

View File

@@ -10,7 +10,7 @@ namespace Octokit
/// <summary>
/// Used to add or update a team repository.
/// </summary>
public RepositoryPermissionRequest(Permission permission)
public RepositoryPermissionRequest(TeamPermissionLegacy permission)
{
Permission = permission;
}
@@ -18,7 +18,7 @@ namespace Octokit
/// <summary>
/// The permission to grant the team on this repository.
/// </summary>
public Permission Permission { get; private set; }
public TeamPermissionLegacy Permission { get; private set; }
internal string DebuggerDisplay
{

View File

@@ -0,0 +1,87 @@
using System.Diagnostics;
using System.Globalization;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class Collaborator
{
public Collaborator() { }
public Collaborator(string login, int id, string email, string name, string nodeId, string avatarUrl, string gravatarUrl, string url, string htmlUrl, string followersUrl, string followingUrl, string gistsUrl, string type, string starredUrl, string subscriptionsUrl, string organizationsUrl, string reposUrl, string eventsUrl, string receivedEventsUrl, bool siteAdmin, CollaboratorPermissions permissions, string roleName)
{
Login = login;
Id = id;
Email = email;
Name = name;
NodeId = nodeId;
AvatarUrl = avatarUrl;
GravatarUrl = gravatarUrl;
Url = url;
HtmlUrl = htmlUrl;
FollowersUrl = followersUrl;
FollowingUrl = followingUrl;
GistsUrl = gistsUrl;
StarredUrl = starredUrl;
SubscriptionsUrl = subscriptionsUrl;
OrganizationsUrl = organizationsUrl;
ReposUrl = reposUrl;
EventsUrl = eventsUrl;
ReceivedEventsUrl = receivedEventsUrl;
Type = type;
SiteAdmin = siteAdmin;
Permissions = permissions;
RoleName = roleName;
}
public string Login { get; protected set; }
public int Id { get; protected set; }
public string Email { get; protected set; }
public string Name { get; protected set; }
/// <summary>
/// GraphQL Node Id
/// </summary>
public string NodeId { get; protected set; }
public string AvatarUrl { get; protected set; }
public string GravatarUrl { get; protected set; }
public string Url { get; protected set; }
public string HtmlUrl { get; protected set; }
public string FollowersUrl { get; protected set; }
public string FollowingUrl { get; protected set; }
public string GistsUrl { get; protected set; }
public string StarredUrl { get; protected set; }
public string SubscriptionsUrl { get; protected set; }
public string OrganizationsUrl { get; protected set; }
public string ReposUrl { get; protected set; }
public string EventsUrl { get; protected set; }
public string ReceivedEventsUrl { get; protected set; }
public string Type { get; protected set; }
public bool SiteAdmin { get; protected set; }
public CollaboratorPermissions Permissions { get; protected set; }
public string RoleName { get; protected set; }
internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture,
$"Collaborator: Id: {Id} Login: {Login}");
}
}

View File

@@ -1,21 +0,0 @@
using System.Diagnostics;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class CollaboratorPermission
{
public CollaboratorPermission() { }
public CollaboratorPermission(PermissionLevel permission, User user)
{
Permission = permission;
User = user;
}
public StringEnum<PermissionLevel> Permission { get; private set; }
public User User { get; private set; }
internal string DebuggerDisplay => $"User: {User.Id} Permission: {Permission}";
}
}

View File

@@ -0,0 +1,28 @@
using System.Diagnostics;
namespace Octokit
{
/// <summary>
/// Based on "#/components/schemas/repository-collaborator-permission:
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class CollaboratorPermissionResponse
{
public CollaboratorPermissionResponse() { }
public CollaboratorPermissionResponse(string permission, string roleName, Collaborator collaborator)
{
Permission = permission;
RoleName = roleName;
Collaborator = collaborator;
}
public string Permission { get; private set; }
public string RoleName { get; private set; }
public Collaborator Collaborator { get; private set; }
internal string DebuggerDisplay => $"Collaborator: {Collaborator.Id} Permission: {Permission} RoleName: {RoleName}";
}
}

View File

@@ -9,16 +9,18 @@ namespace Octokit
/// Represents an application installation.
/// </summary>
/// <remarks>
/// For more information see https://developer.github.com/v3/apps/#find-installations
/// For more information see https://docs.github.com/en/rest/apps/installations?apiVersion=2022-11-28#list-app-installations-accessible-to-the-user-access-token
/// </remarks>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class Installation : InstallationId
{
public Installation() { }
public Installation(long id, User account, string accessTokenUrl, string repositoriesUrl, string htmlUrl, long appId, long targetId, AccountType targetType, InstallationPermissions permissions, IReadOnlyList<string> events, string singleFileName, string repositorySelection) : base(id)
public Installation(long id, User account, string accessTokensUrl, string repositoriesUrl, string htmlUrl, long appId, long targetId, AccountType targetType, InstallationPermissions permissions, IReadOnlyList<string> events, string singleFileName, string repositorySelection) : base(id)
{
Account = account;
AccessTokensUrl = accessTokensUrl;
RepositoriesUrl = repositoriesUrl;
HtmlUrl = htmlUrl;
AppId = appId;
TargetId = targetId;
@@ -34,6 +36,10 @@ namespace Octokit
/// </summary>
public User Account { get; private set; }
public string AccessTokensUrl { get; private set; }
public string RepositoriesUrl { get; private set; }
/// <summary>
/// The URL to view the Installation on GitHub.
/// </summary>
@@ -74,10 +80,7 @@ namespace Octokit
/// </summary>
public StringEnum<InstallationRepositorySelection> RepositorySelection { get; private set; }
internal new string DebuggerDisplay
{
get { return string.Format(CultureInfo.InvariantCulture, "Id: {0} AppId: {1}", Id, AppId); }
}
internal new string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Id: {0} AppId: {1}", Id, AppId);
}
public enum InstallationRepositorySelection

View File

@@ -1,9 +1,10 @@
using System.Diagnostics;
using System.Globalization;
using Octokit.Internal;
namespace Octokit
{
/// <summary>
/// The permissions granted to the user-to-server access token.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class InstallationPermissions
{
@@ -11,39 +12,39 @@ namespace Octokit
public InstallationPermissions
(
InstallationPermissionLevel? actions,
InstallationPermissionLevel? administration,
InstallationPermissionLevel? checks,
InstallationPermissionLevel? contents,
InstallationPermissionLevel? deployments,
InstallationPermissionLevel? environments,
InstallationPermissionLevel? issues,
InstallationPermissionLevel? metadata,
InstallationPermissionLevel? packages,
InstallationPermissionLevel? pages,
InstallationPermissionLevel? pullRequests,
InstallationPermissionLevel? repositoryAnnouncementBanners,
InstallationPermissionLevel? repositoryHooks,
InstallationPermissionLevel? repositoryProjects,
InstallationPermissionLevel? secretScanningAlerts,
InstallationPermissionLevel? secrets,
InstallationPermissionLevel? securityEvents,
InstallationPermissionLevel? singleFile,
InstallationPermissionLevel? statuses,
InstallationPermissionLevel? vulnerabilityAlerts,
InstallationPermissionLevel? workflows,
InstallationPermissionLevel? members,
InstallationPermissionLevel? organizationAdministration,
InstallationPermissionLevel? organizationCustomRoles,
InstallationPermissionLevel? organizationAnnouncementBanners,
InstallationPermissionLevel? organizationHooks,
InstallationPermissionLevel? organizationPlan,
InstallationPermissionLevel? organizationProjects,
InstallationPermissionLevel? organizationPackages,
InstallationPermissionLevel? organizationSecrets,
InstallationPermissionLevel? organizationSelfHostedRunners,
InstallationPermissionLevel? organizationUserBlocking,
InstallationPermissionLevel? teamDiscussions
InstallationReadWritePermissionLevel? actions,
InstallationReadWritePermissionLevel? administration,
InstallationReadWritePermissionLevel? checks,
InstallationReadWritePermissionLevel? contents,
InstallationReadWritePermissionLevel? deployments,
InstallationReadWritePermissionLevel? environments,
InstallationReadWritePermissionLevel? issues,
InstallationReadWritePermissionLevel? metadata,
InstallationReadWritePermissionLevel? packages,
InstallationReadWritePermissionLevel? pages,
InstallationReadWritePermissionLevel? pullRequests,
InstallationReadWritePermissionLevel? repositoryAnnouncementBanners,
InstallationReadWritePermissionLevel? repositoryHooks,
InstallationReadWriteAdminPermissionLevel? repositoryProjects,
InstallationReadWritePermissionLevel? secretScanningAlerts,
InstallationReadWritePermissionLevel? secrets,
InstallationReadWritePermissionLevel? securityEvents,
InstallationReadWritePermissionLevel? singleFile,
InstallationReadWritePermissionLevel? statuses,
InstallationReadWritePermissionLevel? vulnerabilityAlerts,
InstallationWritePermissionLevel? workflows,
InstallationReadWritePermissionLevel? members,
InstallationReadWritePermissionLevel? organizationAdministration,
InstallationReadWritePermissionLevel? organizationCustomRoles,
InstallationReadWritePermissionLevel? organizationAnnouncementBanners,
InstallationReadWritePermissionLevel? organizationHooks,
InstallationReadPermissionLevel? organizationPlan,
InstallationReadWriteAdminPermissionLevel? organizationProjects,
InstallationReadWritePermissionLevel? organizationPackages,
InstallationReadWritePermissionLevel? organizationSecrets,
InstallationReadWritePermissionLevel? organizationSelfHostedRunners,
InstallationReadWritePermissionLevel? organizationUserBlocking,
InstallationReadWritePermissionLevel? teamDiscussions
)
{
Actions = actions;
@@ -84,180 +85,168 @@ namespace Octokit
/// <summary>
/// The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Actions { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Actions { get; private set; }
/// <summary>
/// The level of permission to grant the access token for repository creation, deletion, settings, teams, and collaborators creation.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Administration { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Administration { get; private set; }
/// <summary>
/// The level of permission to grant the access token for checks on code.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Checks { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Checks { get; private set; }
/// <summary>
/// The level of permission to grant the access token for repository contents, commits, branches, downloads, releases, and merges.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Contents { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Contents { get; private set; }
/// <summary>
/// The level of permission to grant the access token for deployments and deployment statuses.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Deployments { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Deployments { get; private set; }
/// <summary>
/// The level of permission to grant the access token for managing repository environments.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Environments { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Environments { get; private set; }
/// <summary>
/// The level of permission to grant the access token for issues and related comments, assignees, labels, and milestones.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Issues { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Issues { get; private set; }
/// <summary>
/// The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Metadata { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Metadata { get; private set; }
/// <summary>
/// The level of permission to grant the access token for packages published to GitHub Packages.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Packages { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Packages { get; private set; }
/// <summary>
/// The level of permission to grant the access token to retrieve Pages statuses, configuration, and builds, as well as create new builds.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Pages { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Pages { get; private set; }
/// <summary>
/// The level of permission to grant the access token for pull requests and related comments, assignees, labels, milestones, and merges.
/// </summary>
public StringEnum<InstallationPermissionLevel>? PullRequests { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? PullRequests { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage announcement banners for a repository.
/// </summary>
public StringEnum<InstallationPermissionLevel>? RepositoryAnnouncementBanners { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? RepositoryAnnouncementBanners { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage the post-receive hooks for a repository.
/// </summary>
public StringEnum<InstallationPermissionLevel>? RepositoryHooks { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? RepositoryHooks { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage repository projects, columns, and cards.
/// </summary>
public StringEnum<InstallationPermissionLevel>? RepositoryProjects { get; private set; }
public StringEnum<InstallationReadWriteAdminPermissionLevel>? RepositoryProjects { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage secret scanning alerts.
/// </summary>
public StringEnum<InstallationPermissionLevel>? SecretScanningAlerts { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? SecretScanningAlerts { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage repository secrets.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Secrets { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Secrets { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage security events like code scanning alerts.
/// </summary>
public StringEnum<InstallationPermissionLevel>? SecurityEvents { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? SecurityEvents { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage just a single file.
/// </summary>
public StringEnum<InstallationPermissionLevel>? SingleFile { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? SingleFile { get; private set; }
/// <summary>
/// The level of permission to grant the access token for commit statuses.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Statuses { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Statuses { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage Dependabot alerts.
/// </summary>
public StringEnum<InstallationPermissionLevel>? VulnerabilityAlerts { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? VulnerabilityAlerts { get; private set; }
/// <summary>
/// The level of permission to grant the access token to update GitHub Actions workflow files.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Workflows { get; private set; }
public StringEnum<InstallationWritePermissionLevel>? Workflows { get; private set; }
/// <summary>
/// The level of permission to grant the access token for organization teams and members.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Members { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? Members { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage access to an organization.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationAdministration { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? OrganizationAdministration { get; private set; }
/// <summary>
/// The level of permission to grant the access token for custom roles management. This property is in beta and is subject to change.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationCustomRoles { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? OrganizationCustomRoles { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage announcement banners for an organization.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationAnnouncementBanners { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? OrganizationAnnouncementBanners { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage the post-receive hooks for an organization.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationHooks { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? OrganizationHooks { get; private set; }
/// <summary>
/// The level of permission to grant the access token for viewing an organization's plan.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationPlan { get; private set; }
public StringEnum<InstallationReadPermissionLevel>? OrganizationPlan { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage organization projects and projects beta (where available).
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationProjects { get; private set; }
public StringEnum<InstallationReadWriteAdminPermissionLevel>? OrganizationProjects { get; private set; }
/// <summary>
/// The level of permission to grant the access token for organization packages published to GitHub Packages.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationPackages { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? OrganizationPackages { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage organization secrets.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationSecrets { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? OrganizationSecrets { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage GitHub Actions self-hosted runners available to an organization.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationSelfHostedRunners { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? OrganizationSelfHostedRunners { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage users blocked by the organization.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationUserBlocking { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? OrganizationUserBlocking { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage team discussions and related comments.
/// </summary>
public StringEnum<InstallationPermissionLevel>? TeamDiscussions { get; private set; }
public StringEnum<InstallationReadWritePermissionLevel>? TeamDiscussions { get; private set; }
internal string DebuggerDisplay
{
get => $"Actions: {Actions}, Administration: {Administration}, Checks: {Checks}, Contents: {Contents}, Deployments: {Deployments}, Environments: {Environments}, Issues: {Issues}, Metadata: {Metadata}, Packages: {Packages}, Pages: {Pages}, PullRequests: {PullRequests}, RepositoryAnnouncementBanners: {RepositoryAnnouncementBanners}, RepositoryHooks: {RepositoryHooks}, RepositoryProjects: {RepositoryProjects}, SecretScanningAlerts: {SecretScanningAlerts}, Secrets: {Secrets}, SecurityEvents: {SecurityEvents}, SingleFile: {SingleFile}, Statuses: {Statuses}, VulnerabilityAlerts: {VulnerabilityAlerts}, Workflows: {Workflows}, Members: {Members}, OrganizationAdministration: {OrganizationAdministration}, OrganizationCustomRoles: {OrganizationCustomRoles}, OrganizationAnnouncementBanners: {OrganizationAnnouncementBanners}, OrganizationHooks: {OrganizationHooks}, OrganizationPlan: {OrganizationPlan}, OrganizationProjects: {OrganizationProjects}, OrganizationPackages: {OrganizationPackages}, OrganizationSecrets: {OrganizationSecrets}, OrganizationSelfHostedRunners: {OrganizationSelfHostedRunners}, OrganizationUserBlocking: {OrganizationUserBlocking}, TeamDiscussions: {TeamDiscussions}";
}
}
public enum InstallationPermissionLevel
{
[Parameter(Value = "read")]
Read,
[Parameter(Value = "write")]
Write
internal string DebuggerDisplay => $"Actions: {Actions}, Administration: {Administration}, Checks: {Checks}, Contents: {Contents}, Deployments: {Deployments}, Environments: {Environments}, Issues: {Issues}, Metadata: {Metadata}, Packages: {Packages}, Pages: {Pages}, PullRequests: {PullRequests}, RepositoryAnnouncementBanners: {RepositoryAnnouncementBanners}, RepositoryHooks: {RepositoryHooks}, RepositoryProjects: {RepositoryProjects}, SecretScanningAlerts: {SecretScanningAlerts}, Secrets: {Secrets}, SecurityEvents: {SecurityEvents}, SingleFile: {SingleFile}, Statuses: {Statuses}, VulnerabilityAlerts: {VulnerabilityAlerts}, Workflows: {Workflows}, Members: {Members}, OrganizationAdministration: {OrganizationAdministration}, OrganizationCustomRoles: {OrganizationCustomRoles}, OrganizationAnnouncementBanners: {OrganizationAnnouncementBanners}, OrganizationHooks: {OrganizationHooks}, OrganizationPlan: {OrganizationPlan}, OrganizationProjects: {OrganizationProjects}, OrganizationPackages: {OrganizationPackages}, OrganizationSecrets: {OrganizationSecrets}, OrganizationSelfHostedRunners: {OrganizationSelfHostedRunners}, OrganizationUserBlocking: {OrganizationUserBlocking}, TeamDiscussions: {TeamDiscussions}";
}
}

View File

@@ -1,16 +0,0 @@
using Octokit.Internal;
namespace Octokit
{
public enum PermissionLevel
{
[Parameter(Value = "admin")]
Admin,
[Parameter(Value = "write")]
Write,
[Parameter(Value = "read")]
Read,
[Parameter(Value = "none")]
None
}
}

View File

@@ -1,28 +1,18 @@
using System;
using System.Diagnostics;
using System.Globalization;
using Octokit.Internal;
namespace Octokit
{
public enum InvitationPermissionType
{
[Parameter(Value = "read")]
Read,
[Parameter(Value = "write")]
Write,
[Parameter(Value = "admin")]
Admin
}
/// <summary>
/// Repository invitations let you manage who you collaborate with.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RepositoryInvitation
{
public RepositoryInvitation() { }
public RepositoryInvitation(int id, string nodeId, Repository repository, User invitee, User inviter, InvitationPermissionType permissions, DateTimeOffset createdAt, string url, string htmlUrl)
public RepositoryInvitation(int id, string nodeId, Repository repository, User invitee, User inviter, InvitationPermissionType permissions, DateTimeOffset createdAt, bool expired, string url, string htmlUrl)
{
Id = id;
NodeId = nodeId;
@@ -31,10 +21,14 @@ namespace Octokit
Inviter = inviter;
Permissions = permissions;
CreatedAt = createdAt;
Expired = expired;
Url = url;
HtmlUrl = htmlUrl;
}
/// <summary>
/// Unique identifier of the repository invitation.
/// </summary>
public int Id { get; private set; }
/// <summary>
@@ -48,21 +42,26 @@ namespace Octokit
public User Inviter { get; private set; }
/// <summary>
/// The permission associated with the invitation.
/// </summary>
public StringEnum<InvitationPermissionType> Permissions { get; private set; }
public DateTimeOffset CreatedAt { get; private set; }
/// <summary>
/// Whether or not the invitation has expired
/// </summary>
public bool Expired { get; private set; }
/// <summary>
/// URL for the repository invitation
/// </summary>
public string Url { get; private set; }
public string HtmlUrl { get; private set; }
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture,
internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture,
"Repository Invitation: Id: {0} Permissions: {1}", Id, Permissions);
}
}
}
}