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);
+ }
}