From 9f32ecb94d9f67fb278148fe45eacae687cb9902 Mon Sep 17 00:00:00 2001 From: Greg Messner Date: Fri, 25 May 2018 15:40:29 -0700 Subject: [PATCH] Added getForks() methods that return List. --- .../java/org/gitlab4j/api/ProjectApi.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/ProjectApi.java b/src/main/java/org/gitlab4j/api/ProjectApi.java index 3b7a3674..d2dce47f 100644 --- a/src/main/java/org/gitlab4j/api/ProjectApi.java +++ b/src/main/java/org/gitlab4j/api/ProjectApi.java @@ -2054,13 +2054,42 @@ public class ProjectApi extends AbstractApi implements Constants { delete(Response.Status.OK, null, "projects", projectId, "push_rule"); } - + /** - * Get a Pager of projects that were forked from the specified project. + * Get a list of projects that were forked from the specified project. * * GET /projects/:id/forks * * @param projectId the ID of the project + * @return a List of forked projects + * @throws GitLabApiException if any exception occurs + */ + public List getForks(Integer projectId) throws GitLabApiException { + return (getForks(projectId, 1, getDefaultPerPage())); + } + + /** + * Get a list of projects that were forked from the specified project and in the specified page range. + * + * GET /projects/:id/forks + * + * @param projectId the ID of the project + * @param page the page to get + * @param perPage the number of projects per page + * @return a List of forked projects + * @throws GitLabApiException if any exception occurs + */ + public List getForks(Integer projectId, int page, int perPage) throws GitLabApiException { + Response response = get(Response.Status.OK, getPageQueryParams(page, perPage),"projects", projectId, "forks"); + return (response.readEntity(new GenericType>() { })); + } + + /** + * Get a Pager of projects that were forked from the specified project. + * + * GET /projects/:id/forks + * + * @param projectId the ID of the project * @param itemsPerPage the number of Project instances that will be fetched per page * @return a Pager of projects * @throws GitLabApiException if any exception occurs -- GitLab