From 83ab12b9f1bcd725a591282bfc751de6a5f79f51 Mon Sep 17 00:00:00 2001 From: Jean-Michel Leclercq Date: Sun, 13 Oct 2024 14:39:46 +0200 Subject: [PATCH] feat: get key by id #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 2f2d653cd..16836ec49 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); + } }