Files
octokit.net/Octokit/Clients/ITeamsClient.cs
2016-06-06 19:25:30 +02:00

193 lines
9.1 KiB
C#

using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
#if NET_45
using System.Collections.Generic;
#endif
namespace Octokit
{
/// <summary>
/// A client for GitHub's Organization Teams API.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/orgs/teams/">Organization Teams API documentation</a> for more information.
/// </remarks>
public interface ITeamsClient
{
/// <summary>
/// Gets a single <see cref="Team"/> by identifier.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/orgs/teams/#get-team
/// </remarks>
/// <param name="id">The team identifier.</param>
/// <returns>The <see cref="Team"/> with the given identifier.</returns>
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "Method makes a network request")]
Task<Team> Get(int id);
/// <summary>
/// Returns all <see cref="Team" />s for the current org.
/// </summary>
/// <param name="org">Organization for which to list all teams.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the orgs's teams <see cref="Team"/>s.</returns>
Task<IReadOnlyList<Team>> GetAll(string org);
/// <summary>
/// Returns all <see cref="Team" />s for the current org.
/// </summary>
/// <param name="org">Organization for which to list all teams.</param>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the orgs's teams <see cref="Team"/>s.</returns>
Task<IReadOnlyList<Team>> GetAll(string org, ApiOptions options);
/// <summary>
/// Returns all <see cref="Team" />s for the current user.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the user's <see cref="Team"/>s.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
Task<IReadOnlyList<Team>> GetAllForCurrent();
/// <summary>
/// Returns all <see cref="Team" />s for the current user.
/// </summary>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the user's <see cref="Team"/>s.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
Task<IReadOnlyList<Team>> GetAllForCurrent(ApiOptions options);
/// <summary>
/// Returns all members of the given team.
/// </summary>
/// <param name="id">The team identifier</param>
/// <remarks>
/// https://developer.github.com/v3/orgs/teams/#list-team-members
/// </remarks>
/// <returns>A list of the team's member <see cref="User"/>s.</returns>
Task<IReadOnlyList<User>> GetAllMembers(int id);
/// <summary>
/// Returns all members of the given team.
/// </summary>
/// <param name="id">The team identifier</param>
/// <param name="options">Options to change API behaviour.</param>
/// <remarks>
/// https://developer.github.com/v3/orgs/teams/#list-team-members
/// </remarks>
/// <returns>A list of the team's member <see cref="User"/>s.</returns>
Task<IReadOnlyList<User>> GetAllMembers(int id, ApiOptions options);
/// <summary>
/// Returns newly created <see cref="Team" /> for the current org.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>Newly created <see cref="Team"/></returns>
Task<Team> Create(string org, NewTeam team);
/// <summary>
/// Returns updated <see cref="Team" /> for the current org.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>Updated <see cref="Team"/></returns>
Task<Team> Update(int id, UpdateTeam team);
/// <summary>
/// Delte a team - must have owner permissions to this
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
Task Delete(int id);
/// <summary>
/// Adds a <see cref="User"/> to a <see cref="Team"/>.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/orgs/teams/#add-team-member">API documentation</a> for more information.
/// </remarks>
/// <param name="id">The team identifier.</param>
/// <param name="login">The user to add to the team.</param>
/// <exception cref="ApiValidationException">Thrown if you attempt to add an organization to a team.</exception>
/// <returns>A <see cref="TeamMembership"/> result indicating the membership status</returns>
Task<TeamMembership> AddMembership(int id, string login);
/// <summary>
/// Removes a <see cref="User"/> from a <see cref="Team"/>.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/orgs/teams/#remove-team-member">API documentation</a> for more information.
/// </remarks>
/// <param name="id">The team identifier.</param>
/// <param name="login">The user to remove from the team.</param>
/// <returns><see langword="true"/> if the user was removed from the team; <see langword="false"/> otherwise.</returns>
Task<bool> RemoveMembership(int id, string login);
/// <summary>
/// Gets whether the user with the given <paramref name="login"/>
/// is a member of the team with the given <paramref name="id"/>.
/// </summary>
/// <param name="id">The team to check.</param>
/// <param name="login">The user to check.</param>
/// <returns>A <see cref="TeamMembership"/> result indicating the membership status</returns>
Task<TeamMembership> GetMembership(int id, string login);
/// <summary>
/// Returns all team's repositories.
/// </summary>
/// <param name="id">Team Id to list repos.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The team's repositories</returns>
Task<IReadOnlyList<Repository>> GetAllRepositories(int id);
/// <summary>
/// Returns all team's repositories.
/// </summary>
/// <param name="id">Team Id to list repos.</param>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The team's repositories</returns>
Task<IReadOnlyList<Repository>> GetAllRepositories(int id, ApiOptions options);
/// <summary>
/// Add a repository to the team
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
Task<bool> AddRepository(int id, string organization, string repoName);
/// <summary>
/// Add a repository to the team
/// </summary>
/// <param name="id">The team identifier.</param>
/// <param name="organization">Org to associate the repo with.</param>
/// <param name="repoName">Name of the repo.</param>
/// <param name="permission">The permission to grant the team on this repository.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
Task<bool> AddRepository(int id, string organization, string repoName, RepositoryPermissionRequest permission);
/// <summary>
/// Remove a repository from the team
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
Task<bool> RemoveRepository(int id, string organization, string repoName);
/// <summary>
/// Gets whether or not the given repository is managed by the given team.
/// </summary>
/// <param name="id">The team identifier</param>
/// <param name="owner">Owner of the org the team is associated with.</param>
/// <param name="repo">Name of the repo.</param>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/orgs/teams/#get-team-repo">API documentation</a> for more information.
/// </remarks>
/// <returns><see langword="true"/> if the repository is managed by the given team; <see langword="false"/> otherwise.</returns>
Task<bool> IsRepositoryManagedByTeam(int id, string owner, string repo);
}
}