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

org.gitlab4j.api.LicenseApi 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.List;
import java.util.Optional;
import java.util.stream.Stream;

import jakarta.ws.rs.core.Response;

import org.gitlab4j.api.models.License;

/**
 * This class provides an entry point to all the GitLab API license calls.
 * @see License API
 */
public class LicenseApi extends AbstractApi {

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

    /**
     * Retrieve information about the current license.
     *
     * 
GitLab Endpoint: GET /license
* * @return a License instance holding info about the current license * @throws GitLabApiException if any exception occurs */ public License getLicense() throws GitLabApiException { Response response = get(Response.Status.OK, null, "license"); return (response.readEntity(License.class)); } /** * Retrieve information about the current license as the value of an Optional. * *
GitLab Endpoint: GET /license
* * @return the current license as the value of an Optional. */ public Optional getOptionalLicense() { try { return (Optional.ofNullable(getLicense())); } catch (GitLabApiException glae) { return (GitLabApi.createOptionalFromException(glae)); } } /** * Retrieve information about all licenses. * *
GitLab Endpoint: GET /licenses
* * @return a List of License instances * @throws GitLabApiException if any exception occurs */ public List getAllLicenses() throws GitLabApiException { return (getAllLicenses(getDefaultPerPage()).all()); } /** * Get a Stream of all licenses. * *
GitLab Endpoint: GET /licenses
* * @return a Stream of License instances * @throws GitLabApiException if any exception occurs */ public Stream getAllLicensesStream() throws GitLabApiException { return (getAllLicenses(getDefaultPerPage()).stream()); } /** * Get a Pager of all licenses. * *
GitLab Endpoint: GET /licenses
* * @param itemsPerPage the number of LicenseTemplate instances that will be * fetched per page * @return a Pager of license template * @throws GitLabApiException if any exception occurs */ public Pager getAllLicenses(int itemsPerPage) throws GitLabApiException { return (new Pager(this, License.class, itemsPerPage, null, "licenses")); } /** * Add a new license. * *
GitLab Endpoint: POST /license
* * @param licenseString the license string for the license * @return a License instance for the added license * @throws GitLabApiException if any exception occurs */ public License addLicense(String licenseString) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("license", licenseString, true); Response response = post(Response.Status.CREATED, formData, "license"); return (response.readEntity(License.class)); } /** * Deletes a license. * *
GitLab Endpoint: DELETE /license/:id
* * @param licenseId the ID of the license to delete * @return a License instance for the delete license * @throws GitLabApiException if any exception occurs */ public License deleteLicense(Long licenseId) throws GitLabApiException { Response response = delete(Response.Status.OK, null, "license", licenseId); return (response.readEntity(License.class)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy