mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 12:26:18 +00:00
Implement Observable Organization Members API
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableOrganizationMembersClient : IObservableOrganizationMembersClient
|
||||
{
|
||||
readonly IOrganizationMembersClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableOrganizationMembersClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Organization.Member;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// List all users who are members of an organization. A member is a user that
|
||||
/// belongs to at least 1 team in the organization.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If the authenticated user is also an owner of this organization then both
|
||||
/// concealed and public member will be returned.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If the requester is not an owner of the organization the query will be redirected
|
||||
/// to the public members list.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/orgs/members/#members-list">API documentation</a>
|
||||
/// for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<User> GetAll(string org)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Members(org));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all users who have publicized their membership of the organization.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/orgs/members/#public-members-list</remarks>
|
||||
/// <param name="org"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<User> GetPublic(string org)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.PublicMembers(org));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a user is, publicly or privately, a member of the organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/orgs/members/#check-membership">API documentation</a>
|
||||
/// for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<bool> CheckMember(string org, string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return _client.CheckMember(org, user).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check is a user is publicly a member of the organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/orgs/members/#check-public-membership">API documentation</a>
|
||||
/// for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<bool> CheckMemberPublic(string org, string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return _client.CheckMemberPublic(org, user).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a user from the organization, this will also remove them from all teams
|
||||
/// within the organization and they will no longer have any access to the organization's
|
||||
/// repositories.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/orgs/members/#remove-a-member">API documentation</a>
|
||||
/// for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Unit> Delete(string org, string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return _client.Delete(org, user).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make the authenticated user's organization membership public.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method requires authentication.
|
||||
/// See the <a href="http://developer.github.com/v3/orgs/members/#publicize-a-users-membership">API documentation</a>
|
||||
/// for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<bool> Publicize(string org, string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return _client.Publicize(org, user).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make the authenticated user's organization membership private.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method requries authentication.
|
||||
/// See the <a href="http://developer.github.com/v3/orgs/members/#conceal-a-users-membership">API documentation</a>
|
||||
/// for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Unit> Conceal(string org, string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return _client.Conceal(org, user).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user