All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gitlab4j.api.KeysApi Maven / Gradle / Ivy

Go to download

GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.

The newest version!
package org.gitlab4j.api;

import java.util.Collections;

import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;

import org.gitlab4j.api.models.Key;

/**
 * See:
 * GitLab Key API Documentaion
 */
public class KeysApi extends AbstractApi {
    public KeysApi(GitLabApi gitLabApi) {
        super(gitLabApi);
    }

    /**
     * @param fingerprint The md5 hash of a ssh public key with : separating the bytes Or SHA256:$base64hash
     * @return The Key which includes the user who owns the key
     * @throws GitLabApiException If anything goes wrong
     */
    public Key getUserBySSHKeyFingerprint(String fingerprint) throws GitLabApiException {
        MultivaluedMap queryParams = new MultivaluedHashMap<>();
        queryParams.put("fingerprint", Collections.singletonList(fingerprint));
        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); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy