using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Octokit.Internal;
namespace Octokit
{
///
/// Filter members in the list
///
///
/// see https://developer.github.com/v3/orgs/members/#members-list for details
///
public enum OrganizationMembersFilter
{
///
/// All members the authenticated user can see.
///
[Parameter(Value = "all")]
All,
///
/// Members without two-factor authentication enabled
///
[Parameter(Value = "2fa_disabled")]
TwoFactorAuthenticationDisabled
}
public enum OrganizationMembersRole
{
[Parameter(Value = "all")]
All,
[Parameter(Value = "admin")]
Admin,
[Parameter(Value = "member")]
Member
}
///
/// A client for GitHub's Organization Members API.
///
///
/// See the Orgs API documentation for more information.
///
public class OrganizationMembersClient : ApiClient, IOrganizationMembersClient
{
///
/// Initializes a new Organization Members API client.
///
/// An API connection
public OrganizationMembersClient(IApiConnection apiConnection) : base(apiConnection)
{
}
///
///
/// 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 users
public Task> 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
/// The users
public Task> GetAll(string org, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(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 filter to use when getting the users,
/// The users
public Task> 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 filter to use when getting the users,
/// Options for changing the API response
/// The users
public Task> GetAll(string org, OrganizationMembersFilter filter, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(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,
/// The users
public Task> 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
/// The users
public Task> GetAll(string org, OrganizationMembersRole role, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(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 filter to use when getting the users,
/// The role filter to use when getting the users,
/// The users
public Task> 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 filter to use when getting the users,
/// The role filter to use when getting the users,
/// Options for changing the API response
/// The users
public Task> GetAll(string org, OrganizationMembersFilter filter, OrganizationMembersRole role, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(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 Task> 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 Task> GetAllPublic(string org, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(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 async Task CheckMember(string org, string user)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
Ensure.ArgumentNotNullOrEmptyString(user, "user");
try
{
var response = await Connection.Get