From ba17e7c24c7a7dce3d56d348c58d201380fc125f Mon Sep 17 00:00:00 2001 From: Jean-Michel Leclercq Date: Tue, 15 Oct 2024 08:33:49 +0200 Subject: [PATCH] Add getKey(String keyId) to KeysApi (#1180) Fixes #1176 --- src/main/java/org/gitlab4j/api/KeysApi.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gitlab4j/api/KeysApi.java b/src/main/java/org/gitlab4j/api/KeysApi.java index 2f2d653c..dc7f912a 100644 --- a/src/main/java/org/gitlab4j/api/KeysApi.java +++ b/src/main/java/org/gitlab4j/api/KeysApi.java @@ -10,7 +10,7 @@ /** * See: - * https://docs.gitlab.com/ee/api/keys.html#get-user-by-fingerprint-of-ssh-key + * GitLab Key API Documentaion */ public class KeysApi extends AbstractApi { public KeysApi(GitLabApi gitLabApi) { @@ -28,4 +28,18 @@ public Key getUserBySSHKeyFingerprint(String fingerprint) throws GitLabApiExcept Response response = get(Response.Status.OK, queryParams, "keys"); return response.readEntity(Key.class); } + + /** + * Get a single key by id. + * + *
GitLab Endpoint: GET /keys/:id
+ * + * @param keyId the IID of the key to get + * @return a Key instance + * @throws GitLabApiException if any exception occurs + */ + public Key getKey(String keyId) throws GitLabApiException { + Response response = get(Response.Status.OK, null, "keys", keyId); + return response.readEntity(Key.class); + } }