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

org.gitlab4j.api.ReleasesApi 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.Release;
import org.gitlab4j.api.models.ReleaseParams;

/**
 * This class provides an entry point to all the GitLab Releases API calls.
 * @see Releases API at GitLab
 */
public class ReleasesApi extends AbstractApi {

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

    /**
     * Get a list of releases for a project, sorted by release date.
     *
     * 
GitLab Endpoint: GET /projects/:id/releases
* * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path * @return the list of releases for the specified project * @throws GitLabApiException if any exception occurs */ public List getReleases(Object projectIdOrPath) throws GitLabApiException { return (getReleases(projectIdOrPath, getDefaultPerPage()).all()); } /** * Get a Pager of releases for a project, sorted by release date. * *
GitLab Endpoint: GET /projects/:id/releases
* * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path * @param itemsPerPage the number of Release instances that will be fetched per page * @return the Pager of Release instances for the specified project ID * @throws GitLabApiException if any exception occurs */ public Pager getReleases(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { return (new Pager( this, Release.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "releases")); } /** * Get a Stream of releases for a project, sorted by release date. * *
GitLab Endpoint: GET /projects/:id/releases
* * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path * @return a Stream of Release instances for the specified project ID * @throws GitLabApiException if any exception occurs */ public Stream getReleasesStream(Object projectIdOrPath) throws GitLabApiException { return (getReleases(projectIdOrPath, getDefaultPerPage()).stream()); } /** * Get a Release for the given tag name. * *
GitLab Endpoint: GET /projects/:id/releases/:tagName
* * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path * @param tagName the name of the tag to fetch the Release for * @return a Releases instance with info on the specified tag * @throws GitLabApiException if any exception occurs */ public Release getRelease(Object projectIdOrPath, String tagName) throws GitLabApiException { Response response = get( Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "releases", urlEncode(tagName)); return (response.readEntity(Release.class)); } /** * Get an Optional instance holding a Release instance for the specific tag name. * *
GitLab Endpoint: GET /projects/:id/releases/:tagName
* * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path * @param tagName the name of the tag to fetch the Release for * @return an Optional instance with the specified Release as the value * @throws GitLabApiException if any exception occurs */ public Optional getOptionalRelease(Object projectIdOrPath, String tagName) throws GitLabApiException { try { return (Optional.ofNullable(getRelease(projectIdOrPath, tagName))); } catch (GitLabApiException glae) { return (GitLabApi.createOptionalFromException(glae)); } } /** * Create a Release. You need push access to the repository to create a Release. * *
GitLab Endpoint: POST /projects/:id/releases
* * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path * @param params a ReleaseParams instance holding the parameters for the release * @return a Release instance containing the newly created Release info * @throws GitLabApiException if any exception occurs */ public Release createRelease(Object projectIdOrPath, ReleaseParams params) throws GitLabApiException { Response response = post(Response.Status.CREATED, params, "projects", getProjectIdOrPath(projectIdOrPath), "releases"); return (response.readEntity(Release.class)); } /** * Updates the release notes of a given release. * *
GitLab Endpoint: PUT /projects/:id/releases/:tag_name
* * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path * @param params a ReleaseParams instance holding the parameters for the release * @return a Release instance containing info on the updated Release * @throws GitLabApiException if any exception occurs */ public Release updateRelease(Object projectIdOrPath, ReleaseParams params) throws GitLabApiException { String tagName = params.getTagName(); if (tagName == null || tagName.trim().isEmpty()) { throw new RuntimeException("params.tagName cannot be null or empty"); } Response response = put( Response.Status.OK, params, "projects", getProjectIdOrPath(projectIdOrPath), "releases", urlEncode(tagName)); return (response.readEntity(Release.class)); } /** * Delete a Release. Deleting a Release will not delete the associated tag. * *
GitLab Endpoint: DELETE /projects/:id/releases/:tag_name
* * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance * @param tagName the tag name that the release was created from * @throws GitLabApiException if any exception occurs */ public void deleteRelease(Object projectIdOrPath, String tagName) throws GitLabApiException { delete( Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "releases", urlEncode(tagName)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy