Files
octokit.net/Octokit/Clients/UsersClient.cs
Ryan Gribble 046c5a36cc Rename client.User.Keys to client.User.GitSshKey
Mark client.User.Keys as [Obsolete]
2016-06-09 06:44:28 +10:00

117 lines
4.5 KiB
C#

using System;
using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Users API.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/">Users API documentation</a> for more information.
/// </remarks>
public class UsersClient : ApiClient, IUsersClient
{
static readonly Uri _userEndpoint = new Uri("user", UriKind.Relative);
/// <summary>
/// Instantiates a new GitHub Users API client.
/// </summary>
/// <param name="apiConnection">An API connection</param>
public UsersClient(IApiConnection apiConnection) : base(apiConnection)
{
Email = new UserEmailsClient(apiConnection);
Followers = new FollowersClient(apiConnection);
#pragma warning disable CS0618 // Type or member is obsolete
Keys = new UserKeysClient(apiConnection);
#pragma warning restore CS0618 // Type or member is obsolete
GitSshKey = new UserKeysClient(apiConnection);
GpgKey = new UserGpgKeysClient(apiConnection);
Administration = new UserAdministrationClient(apiConnection);
}
/// <summary>
/// A client for GitHub's User Emails API
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/emails/">Emails API documentation</a> for more information.
///</remarks>
public IUserEmailsClient Email { get; private set; }
/// <summary>
/// A client for GitHub's User Keys API
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/keys/">Keys API documentation</a> for more information.
///</remarks>
[Obsolete("Ssh key information is now available under the GitSshKey property. This will be removed in a future update.")]
public IUserKeysClient Keys { get; private set; }
/// <summary>
/// A client for GitHub's User Keys API
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/keys/">Keys API documentation</a> for more information.
///</remarks>
public IUserKeysClient GitSshKey { get; private set; }
/// <summary>
/// A client for GitHub's UserUser GPG Keys API.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/users/gpg_keys/">User GPG Keys documentation</a> for more information.
/// </remarks>
public IUserGpgKeysClient GpgKey { get; private set; }
/// <summary>
/// Returns the user specified by the login.
/// </summary>
/// <param name="login">The login name for the user</param>
public Task<User> Get(string login)
{
Ensure.ArgumentNotNullOrEmptyString(login, "login");
return ApiConnection.Get<User>(ApiUrls.User(login));
}
/// <summary>
/// Returns a <see cref="User"/> for the current authenticated user.
/// </summary>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
/// <returns>A <see cref="User"/></returns>
public Task<User> Current()
{
return ApiConnection.Get<User>(_userEndpoint);
}
/// <summary>
/// Update the specified <see cref="UserUpdate"/>.
/// </summary>
/// <param name="user">The login for the user</param>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
/// <returns>A <see cref="User"/></returns>
public Task<User> Update(UserUpdate user)
{
Ensure.ArgumentNotNull(user, "user");
return ApiConnection.Patch<User>(_userEndpoint, user);
}
/// <summary>
/// A client for GitHub's User Followers API
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/followers/">Followers API documentation</a> for more information.
///</remarks>
public IFollowersClient Followers { get; private set; }
/// <summary>
/// A client for GitHub's User Administration API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/users/administration/">User Administration API documentation</a> for more information.
///</remarks>
public IUserAdministrationClient Administration { get; private set; }
}
}