diff --git a/Octokit.Reactive/Clients/IObservableUserKeysClient.cs b/Octokit.Reactive/Clients/IObservableUserKeysClient.cs index 4c5aa927..333a479c 100644 --- a/Octokit.Reactive/Clients/IObservableUserKeysClient.cs +++ b/Octokit.Reactive/Clients/IObservableUserKeysClient.cs @@ -13,14 +13,14 @@ namespace Octokit.Reactive public interface IObservableUserKeysClient { /// - /// Gets all public keys for the authenticated user. + /// Gets all verified public keys for a user. /// /// - /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user /// - /// - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - IObservable GetAllForCurrent(); + /// The @ handle of the user. + /// Lists the verified public keys for a user. + IObservable GetAll(string userName); /// /// Gets all verified public keys for a user. @@ -28,8 +28,31 @@ namespace Octokit.Reactive /// /// https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user /// - /// - IObservable GetAll(string userName); + /// The @ handle of the user. + /// Options to change API's behavior. + /// Lists the verified public keys for a user. + IObservable GetAll(string userName, ApiOptions options); + + /// + /// Gets all public keys for the authenticated user. + /// + /// + /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// + /// Lists the current user's keys. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetAllForCurrent(); + + /// + /// Gets all public keys for the authenticated user. + /// + /// + /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// + /// Options to change API's behavior. + /// Lists the current user's keys. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetAllForCurrent(ApiOptions options); /// /// Retrieves the for the specified id. @@ -38,7 +61,7 @@ namespace Octokit.Reactive /// https://developer.github.com/v3/users/keys/#get-a-single-public-key /// /// The ID of the SSH key - /// + /// View extended details for a single public key. [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] IObservable Get(int id); @@ -49,7 +72,7 @@ namespace Octokit.Reactive /// https://developer.github.com/v3/users/keys/#create-a-public-key /// /// The SSH Key contents - /// + /// Creates a public key. IObservable Create(NewPublicKey newKey); /// @@ -59,7 +82,7 @@ namespace Octokit.Reactive /// https://developer.github.com/v3/users/keys/#delete-a-public-key /// /// The id of the key to delete - /// + /// Removes a public key. IObservable Delete(int id); } } diff --git a/Octokit.Reactive/Clients/ObservableUserKeysClient.cs b/Octokit.Reactive/Clients/ObservableUserKeysClient.cs index 1b563b94..cc3590b4 100644 --- a/Octokit.Reactive/Clients/ObservableUserKeysClient.cs +++ b/Octokit.Reactive/Clients/ObservableUserKeysClient.cs @@ -23,15 +23,18 @@ namespace Octokit.Reactive } /// - /// Gets all public keys for the authenticated user. + /// Gets all verified public keys for a user. /// /// - /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user /// - /// - public IObservable GetAllForCurrent() + /// The @ handle of the user. + /// Lists the verified public keys for a user. + public IObservable GetAll(string userName) { - return _client.GetAllForCurrent().ToObservable().SelectMany(k => k); + Ensure.ArgumentNotNullOrEmptyString(userName, "userName"); + + return GetAll(userName, ApiOptions.None); } /// @@ -40,10 +43,42 @@ namespace Octokit.Reactive /// /// https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user /// - /// - public IObservable GetAll(string userName) + /// The @ handle of the user. + /// Options to change API's behavior. + /// Lists the verified public keys for a user. + public IObservable GetAll(string userName, ApiOptions options) { - return _client.GetAll(userName).ToObservable().SelectMany(k => k); + Ensure.ArgumentNotNullOrEmptyString(userName, "userName"); + Ensure.ArgumentNotNull(options, "options"); + + return _client.GetAll(userName, options).ToObservable().SelectMany(k => k); + } + + /// + /// Gets all public keys for the authenticated user. + /// + /// + /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// + /// Lists the current user's keys. + public IObservable GetAllForCurrent() + { + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// Gets all public keys for the authenticated user. + /// + /// + /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// + /// Options to change API's behavior. + /// Lists the current user's keys. + public IObservable GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _client.GetAllForCurrent(options).ToObservable().SelectMany(k => k); } /// @@ -53,7 +88,7 @@ namespace Octokit.Reactive /// https://developer.github.com/v3/users/keys/#get-a-single-public-key /// /// The ID of the SSH key - /// + /// View extended details for a single public key. public IObservable Get(int id) { return _client.Get(id).ToObservable(); @@ -66,7 +101,7 @@ namespace Octokit.Reactive /// https://developer.github.com/v3/users/keys/#create-a-public-key /// /// The SSH Key contents - /// + /// Creates a public key. public IObservable Create(NewPublicKey newKey) { Ensure.ArgumentNotNull(newKey, "newKey"); @@ -81,7 +116,7 @@ namespace Octokit.Reactive /// https://developer.github.com/v3/users/keys/#delete-a-public-key /// /// The id of the key to delete - /// + /// Removes a public key. public IObservable Delete(int id) { return _client.Delete(id).ToObservable(); diff --git a/Octokit.Tests/Clients/UserKeysClientTests.cs b/Octokit.Tests/Clients/UserKeysClientTests.cs index d1a044d8..2e80491e 100644 --- a/Octokit.Tests/Clients/UserKeysClientTests.cs +++ b/Octokit.Tests/Clients/UserKeysClientTests.cs @@ -19,7 +19,8 @@ namespace Octokit.Tests.Clients client.GetAllForCurrent(); connection.Received().GetAll( - Arg.Is(u => u.ToString() == expectedUri)); + Arg.Is(u => u.ToString() == expectedUri), + Arg.Any()); } } @@ -30,6 +31,7 @@ namespace Octokit.Tests.Clients { var client = new UserKeysClient(Substitute.For()); await Assert.ThrowsAsync(() => client.GetAll(null)); + await Assert.ThrowsAsync(() => client.GetAll("fake", null)); } [Fact] @@ -50,7 +52,8 @@ namespace Octokit.Tests.Clients client.GetAll("auser"); connection.Received().GetAll( - Arg.Is(u => u.ToString() == expectedUri)); + Arg.Is(u => u.ToString() == expectedUri), + Arg.Any()); } } diff --git a/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs b/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs index 385a5a1f..700e5f42 100644 --- a/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs @@ -17,7 +17,7 @@ namespace Octokit.Tests.Reactive client.GetAllForCurrent(); - gitHubClient.User.Keys.Received().GetAllForCurrent(); + gitHubClient.User.Keys.Received().GetAllForCurrent(Arg.Any()); } } @@ -31,7 +31,7 @@ namespace Octokit.Tests.Reactive client.GetAll("auser"); - gitHubClient.User.Keys.Received().GetAll("auser"); + gitHubClient.User.Keys.Received().GetAll("auser", Arg.Any()); } } diff --git a/Octokit/Clients/IUserKeysClient.cs b/Octokit/Clients/IUserKeysClient.cs index 41b5a76b..bc85ee62 100644 --- a/Octokit/Clients/IUserKeysClient.cs +++ b/Octokit/Clients/IUserKeysClient.cs @@ -13,14 +13,14 @@ namespace Octokit public interface IUserKeysClient { /// - /// Gets all public keys for the authenticated user. + /// Gets all verified public keys for a user. /// /// - /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user /// - /// - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - Task> GetAllForCurrent(); + /// The @ handle of the user. + /// Lists the verified public keys for a user. + Task> GetAll(string userName); /// /// Gets all verified public keys for a user. @@ -28,8 +28,31 @@ namespace Octokit /// /// https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user /// - /// - Task> GetAll(string userName); + /// The @ handle of the user. + /// Options to change API's behavior. + /// Lists the verified public keys for a user. + Task> GetAll(string userName, ApiOptions options); + + /// + /// Gets all public keys for the authenticated user. + /// + /// + /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// + /// Lists the current user's keys. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task> GetAllForCurrent(); + + /// + /// Gets all public keys for the authenticated user. + /// + /// + /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// + /// Options to change API's behavior. + /// Lists the current user's keys. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task> GetAllForCurrent(ApiOptions options); /// /// Retrieves the for the specified id. @@ -38,7 +61,7 @@ namespace Octokit /// https://developer.github.com/v3/users/keys/#get-a-single-public-key /// /// The ID of the SSH key - /// + /// View extended details for a single public key. [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task Get(int id); @@ -49,7 +72,7 @@ namespace Octokit /// https://developer.github.com/v3/users/keys/#create-a-public-key /// /// The SSH Key contents - /// + /// Creates a public key. Task Create(NewPublicKey newKey); /// @@ -59,7 +82,7 @@ namespace Octokit /// https://developer.github.com/v3/users/keys/#delete-a-public-key /// /// The id of the key to delete - /// + /// Removes a public key. Task Delete(int id); } } diff --git a/Octokit/Clients/UserKeysClient.cs b/Octokit/Clients/UserKeysClient.cs index cc8dee50..928f241a 100644 --- a/Octokit/Clients/UserKeysClient.cs +++ b/Octokit/Clients/UserKeysClient.cs @@ -17,15 +17,18 @@ namespace Octokit } /// - /// Gets all public keys for the authenticated user. + /// Gets all verified public keys for a user. /// /// - /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user /// - /// - public Task> GetAllForCurrent() + /// The @ handle of the user. + /// Lists the verified public keys for a user. + public Task> GetAll(string userName) { - return ApiConnection.GetAll(ApiUrls.Keys()); + Ensure.ArgumentNotNullOrEmptyString(userName, "userName"); + + return GetAll(userName, ApiOptions.None); } /// @@ -34,12 +37,42 @@ namespace Octokit /// /// https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user /// - /// - public Task> GetAll(string userName) + /// The @ handle of the user. + /// Options to change API's behavior. + /// Lists the verified public keys for a user. + public Task> GetAll(string userName, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(userName, "userName"); + Ensure.ArgumentNotNull(options, "options"); - return ApiConnection.GetAll(ApiUrls.Keys(userName)); + return ApiConnection.GetAll(ApiUrls.Keys(userName), options); + } + + /// + /// Gets all public keys for the authenticated user. + /// + /// + /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// + /// Lists the current user's keys. + public Task> GetAllForCurrent() + { + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// Gets all public keys for the authenticated user. + /// + /// + /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// + /// Options to chagne API's behavior. + /// Lists the current user's keys. + public Task> GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Keys(), options); } ///