using System; 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; /// /// Initializes a new Organization Members API client. /// /// An used to make the requests public ObservableOrganizationMembersClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); _client = client.Organization.Member; _connection = client.Connection; } /// /// /// List all users who are members of an organization. A member is a user that /// belongs to at least 1 team in the organization. /// /// /// If the authenticated user is also an owner of this organization then both /// concealed and public member will be returned. /// /// /// If the requester is not an owner of the organization the query will be redirected /// to the public members list. /// /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// public IObservable GetAll(string org) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); return GetAll(org, ApiOptions.None); } /// /// /// List all users who are members of an organization. A member is a user that /// belongs to at least 1 team in the organization. /// /// /// If the authenticated user is also an owner of this organization then both /// concealed and public member will be returned. /// /// /// If the requester is not an owner of the organization the query will be redirected /// to the public members list. /// /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// Options for changing the API response /// public IObservable GetAll(string org, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages(ApiUrls.Members(org), options); } /// /// /// List all users who are members of an organization. A member is a user that /// belongs to at least 1 team in the organization. /// /// /// If the authenticated user is also an owner of this organization then both /// concealed and public member will be returned. /// /// /// If the requester is not an owner of the organization the query will be redirected /// to the public members list. /// /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// The members filter, /// public IObservable GetAll(string org, OrganizationMembersFilter filter) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); return GetAll(org, filter, ApiOptions.None); } /// /// /// List all users who are members of an organization. A member is a user that /// belongs to at least 1 team in the organization. /// /// /// If the authenticated user is also an owner of this organization then both /// concealed and public member will be returned. /// /// /// If the requester is not an owner of the organization the query will be redirected /// to the public members list. /// /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// The members filter, /// Options for changing the API response /// public IObservable GetAll(string org, OrganizationMembersFilter filter, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages(ApiUrls.Members(org, filter), options); } /// /// /// List all users who are members of an organization. A member is a user that /// belongs to at least 1 team in the organization. /// /// /// If the authenticated user is also an owner of this organization then both /// concealed and public member will be returned. /// /// /// If the requester is not an owner of the organization the query will be redirected /// to the public members list. /// /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// The role filter to use when getting the users, /// public IObservable GetAll(string org, OrganizationMembersRole role) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); return GetAll(org, role, ApiOptions.None); } /// /// /// List all users who are members of an organization. A member is a user that /// belongs to at least 1 team in the organization. /// /// /// If the authenticated user is also an owner of this organization then both /// concealed and public member will be returned. /// /// /// If the requester is not an owner of the organization the query will be redirected /// to the public members list. /// /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// The role filter to use when getting the users, /// Options for changing the API response /// public IObservable GetAll(string org, OrganizationMembersRole role, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages(ApiUrls.Members(org, role), options); } /// /// /// List all users who are members of an organization. A member is a user that /// belongs to at least 1 team in the organization. /// /// /// If the authenticated user is also an owner of this organization then both /// concealed and public member will be returned. /// /// /// If the requester is not an owner of the organization the query will be redirected /// to the public members list. /// /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// The members filter, /// The role filter to use when getting the users, /// public IObservable GetAll(string org, OrganizationMembersFilter filter, OrganizationMembersRole role) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); return GetAll(org, filter, role, ApiOptions.None); } /// /// /// List all users who are members of an organization. A member is a user that /// belongs to at least 1 team in the organization. /// /// /// If the authenticated user is also an owner of this organization then both /// concealed and public member will be returned. /// /// /// If the requester is not an owner of the organization the query will be redirected /// to the public members list. /// /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// The members filter, /// The role filter to use when getting the users, /// Options for changing the API response /// public IObservable GetAll(string org, OrganizationMembersFilter filter, OrganizationMembersRole role, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages(ApiUrls.Members(org, filter, role), options); } /// /// List all users who have publicized their membership of the organization. /// /// http://developer.github.com/v3/orgs/members/#public-members-list /// The login for the organization /// public IObservable GetAllPublic(string org) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); return GetAllPublic(org, ApiOptions.None); } /// /// List all users who have publicized their membership of the organization. /// /// http://developer.github.com/v3/orgs/members/#public-members-list /// The login for the organization /// Options for changing the API response /// public IObservable GetAllPublic(string org, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages(ApiUrls.PublicMembers(org), options); } /// /// Check if a user is, publicly or privately, a member of the organization. /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// The login for the user /// public IObservable CheckMember(string org, string user) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNullOrEmptyString(user, "user"); return _client.CheckMember(org, user).ToObservable(); } /// /// Check is a user is publicly a member of the organization. /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// The login for the user /// public IObservable CheckMemberPublic(string org, string user) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNullOrEmptyString(user, "user"); return _client.CheckMemberPublic(org, user).ToObservable(); } /// /// 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. /// /// /// See the API documentation /// for more information. /// /// The login for the organization /// The login for the user /// public IObservable Delete(string org, string user) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNullOrEmptyString(user, "user"); return _client.Delete(org, user).ToObservable(); } /// /// Make the authenticated user's organization membership public. /// /// /// This method requires authentication. /// See the API documentation /// for more information. /// /// The login for the organization /// The login for the user /// public IObservable Publicize(string org, string user) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNullOrEmptyString(user, "user"); return _client.Publicize(org, user).ToObservable(); } /// /// Make the authenticated user's organization membership private. /// /// /// This method requries authentication. /// See the API documentation /// for more information. /// /// The login for the organization /// The login for the user /// public IObservable Conceal(string org, string user) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNullOrEmptyString(user, "user"); return _client.Conceal(org, user).ToObservable(); } } }