IssuesApi.java 43.44 KiB
package org.gitlab4j.api;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Duration;
import org.gitlab4j.api.models.Issue;
import org.gitlab4j.api.models.IssueFilter;
import org.gitlab4j.api.models.IssueLink;
import org.gitlab4j.api.models.IssuesStatistics;
import org.gitlab4j.api.models.IssuesStatisticsFilter;
import org.gitlab4j.api.models.MergeRequest;
import org.gitlab4j.api.models.Participant;
import org.gitlab4j.api.models.TimeStats;
import org.gitlab4j.api.utils.DurationUtils;
/**
 * This class provides an entry point to all the GitLab API Issue calls.
 * @see <a href="https://docs.gitlab.com/ce/api/issues.html">Issues API at GitLab</a>
 * @see <a href="https://docs.gitlab.com/ce/api/issue_links.html">Issue Links API at GitLab</a>
 * @see <a href="https://docs.gitlab.com/ce/api/issues_statistics.html">Issues Statistics API at GitLab</a>
public class IssuesApi extends AbstractApi implements Constants {
    public IssuesApi(GitLabApi gitLabApi) {
        super(gitLabApi);
    /**
     * Get all issues the authenticated user has access to. Only returns issues created by the current user.
     * <pre><code>GitLab Endpoint: GET /issues</code></pre>
     * @return a list of user's issues
     * @throws GitLabApiException if any exception occurs
    public List<Issue> getIssues() throws GitLabApiException {
        return (getIssues(getDefaultPerPage()).all());
    /**
     * Get all issues the authenticated user has access to using the specified page and per page setting. Only returns issues created by the current user.
     * <pre><code>GitLab Endpoint: GET /issues</code></pre>
     * @param page the page to get
     * @param perPage the number of issues per page
     * @return the list of issues in the specified range
     * @throws GitLabApiException if any exception occurs
    public List<Issue> getIssues(int page, int perPage) throws GitLabApiException {
        Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "issues");
        return (response.readEntity(new GenericType<List<Issue>>() {}));
    /**
     * Get a Pager of all issues the authenticated user has access to. Only returns issues created by the current user.
     * <pre><code>GitLab Endpoint: GET /issues</code></pre>
     * @param itemsPerPage the number of issues per page
     * @return the Pager of issues in the specified range
     * @throws GitLabApiException if any exception occurs
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
public Pager<Issue> getIssues(int itemsPerPage) throws GitLabApiException { return (new Pager<Issue>(this, Issue.class, itemsPerPage, null, "issues")); } /** * Get all issues the authenticated user has access to as a Stream. Only returns issues created by the current user. * * <pre><code>GitLab Endpoint: GET /issues</code></pre> * * @return a Stream of user's issues * @throws GitLabApiException if any exception occurs */ public Stream<Issue> getIssuesStream() throws GitLabApiException { return (getIssues(getDefaultPerPage()).stream()); } /** * Get a list of project's issues. * * <pre><code>GitLab Endpoint: GET /projects/:id/issues</code></pre> * * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @return a list of project's issues * @throws GitLabApiException if any exception occurs */ public List<Issue> getIssues(Object projectIdOrPath) throws GitLabApiException { return (getIssues(projectIdOrPath, getDefaultPerPage()).all()); } /** * Get a list of project's issues using the specified page and per page settings. * * <pre><code>GitLab Endpoint: GET /projects/:id/issues</code></pre> * * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param page the page to get * @param perPage the number of issues per page * @return the list of issues in the specified range * @throws GitLabApiException if any exception occurs */ public List<Issue> getIssues(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "projects", getProjectIdOrPath(projectIdOrPath), "issues"); return (response.readEntity(new GenericType<List<Issue>>() {})); } /** * Get a Pager of project's issues. * * <pre><code>GitLab Endpoint: GET /projects/:id/issues</code></pre> * * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param itemsPerPage the number of issues per page * @return the Pager of issues in the specified range * @throws GitLabApiException if any exception occurs */ public Pager<Issue> getIssues(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { return (new Pager<Issue>(this, Issue.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "issues")); } /** * Get a Stream of project's issues. Only returns the first page * * <pre><code>GitLab Endpoint: GET /projects/:id/issues</code></pre> * * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @return a Stream of project's issues * @throws GitLabApiException if any exception occurs */ public Stream<Issue> getIssuesStream(Object projectIdOrPath) throws GitLabApiException { return (getIssues(projectIdOrPath, getDefaultPerPage()).stream());