An error occurred while loading the file. Please try again.
An error occurred while loading the file. Please try again.
An error occurred while loading the file. Please try again.
-
Gabriel Barbier authored267ffcf3
package org.gitlab4j.api;
import java.util.Date;
import java.util.List;
import java.util.stream.Stream;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.Response;
import org.gitlab4j.api.models.Issue;
import org.gitlab4j.api.models.MergeRequest;
import org.gitlab4j.api.models.Milestone;
/**
* This class implements the client side API for the GitLab milestones calls.
* @see <a href="https://docs.gitlab.com/ce/api/milestones.html">Project milestones API</a>
* @see <a href="https://docs.gitlab.com/ce/api/group_milestones.html">Group milestones API</a>
*/
public class MilestonesApi extends AbstractApi {
public MilestonesApi(GitLabApi gitLabApi) {
super(gitLabApi);
}
/**
* Get a list of group milestones.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @return the milestones associated with the specified group
* @throws GitLabApiException if any exception occurs
*/
public List<Milestone> getGroupMilestones(Object groupIdOrPath) throws GitLabApiException {
return (getGroupMilestones(groupIdOrPath, getDefaultPerPage()).all());
}
/**
* Get a list of group milestones.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param page the page number to get
* @param perPage how many milestones per page
* @return the milestones associated with the specified group
* @throws GitLabApiException if any exception occurs
*/
public List<Milestone> getGroupMilestones(Object groupIdOrPath, int page, int perPage) throws GitLabApiException {
Response response = get(Response.Status.OK, getPageQueryParams(page, perPage),
"groups", getGroupIdOrPath(groupIdOrPath), "milestones");
return (response.readEntity(new GenericType<List<Milestone>>() {}));
}
/**
* Get a Page of group milestones.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param itemsPerPage The number of Milestone instances that will be fetched per page
* @return the milestones associated with the specified group
* @throws GitLabApiException if any exception occurs
*/
public Pager<Milestone> getGroupMilestones(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException {
return (new Pager<Milestone>(this, Milestone.class, itemsPerPage, null,
"groups", getGroupIdOrPath(groupIdOrPath), "milestones"));
}
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
/**
* Get a Stream of group milestones.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @return a Stream of the milestones associated with the specified group
* @throws GitLabApiException if any exception occurs
*/
public Stream<Milestone> getGroupMilestonesStream(Object groupIdOrPath) throws GitLabApiException {
return (getGroupMilestones(groupIdOrPath, getDefaultPerPage()).stream());
}
/**
* Get a list of group milestones that have the specified state.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param state the milestone state
* @return the milestones associated with the specified group and state
* @throws GitLabApiException if any exception occurs
*/
public List<Milestone> getGroupMilestones(Object groupIdOrPath, MilestoneState state) throws GitLabApiException {
Form formData = new GitLabApiForm().withParam("state", state).withParam(PER_PAGE_PARAM, getDefaultPerPage());
Response response = get(Response.Status.OK, formData.asMap(),
"groups", getGroupIdOrPath(groupIdOrPath), "milestones");
return (response.readEntity(new GenericType<List<Milestone>>() {}));
}
/**
* Get a list of group milestones that have match the search string.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param search the search string
* @return the milestones associated with the specified group
* @throws GitLabApiException if any exception occurs
*/
public List<Milestone> getGroupMilestones(Object groupIdOrPath, String search) throws GitLabApiException {
Form formData = new GitLabApiForm().withParam("search", search).withParam(PER_PAGE_PARAM, getDefaultPerPage());
Response response = get(Response.Status.OK, formData.asMap(),
"groups", getGroupIdOrPath(groupIdOrPath), "milestones");
return (response.readEntity(new GenericType<List<Milestone>>() {}));
}
/**
* Get a list of group milestones that have the specified state and match the search string.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones/:milestone_id</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param state the milestone state
* @param search the search string
* @return the milestones associated with the specified group
* @throws GitLabApiException if any exception occurs
*/
public List<Milestone> getGroupMilestones(Object groupIdOrPath, MilestoneState state, String search) throws GitLabApiException {
Form formData = new GitLabApiForm()
.withParam("state", state)
.withParam("search", search)
.withParam(PER_PAGE_PARAM, getDefaultPerPage());
Response response = get(Response.Status.OK, formData.asMap(),
"groups", getGroupIdOrPath(groupIdOrPath), "milestones");
return (response.readEntity(new GenericType<List<Milestone>>() {}));
}
/**
* Get the specified group milestone.
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones/:milestone_id</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param milestoneId the ID of the milestone tp get
* @return a Milestone instance for the specified IDs
* @throws GitLabApiException if any exception occurs
*/
public Milestone getGroupMilestone(Object groupIdOrPath, Long milestoneId) throws GitLabApiException {
Response response = get(Response.Status.OK, getDefaultPerPageParam(),
"groups", getGroupIdOrPath(groupIdOrPath), "milestones", milestoneId);
return (response.readEntity(Milestone.class));
}
/**
* Get the list of issues associated with the specified group milestone.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones/:milestone_id/issues</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param milestoneId the milestone ID to get the issues for
* @return a List of Issue for the milestone
* @throws GitLabApiException if any exception occurs
*/
public List<Issue> getGroupIssues(Object groupIdOrPath, Long milestoneId) throws GitLabApiException {
return (getGroupIssues(groupIdOrPath, milestoneId, getDefaultPerPage()).all());
}
/**
* Get the Pager of issues associated with the specified group milestone.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones/:milestone_id/issues</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param milestoneId the milestone ID to get the issues for
* @param itemsPerPage The number of Milestone instances that will be fetched per page
* @return a Pager of Issue for the milestone
* @throws GitLabApiException if any exception occurs
*/
public Pager<Issue> getGroupIssues(Object groupIdOrPath, Long milestoneId, int itemsPerPage) throws GitLabApiException {
return (new Pager<Issue>(this, Issue.class, itemsPerPage, null,
"groups", getGroupIdOrPath(groupIdOrPath), "milestones", milestoneId, "issues"));
}
/**
* Get a Stream of issues associated with the specified group milestone.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones/:milestone_id/issues</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param milestoneId the milestone ID to get the issues for
* @return a Stream of Issue for the milestone
* @throws GitLabApiException if any exception occurs
*/
public Stream<Issue> getGroupIssuesStream(Object groupIdOrPath, Long milestoneId) throws GitLabApiException {
return (getGroupIssues(groupIdOrPath, milestoneId, getDefaultPerPage()).stream());
}
/**
* Get the list of merge requests associated with the specified group milestone.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/milestones/:milestone_id/merge_requests</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param milestoneId the milestone ID to get the merge requests for
* @return a list of merge requests associated with the specified milestone
* @throws GitLabApiException if any exception occurs
*/
public List<MergeRequest> getGroupMergeRequest(Object groupIdOrPath, Long milestoneId) throws GitLabApiException {
Response response = get(Response.Status.OK, getDefaultPerPageParam(),