From fde7749f15b4457313fe7c1cccf7ac0efc165925 Mon Sep 17 00:00:00 2001 From: niels Date: Thu, 15 Apr 2021 15:52:00 +0200 Subject: [PATCH] Added Paging- and Stream-Support for Jobs in Pipeline. --- src/main/java/org/gitlab4j/api/JobApi.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main/java/org/gitlab4j/api/JobApi.java b/src/main/java/org/gitlab4j/api/JobApi.java index 0d7046bb..de69ed22 100644 --- a/src/main/java/org/gitlab4j/api/JobApi.java +++ b/src/main/java/org/gitlab4j/api/JobApi.java @@ -162,6 +162,35 @@ public class JobApi extends AbstractApi implements Constants { return (response.readEntity(new GenericType>() {})); } + /** + * Get a Pager of jobs in a pipeline. + * + *
GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for + * @param pipelineId the pipeline ID to get the list of jobs for + * @param itemsPerPage the number of Job instances that will be fetched per page + * @return a list containing the jobs for the specified project ID and pipeline ID + * @throws GitLabApiException if any exception occurs during execution + */ + public Pager getJobsForPipeline(Object projectIdOrPath, int pipelineId, int itemsPerPage) throws GitLabApiException { + return (new Pager(this, Job.class, itemsPerPage, getDefaultPerPageParam(), + "projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "jobs")); + } + + /** + * Get a Stream of jobs in a pipeline. + *
GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param pipelineId the pipeline ID to get the list of jobs for + * @return a Stream containing the jobs for the specified project ID + * @throws GitLabApiException if any exception occurs during execution + */ + public Stream getJobsStream(Object projectIdOrPath, int pipelineId) throws GitLabApiException { + return (getJobsForPipeline(projectIdOrPath, pipelineId, getDefaultPerPage()).stream()); + } + /** * Get single job in a project. * -- GitLab