diff --git a/Octokit/Clients/IUserGpgKeysClient.cs b/Octokit/Clients/IUserGpgKeysClient.cs
new file mode 100644
index 00000000..57c40053
--- /dev/null
+++ b/Octokit/Clients/IUserGpgKeysClient.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Octokit
+{
+ ///
+ /// A client for GitHub's UserUser GPG Keys API.
+ ///
+ ///
+ /// See the User GPG Keys documentation for more information.
+ ///
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
+ public interface IUserGpgKeysClient
+ {
+ ///
+ /// Gets all GPG keys for the authenticated user.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// A of s for the current user.
+ Task> GetAllForCurrent();
+
+ ///
+ /// Gets all GPG keys for the authenticated user.
+ ///
+ /// Options for changing the API response
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// A of s for the current user.
+ Task> GetAllForCurrent(ApiOptions options);
+
+ ///
+ /// View extended details of the for the specified id.
+ ///
+ /// The ID of the GPG key
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The for the specified ID.
+ [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
+ Justification = "Method makes a network request")]
+ Task Get(int id);
+
+ ///
+ /// Creates a new for the authenticated user.
+ ///
+ /// The new GPG key to add.
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The newly created .
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
+ Task Create(NewGpgKey newGpgKey);
+
+ ///
+ /// Deletes the GPG key for the specified ID.
+ ///
+ /// The ID of the GPG key to delete.
+ ///
+ /// See the API documentation for more information.
+ ///
+ ///
+ Task Delete(int id);
+ }
+}
diff --git a/Octokit/Clients/UserGpgKeysClient.cs b/Octokit/Clients/UserGpgKeysClient.cs
new file mode 100644
index 00000000..f7a940e6
--- /dev/null
+++ b/Octokit/Clients/UserGpgKeysClient.cs
@@ -0,0 +1,88 @@
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Threading.Tasks;
+
+namespace Octokit
+{
+ ///
+ /// A client for GitHub's UserUser GPG Keys API.
+ ///
+ ///
+ /// See the User GPG Keys documentation for more information.
+ ///
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
+ public class UserGpgKeysClient : ApiClient, IUserGpgKeysClient
+ {
+ ///
+ /// Instatiates a new GitHub User GPG Keys API client.
+ ///
+ /// The API connection.
+ public UserGpgKeysClient(IApiConnection apiConnection) : base(apiConnection)
+ {
+ }
+
+ ///
+ /// Gets all GPG keys for the authenticated user.
+ ///
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// A of s for the current user.
+ public Task> GetAllForCurrent()
+ {
+ return GetAllForCurrent(ApiOptions.None);
+ }
+
+ ///
+ /// Gets all GPG keys for the authenticated user.
+ ///
+ /// Options for changing the API response
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// A of s for the current user.
+ public Task> GetAllForCurrent(ApiOptions options)
+ {
+ return ApiConnection.GetAll(ApiUrls.GpgKeys(), null, AcceptHeaders.GpgKeysPreview, options);
+ }
+
+ ///
+ /// View extended details of the for the specified id.
+ ///
+ /// The ID of the GPG key
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The for the specified ID.
+ public Task Get(int id)
+ {
+ return ApiConnection.Get(ApiUrls.GpgKeys(id), null, AcceptHeaders.GpgKeysPreview);
+ }
+
+ ///
+ /// Creates a new for the authenticated user.
+ ///
+ /// The new GPG key to add.
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// The newly created .
+ public Task Create(NewGpgKey newGpgKey)
+ {
+ return ApiConnection.Post(ApiUrls.GpgKeys(), newGpgKey);
+ }
+
+ ///
+ /// Deletes the GPG key for the specified ID.
+ ///
+ /// The ID of the GPG key to delete.
+ ///
+ /// See the API documentation for more information.
+ ///
+ ///
+ public Task Delete(int id)
+ {
+ return ApiConnection.Delete(ApiUrls.GpgKeys(id));
+ }
+ }
+}
\ No newline at end of file
diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs
index c6af35f2..7640ac6a 100644
--- a/Octokit/Helpers/ApiUrls.cs
+++ b/Octokit/Helpers/ApiUrls.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics.CodeAnalysis;
namespace Octokit
{
@@ -10,6 +11,7 @@ namespace Octokit
static readonly Uri _currentUserRepositoriesUrl = new Uri("user/repos", UriKind.Relative);
static readonly Uri _currentUserOrganizationsUrl = new Uri("user/orgs", UriKind.Relative);
static readonly Uri _currentUserSshKeys = new Uri("user/keys", UriKind.Relative);
+ static readonly Uri _currentUserGpgKeys = new Uri("user/gpg_keys", UriKind.Relative);
static readonly Uri _currentUserStars = new Uri("user/starred", UriKind.Relative);
static readonly Uri _currentUserWatched = new Uri("user/subscriptions", UriKind.Relative);
static readonly Uri _currentUserEmailsEndpoint = new Uri("user/emails", UriKind.Relative);
@@ -2146,6 +2148,27 @@ namespace Octokit
return "repositories/{0}/events".FormatUri(repositoryId);
}
+ ///
+ /// Returns the that returns all the GPG Keys for the authenticated user.
+ ///
+ /// The that returns all the GPG Keys for the authenticated user.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
+ public static Uri GpgKeys()
+ {
+ return _currentUserGpgKeys;
+ }
+
+ ///
+ /// Returns the that returns the GPG Key for the authenticated user for the specified ID.
+ ///
+ /// The that returns the GPG Key for the authenticated user for the specified ID.
+ ///
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
+ public static Uri GpgKeys(int id)
+ {
+ return "user/gpg_keys/{0}".FormatUri(id);
+ }
+
///
/// Returns the for the specified issue.
///
diff --git a/Octokit/Models/Request/NewGpgKey.cs b/Octokit/Models/Request/NewGpgKey.cs
new file mode 100644
index 00000000..428779b7
--- /dev/null
+++ b/Octokit/Models/Request/NewGpgKey.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Octokit
+{
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
+ [DebuggerDisplay("{DebuggerDisplay,nq")]
+ public class NewGpgKey
+ {
+ public NewGpgKey()
+ {
+ }
+
+ public NewGpgKey(string publicKey)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(publicKey, "publicKey");
+
+ ArmoredPublicKey = publicKey;
+ }
+
+ public string ArmoredPublicKey { get; set; }
+
+ internal string DebuggerDisplay
+ {
+ get { return string.Format(CultureInfo.InvariantCulture, "ArmoredPublicKey: {0}", ArmoredPublicKey); }
+ }
+ }
+}
diff --git a/Octokit/Models/Response/GpgKey.cs b/Octokit/Models/Response/GpgKey.cs
new file mode 100644
index 00000000..e7d6b9fa
--- /dev/null
+++ b/Octokit/Models/Response/GpgKey.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Octokit.Internal;
+
+namespace Octokit
+{
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
+ public class GpgKey
+ {
+ public int Id { get; protected set; }
+ public int? PrimaryKeyId { get; protected set; }
+ public string KeyId { get; protected set; }
+ public string PublicKey { get; protected set; }
+ public IReadOnlyList Emails { get; protected set; }
+ public IReadOnlyList Subkeys { get; protected set; }
+ public bool CanSign { get; protected set; }
+ [Parameter(Key = "can_encrypt_comms")]
+ public bool CanEncryptCommunications { get; protected set; }
+ public bool CanEncryptStorage { get; protected set; }
+ public bool CanCertify { get; protected set; }
+ public DateTimeOffset CreatedAt { get; protected set; }
+ public DateTimeOffset? ExpiresAt { get; protected set; }
+ }
+}
diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj
index bb98c8a8..048f2218 100644
--- a/Octokit/Octokit-Mono.csproj
+++ b/Octokit/Octokit-Mono.csproj
@@ -467,6 +467,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj
index cf0aa9e7..f9b8844a 100644
--- a/Octokit/Octokit-MonoAndroid.csproj
+++ b/Octokit/Octokit-MonoAndroid.csproj
@@ -478,6 +478,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj
index cbb7347e..b0ac11df 100644
--- a/Octokit/Octokit-Monotouch.csproj
+++ b/Octokit/Octokit-Monotouch.csproj
@@ -474,6 +474,10 @@
+
+
+
+
diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj
index d5cc1c6e..66c9177c 100644
--- a/Octokit/Octokit-Portable.csproj
+++ b/Octokit/Octokit-Portable.csproj
@@ -464,6 +464,10 @@
+
+
+
+
diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj
index b6714a9b..9b94327e 100644
--- a/Octokit/Octokit-netcore45.csproj
+++ b/Octokit/Octokit-netcore45.csproj
@@ -471,6 +471,10 @@
+
+
+
+
diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj
index 24dad5da..41b3dd0c 100644
--- a/Octokit/Octokit.csproj
+++ b/Octokit/Octokit.csproj
@@ -58,6 +58,7 @@
Properties\SolutionInfo.cs
+
@@ -93,6 +94,7 @@
+
@@ -120,6 +122,7 @@
+
@@ -173,6 +176,7 @@
+