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

org.gitlab4j.api.LicensesApi 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.

There is a newer version: 6.0.0-rc.5
Show newest version
package org.gitlab4j.api;

import java.util.List;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;

import org.gitlab4j.api.models.LicenseTemplate;

/**
 * This class provides an entry point to all the GitLab API licenses calls.
 */
public class LicensesApi extends AbstractApi {

    public LicensesApi(GitLabApi gitLabApi) {
        super(gitLabApi);
    }

    /**
     * Get all license templates.
     *
     * GET /licenses
     *
     * @return a list of LicenseTemplate instances
     * @throws GitLabApiException if any exception occurs
     */
    public List getAllLicenseTemplates() throws GitLabApiException {
        Response response = get(Response.Status.OK, null, "licenses");
        return (response.readEntity(new GenericType>() {}));
    }

    /**
     * Get popular license templates.
     *
     * GET /licenses
     *
     * @return a list of LicenseTemplate instances
     * @throws GitLabApiException if any exception occurs
     */
    public List getPopularLicenseTemplates() throws GitLabApiException {
        Form formData = new GitLabApiForm().withParam("popular", true, true);
        Response response = get(Response.Status.OK, formData.asMap(), "licenses");
        return (response.readEntity(new GenericType>() {}));
    }

    /**
     * Get a single license template.
     *
     * GET /licenses
     *
     * @param key The key of the license template
     * @return a LicenseTemplate instance
     * @throws GitLabApiException if any exception occurs
     */
    public LicenseTemplate getSingleLicenseTemplate(String key) throws GitLabApiException {
        Response response = get(Response.Status.OK, null, "licenses", key);
        return (response.readEntity(LicenseTemplate.class));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy