mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-05-28 08:58:37 +00:00
Implement Observable Organization Members API
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableOrganizationMembersClient
|
||||
{
|
||||
/// <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>
|
||||
IObservable<User> GetAll(string 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>
|
||||
IObservable<User> GetPublic(string 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>
|
||||
IObservable<bool> CheckMember(string org, string user);
|
||||
|
||||
/// <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>
|
||||
IObservable<bool> CheckMemberPublic(string org, string user);
|
||||
|
||||
/// <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>
|
||||
IObservable<Unit> Delete(string org, string user);
|
||||
|
||||
/// <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>
|
||||
IObservable<bool> Publicize(string org, string user);
|
||||
|
||||
/// <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>
|
||||
IObservable<Unit> Conceal(string org, string user);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,7 @@
|
||||
</Compile>
|
||||
<Compile Include="Clients\IObservableEventsClient.cs" />
|
||||
<Compile Include="Clients\ObservableEventsClient.cs" />
|
||||
<Compile Include="Clients\IObservableOrganizationMembersClient.cs" />
|
||||
<Compile Include="Clients\ObservableGitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\IObservableGitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\IObservableTagsClient.cs" />
|
||||
@@ -92,6 +93,7 @@
|
||||
<Compile Include="Clients\ObservableNotificationsClient.cs" />
|
||||
<Compile Include="Clients\ObservableAuthorizationsClient.cs" />
|
||||
<Compile Include="Clients\ObservableMiscellaneousClient.cs" />
|
||||
<Compile Include="Clients\ObservableOrganizationMembersClient.cs" />
|
||||
<Compile Include="Clients\ObservableOrganizationsClient.cs" />
|
||||
<Compile Include="Clients\ObservableReleasesClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoriesClient.cs" />
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Octokit
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
|
||||
return ApiConnection.GetAll<User>("orgs/{0}/members".FormatUri(org));
|
||||
return ApiConnection.GetAll<User>(ApiUrls.Members(org));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -51,7 +51,7 @@ namespace Octokit
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
|
||||
return ApiConnection.GetAll<User>("orgs/{0}/public_members".FormatUri(org));
|
||||
return ApiConnection.GetAll<User>(ApiUrls.PublicMembers(org));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -247,6 +247,26 @@ namespace Octokit
|
||||
return "repos/{0}/{1}/assignees/{2}".FormatUri(owner, name, login);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that returns all of the members of the organization
|
||||
/// </summary>
|
||||
/// <param name="org">The organization</param>
|
||||
/// <returns></returns>
|
||||
public static Uri Members(string org)
|
||||
{
|
||||
return "orgs/{0}/members".FormatUri(org);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that returns all of the public members of the organization
|
||||
/// </summary>
|
||||
/// <param name="org">Organization</param>
|
||||
/// <returns></returns>
|
||||
public static Uri PublicMembers(string org)
|
||||
{
|
||||
return "orgs/{0}/public_members".FormatUri(org);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that returns a 204 if requester is an organization member and
|
||||
/// the user is, publicly or privately a member of the organization.
|
||||
|
||||
Reference in New Issue
Block a user