diff --git a/Octokit/Clients/IOrganizationMembersClient.cs b/Octokit/Clients/IOrganizationMembersClient.cs index 3ac23eb7..860fa7c9 100644 --- a/Octokit/Clients/IOrganizationMembersClient.cs +++ b/Octokit/Clients/IOrganizationMembersClient.cs @@ -30,9 +30,32 @@ namespace Octokit /// for more information. /// /// The login for the organization - /// + /// The users Task> GetAll(string org); + /// + /// + /// 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 + Task> GetAll(string org, string filter); + /// /// List all users who have publicized their membership of the organization. /// diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 8b9a11b7..1637b421 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -72,5 +72,40 @@ namespace Octokit /// The user to check. /// if the user is a member of the team; otherwise. Task IsMember(int id, string login); + + /// + /// Add a member to the team + /// + /// Thrown when a general API error occurs. + /// + Task AddMember(int id, string login); + + /// + /// Remove a member from the team + /// + /// Thrown when a general API error occurs. + /// + Task RemoveMember(int id, string login); + + /// + /// Returns all team's repositories. + /// + /// Thrown when a general API error occurs. + /// The team's repositories + Task> GetRepositories(int id); + + /// + /// Add a repository to the team + /// + /// Thrown when a general API error occurs. + /// + Task AddRepository(int teamId, string organization, string repoName); + + /// + /// Remove a repository from the team + /// + /// Thrown when a general API error occurs. + /// + Task RemoveRepository(int teamId, string organization, string repoName); } } diff --git a/Octokit/Clients/OrganizationMembersClient.cs b/Octokit/Clients/OrganizationMembersClient.cs index 0c892066..15149d20 100644 --- a/Octokit/Clients/OrganizationMembersClient.cs +++ b/Octokit/Clients/OrganizationMembersClient.cs @@ -39,7 +39,7 @@ namespace Octokit /// for more information. /// /// The login for the organization - /// + /// The users public Task> GetAll(string org) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); @@ -47,6 +47,35 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.Members(org)); } + /// + /// + /// 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, string filter) + { + Ensure.ArgumentNotNullOrEmptyString(org, "org"); + Ensure.ArgumentNotNullOrEmptyString(filter, "filter"); + + return ApiConnection.GetAll(ApiUrls.Members(org, filter)); + } + /// /// List all users who have publicized their membership of the organization. /// diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 8b7b9d93..31529faf 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -128,5 +128,65 @@ namespace Octokit return false; } } + + /// + /// Add a member to the team + /// + /// Thrown when a general API error occurs. + /// + public Task AddMember(int id, string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + var endpoint = ApiUrls.TeamMember(id, login); + return ApiConnection.Connection.Put(endpoint); + } + + /// + /// Remove a member from the team + /// + /// Thrown when a general API error occurs. + /// + public Task RemoveMember(int id, string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + var endpoint = ApiUrls.TeamMember(id, login); + return ApiConnection.Delete(endpoint); + } + + /// + /// Returns all team's repositories. + /// + /// Thrown when a general API error occurs. + /// The team's repositories + public Task> GetRepositories(int id) + { + var endpoint = ApiUrls.TeamRepositories(id); + + return ApiConnection.GetAll(endpoint); + } + + /// + /// Add a repository to the team + /// + /// Thrown when a general API error occurs. + /// + public Task AddRepository(int teamId, string organization, string repoName) + { + var endpoint = ApiUrls.TeamRepository(teamId, organization, repoName); + return ApiConnection.Put(endpoint); + } + + /// + /// Remove a repository from the team + /// + /// Thrown when a general API error occurs. + /// + public Task RemoveRepository(int teamId, string organization, string repoName) + { + var endpoint = ApiUrls.TeamRepository(teamId, organization, repoName); + return ApiConnection.Delete(endpoint); + } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 925f40f1..1444ef22 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -332,6 +332,16 @@ namespace Octokit return "orgs/{0}/members".FormatUri(org); } + /// + /// Returns the that returns all of the members of the organization + /// + /// The organization + /// + public static Uri Members(string org, string filter) + { + return "orgs/{0}/members?filter={1}".FormatUri(org, filter); + } + /// /// Returns the that returns all of the public members of the organization /// @@ -988,6 +998,26 @@ namespace Octokit return "teams/{0}/members".FormatUri(id); } + /// + /// returns the for the repositories + /// + /// The team id + public static Uri TeamRepositories(int id) + { + return "teams/{0}/repos/".FormatUri(id); + } + + /// + /// returns the for a team repository + /// + /// The team id + /// The organization id + /// The repository name + public static Uri TeamRepository(int id, string organization, string repoName) + { + return "teams/{0}/repos/{1}/{2}".FormatUri(id, organization, repoName); + } + /// /// returns the for teams /// use for update or deleting a team