From 605500b34f0b1f0e1b49b8dfe0d520d95336499e Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Tue, 8 Jul 2014 11:42:59 +0930 Subject: [PATCH] actually implement the thing --- .../Clients/ObservableUserKeysClient.cs | 20 +++++++++++++++++++ Octokit.Reactive/Octokit.Reactive-Mono.csproj | 2 ++ .../Octokit.Reactive-MonoAndroid.csproj | 2 ++ .../Octokit.Reactive-Monotouch.csproj | 2 ++ Octokit/Clients/UserKeysClient.cs | 4 ++-- Octokit/Helpers/ApiUrls.Keys.cs | 19 ++++++++++++++++++ Octokit/Helpers/ApiUrls.cs | 2 +- Octokit/Models/Request/PublicKey.cs | 8 ++++++++ Octokit/Octokit-Mono.csproj | 1 + Octokit/Octokit-MonoAndroid.csproj | 1 + Octokit/Octokit-Monotouch.csproj | 1 + Octokit/Octokit-Portable.csproj | 1 + Octokit/Octokit-netcore45.csproj | 1 + Octokit/Octokit.csproj | 1 + 14 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 Octokit/Helpers/ApiUrls.Keys.cs diff --git a/Octokit.Reactive/Clients/ObservableUserKeysClient.cs b/Octokit.Reactive/Clients/ObservableUserKeysClient.cs index 2ec1de04..8e43bdd8 100644 --- a/Octokit.Reactive/Clients/ObservableUserKeysClient.cs +++ b/Octokit.Reactive/Clients/ObservableUserKeysClient.cs @@ -4,6 +4,12 @@ using System.Reactive.Threading.Tasks; namespace Octokit.Reactive { + /// + /// A client for GitHub's User Keys API. + /// + /// + /// See the User Keys API documentation for more information. + /// public class ObservableUserKeysClient : IObservableUserKeysClient { readonly IUserKeysClient _client; @@ -15,11 +21,25 @@ namespace Octokit.Reactive _client = client.User.Keys; } + /// + /// Gets all public keys for the authenticated user. + /// + /// + /// https://developer.github.com/v3/users/keys/#list-your-public-keys + /// + /// The s for the authenticated user. public IObservable GetAll() { return _client.GetAll().ToObservable().SelectMany(k => k); } + /// + /// Gets all verified public keys for a user. + /// + /// + /// https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user + /// + /// The s for the user. public IObservable GetAll(string userName) { return _client.GetAll(userName).ToObservable().SelectMany(k => k); diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index 153a4e0e..e952a858 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -144,6 +144,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index dac209cf..33dfb655 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -153,6 +153,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index 581837d2..03e99810 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -148,6 +148,8 @@ + + diff --git a/Octokit/Clients/UserKeysClient.cs b/Octokit/Clients/UserKeysClient.cs index 15df5bbe..29cc3fb7 100644 --- a/Octokit/Clients/UserKeysClient.cs +++ b/Octokit/Clients/UserKeysClient.cs @@ -25,7 +25,7 @@ namespace Octokit /// The s for the authenticated user. public Task> GetAll() { - return null; + return ApiConnection.GetAll(ApiUrls.Keys()); } /// @@ -37,7 +37,7 @@ namespace Octokit /// The s for the user. public Task> GetAll(string userName) { - return null; + return ApiConnection.GetAll(ApiUrls.Keys(userName)); } } } \ No newline at end of file diff --git a/Octokit/Helpers/ApiUrls.Keys.cs b/Octokit/Helpers/ApiUrls.Keys.cs new file mode 100644 index 00000000..b936322e --- /dev/null +++ b/Octokit/Helpers/ApiUrls.Keys.cs @@ -0,0 +1,19 @@ +using System; + +namespace Octokit +{ + public static partial class ApiUrls + { + static readonly Uri _currentUserKeysUrl = new Uri("user/keys", UriKind.Relative); + + public static Uri Keys() + { + return _currentUserKeysUrl; + } + + public static Uri Keys(string userName) + { + return "users/{0}/keys".FormatUri(userName); + } + } +} diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 39021fd8..44dc39e2 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -5,7 +5,7 @@ namespace Octokit /// /// Class for retrieving GitHub ApI URLs /// - public static class ApiUrls + public static partial class ApiUrls { static readonly Uri _currentUserRepositoriesUrl = new Uri("user/repos", UriKind.Relative); static readonly Uri _currentUserOrganizationsUrl = new Uri("user/orgs", UriKind.Relative); diff --git a/Octokit/Models/Request/PublicKey.cs b/Octokit/Models/Request/PublicKey.cs index 3e8fc431..7df9949b 100644 --- a/Octokit/Models/Request/PublicKey.cs +++ b/Octokit/Models/Request/PublicKey.cs @@ -7,7 +7,15 @@ namespace Octokit { public int Id { get; set; } public string Key { get; set; } + + /// + /// Only visible for the current user, or with the correct OAuth scope + /// public string Url { get; set; } + + /// + /// Only visible for the current user, or with the correct OAuth scope + /// public string Title { get; set; } internal string DebuggerDisplay diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 82ac725a..f3c0ab1c 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -327,6 +327,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index ff10f3b6..a61ab64a 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -337,6 +337,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 578182e0..5d8d0105 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -332,6 +332,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 09eec189..c12471e3 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -324,6 +324,7 @@ + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 1aa16020..3711032b 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -328,6 +328,7 @@ + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index b01b97a6..336b6cbe 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -69,6 +69,7 @@ +