Skip to content

Commit

Permalink
feat: get key by id #1176
Browse files Browse the repository at this point in the history
  • Loading branch information
LeJeanbono committed Oct 13, 2024
1 parent 6e5e2e6 commit 83ab12b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main/java/org/gitlab4j/api/KeysApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/**
* See:
* https://docs.gitlab.com/ee/api/keys.html#get-user-by-fingerprint-of-ssh-key
* <a href="https://docs.gitlab.com/ee/api/keys.html">GitLab Key API Documentaion<</a>
*/
public class KeysApi extends AbstractApi {
public KeysApi(GitLabApi gitLabApi) {
Expand All @@ -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.
*
* <pre><code>GitLab Endpoint: GET /keys/:id</code></pre>
*
* @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);
}
}

0 comments on commit 83ab12b

Please sign in to comment.