Skip to content

Commit

Permalink
Add getKey(String keyId) to KeysApi (#1180)
Browse files Browse the repository at this point in the history
Fixes #1176
  • Loading branch information
LeJeanbono authored Oct 15, 2024
1 parent 0c46de5 commit ba17e7c
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 ba17e7c

Please sign in to comment.