From 378dea67c232a6584df0d2042d5dfd005a5ea3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Vila=C3=A7a?= Date: Thu, 6 Apr 2023 16:24:14 +0100 Subject: [PATCH 1/3] Update IssueOrderBy It was followed the documentation of `order_by` on https://docs.gitlab.com/ee/api/issues.html#list-issues --- src/main/java/org/gitlab4j/api/Constants.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/Constants.java b/src/main/java/org/gitlab4j/api/Constants.java index 824cb4492..ea1b2526a 100644 --- a/src/main/java/org/gitlab4j/api/Constants.java +++ b/src/main/java/org/gitlab4j/api/Constants.java @@ -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 enumHelper = new JacksonJsonEnumHelper<>(IssueOrderBy.class); @JsonCreator public static IssueOrderBy forValue(String value) { return enumHelper.forValue(value); - } + } @JsonValue public String toValue() { From 271e26f9082a7d3a0d7dd1cd527f6e0b7c1ae23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Vila=C3=A7a?= Date: Thu, 6 Apr 2023 16:54:17 +0100 Subject: [PATCH 2/3] implemented getGroupIssues by `page` and `items per page` --- src/main/java/org/gitlab4j/api/IssuesApi.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gitlab4j/api/IssuesApi.java b/src/main/java/org/gitlab4j/api/IssuesApi.java index 2c8ee532b..862afe363 100644 --- a/src/main/java/org/gitlab4j/api/IssuesApi.java +++ b/src/main/java/org/gitlab4j/api/IssuesApi.java @@ -316,9 +316,30 @@ public Stream getGroupIssuesStream(Object groupIdOrPath) throws GitLabApi * @throws GitLabApiException if any exception occurs */ public List 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. + * + *
GitLab Endpoint: GET /groups/:id/issues
+ * + * @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 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>() {})); + + } + + /** * Get a list of groups's issues. * From 0abed0b0189d714c508ea0bb5a1b4cfd87c51bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Vila=C3=A7a?= Date: Thu, 6 Apr 2023 18:01:47 +0100 Subject: [PATCH 3/3] [new] Reorder issues --- src/main/java/org/gitlab4j/api/IssuesApi.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gitlab4j/api/IssuesApi.java b/src/main/java/org/gitlab4j/api/IssuesApi.java index 862afe363..75af4cfc9 100644 --- a/src/main/java/org/gitlab4j/api/IssuesApi.java +++ b/src/main/java/org/gitlab4j/api/IssuesApi.java @@ -1071,4 +1071,29 @@ public Issue moveIssue(Object projectIdOrPath, Long issueIid, Object toProjectId "projects", this.getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "move"); return (response.readEntity(Issue.class)); } -} + + + /** + *

Reorders an issue, you can see the results when sorting issues manually.

+ * + * *
GitLab Endpoint: PUT /projects/:id/issues/:issue_iid/reorder 
+ * + * @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"); + + + } +}