Skip to content

Commit 880b5a3

Browse files
zhengrenjiegmessner
authored andcommitted
Added three getIssues() methods with all optionals in Issues Api. (#246)
1 parent 78fd371 commit 880b5a3

File tree

5 files changed

+786
-315
lines changed

5 files changed

+786
-315
lines changed

src/main/java/org/gitlab4j/api/Constants.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,29 @@ public String toString() {
8686
}
8787
}
8888

89+
/** Enum to use for ordering the results of getIssues(). */
90+
public enum IssueOrderBy {
91+
92+
CREATED_AT, UPDATED_AT;
93+
94+
private static JacksonJsonEnumHelper<IssueOrderBy> enumHelper = new JacksonJsonEnumHelper<>(IssueOrderBy.class);
95+
96+
@JsonCreator
97+
public static IssueOrderBy forValue(String value) {
98+
return enumHelper.forValue(value);
99+
}
100+
101+
@JsonValue
102+
public String toValue() {
103+
return (enumHelper.toString(this));
104+
}
105+
106+
@Override
107+
public String toString() {
108+
return (enumHelper.toString(this));
109+
}
110+
}
111+
89112
/** Enum to use for ordering the results of getProjects(). */
90113
public enum ProjectOrderBy {
91114

src/main/java/org/gitlab4j/api/IssuesApi.java

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.gitlab4j.api.GitLabApi.ApiVersion;
3434
import org.gitlab4j.api.models.Duration;
3535
import org.gitlab4j.api.models.Issue;
36+
import org.gitlab4j.api.models.IssueFilter;
3637
import org.gitlab4j.api.models.TimeStats;
3738
import org.gitlab4j.api.utils.DurationUtils;
3839

@@ -128,6 +129,107 @@ public Pager<Issue> getIssues(Integer projectId, int itemsPerPage) throws GitLab
128129
return (new Pager<Issue>(this, Issue.class, itemsPerPage, null, "projects", projectId, "issues"));
129130
}
130131

132+
/**
133+
* Get a list of project's issues. Only returns the first page with default 100 items.
134+
*
135+
* GET /projects/:id/issues
136+
*
137+
* @param projectIdOrPath The ID or URL-encoded path of the project owned by the authenticated user.
138+
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings
139+
* @return the list of issues in the specified range.
140+
* @throws GitLabApiException
141+
*/
142+
public List<Issue> getIssues(Object projectIdOrPath, IssueFilter filter) throws GitLabApiException {
143+
return (getIssues(projectIdOrPath, filter, 1, getDefaultPerPage()));
144+
}
145+
146+
/**
147+
* Get a list of project's issues.
148+
*
149+
* GET /projects/:id/issues
150+
*
151+
* @param projectIdOrPath The ID or URL-encoded path of the project owned by the authenticated user.
152+
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
153+
* @param page the page to get.
154+
* @param perPage the number of projects per page.
155+
* @return the list of issues in the specified range.
156+
* @throws GitLabApiException
157+
*/
158+
public List<Issue> getIssues(Object projectIdOrPath, IssueFilter filter, int page, int perPage) throws GitLabApiException {
159+
160+
GitLabApiForm formData = filter.getQueryParams(page, perPage);
161+
Response response = get(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues");
162+
return (response.readEntity(new GenericType<List<Issue>>() {}));
163+
}
164+
165+
/**
166+
* Get a list of project's issues.
167+
*
168+
* GET /projects/:id/issues
169+
*
170+
* @param projectIdOrPath The ID or URL-encoded path of the project owned by the authenticated user.
171+
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
172+
* @param itemsPerPage the number of Project instances that will be fetched per page.
173+
* @return the list of issues in the specified range.
174+
* @throws GitLabApiException
175+
*/
176+
public Pager<Issue> getIssues(Object projectIdOrPath, IssueFilter filter, int itemsPerPage) throws GitLabApiException {
177+
178+
GitLabApiForm formData = filter.getQueryParams();
179+
return (new Pager<Issue>(this, Issue.class, itemsPerPage, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues"));
180+
}
181+
182+
/**
183+
* Get all issues the authenticated user has access to.
184+
* By default it returns only issues created by the current user.
185+
* Only returns the first page with default 100 items.
186+
*
187+
* GET /issues
188+
*
189+
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings
190+
* @return the list of issues in the specified range.
191+
* @throws GitLabApiException
192+
*/
193+
public List<Issue> getIssues(IssueFilter filter) throws GitLabApiException {
194+
return (getIssues(filter, 1, getDefaultPerPage()));
195+
}
196+
197+
/**
198+
* Get all issues the authenticated user has access to.
199+
* By default it returns only issues created by the current user.
200+
*
201+
* GET /issues
202+
*
203+
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
204+
* @param page the page to get.
205+
* @param perPage the number of projects per page.
206+
* @return the list of issues in the specified range.
207+
* @throws GitLabApiException
208+
*/
209+
public List<Issue> getIssues(IssueFilter filter, int page, int perPage) throws GitLabApiException {
210+
211+
GitLabApiForm formData = filter.getQueryParams(page, perPage);
212+
Response response = get(Response.Status.OK, formData.asMap(), "issues");
213+
return (response.readEntity(new GenericType<List<Issue>>() {}));
214+
}
215+
216+
/**
217+
* Get all issues the authenticated user has access to.
218+
* By default it returns only issues created by the current user.
219+
*
220+
* GET /issues
221+
*
222+
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
223+
* @param itemsPerPage the number of Project instances that will be fetched per page.
224+
* @return the list of issues in the specified range.
225+
* @throws GitLabApiException
226+
*/
227+
public Pager<Issue> getIssues(IssueFilter filter, int itemsPerPage) throws GitLabApiException {
228+
229+
GitLabApiForm formData = filter.getQueryParams();
230+
return (new Pager<Issue>(this, Issue.class, itemsPerPage, formData.asMap(), "issues"));
231+
}
232+
131233
/**
132234
* Get a single project issue.
133235
*

0 commit comments

Comments
 (0)