Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improved IssuesApi #941

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/gitlab4j/api/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ public String toString() {
/** Enum to use for ordering the results of getIssues(). */
public enum IssueOrderBy {

CREATED_AT, UPDATED_AT;
CREATED_AT, DUE_DATE, LABEL_PRIORITY, MILESTONE_DUE, POPULARITY, PRIORITY, RELATIVE_POSITION,relative_position, TITLE, UPDATED_AT, WEIGHT;

private static JacksonJsonEnumHelper<IssueOrderBy> enumHelper = new JacksonJsonEnumHelper<>(IssueOrderBy.class);

@JsonCreator
public static IssueOrderBy forValue(String value) {
return enumHelper.forValue(value);
}
}

@JsonValue
public String toValue() {
Expand Down
50 changes: 48 additions & 2 deletions src/main/java/org/gitlab4j/api/IssuesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,30 @@ public Stream<Issue> getGroupIssuesStream(Object groupIdOrPath) throws GitLabApi
* @throws GitLabApiException if any exception occurs
*/
public List<Issue> getGroupIssues(Object groupIdOrPath, IssueFilter filter) throws GitLabApiException {
return (getGroupIssues(groupIdOrPath, filter, getDefaultPerPage()).all());
return (getGroupIssues(groupIdOrPath, filter, getDefaultPerPage()).all());
}


/**
* Get a list of a group’s issues.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/issues</code></pre>
*
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
* @param page the page to get.
* @param perPage the number of projects per page.
* @return a List of issues for the specified group and filter
* @throws GitLabApiException if any exception occurs
*/
public List<Issue> getGroupIssues(Object groupIdOrPath, IssueFilter filter, int page, int perPage) throws GitLabApiException {
GitLabApiForm formData = filter.getQueryParams(page, perPage);
Response response = get(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "issues");
return (response.readEntity(new GenericType<List<Issue>>() {}));

}


/**
* Get a list of groups's issues.
*
Expand Down Expand Up @@ -1050,4 +1071,29 @@ public Issue moveIssue(Object projectIdOrPath, Long issueIid, Object toProjectId
"projects", this.getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "move");
return (response.readEntity(Issue.class));
}
}


/**
* <p>Reorders an issue, you can see the results when sorting issues manually.</p>
*
* * <pre><code>GitLab Endpoint: PUT /projects/:id/issues/:issue_iid/reorder </code></pre>
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance, required
* @param issueIid the IID of the issue to move
* @param moveAfterIssueId The global ID of a project’s issue that should be placed after this issue
* @param moveBeforeIssueId The global ID of a project’s issue that should be placed before this issue
* @param groupFullPath the group in the form of an Long(ID), String(path), or Group instance
* @throws GitLabApiException
*/
public void reorder(Object projectIdOrPath, Long issueIid, Long moveBeforeIssueId, Long moveAfterIssueId, Object groupFullPath) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("move_before_id", moveBeforeIssueId)
.withParam("move_after_id", moveAfterIssueId)
.withParam("group_full_path", getGroupIdOrPath(groupFullPath));

put(Response.Status.OK, formData.asMap(),
"projects", this.getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "reorder");


}
}