Use ListJobsPaginator with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use ListJobsPaginator with an AWS SDK or CLI

The following code example shows how to use ListJobsPaginator.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

/** * Asynchronously lists the jobs in the specified job queue with the given job status. * * @param jobQueue the name of the job queue to list jobs from * @return a List<JobSummary> that contains the jobs that succeeded */ public List<JobSummary> listJobsAsync(String jobQueue) { if (jobQueue == null || jobQueue.isEmpty()) { throw new IllegalArgumentException("Job queue cannot be null or empty"); } ListJobsRequest listJobsRequest = ListJobsRequest.builder() .jobQueue(jobQueue) .jobStatus(JobStatus.SUCCEEDED) // Filter jobs by status. .build(); List<JobSummary> jobSummaries = new ArrayList<>(); ListJobsPublisher listJobsPaginator = getAsyncClient().listJobsPaginator(listJobsRequest); CompletableFuture<Void> future = listJobsPaginator.subscribe(response -> { jobSummaries.addAll(response.jobSummaryList()); }); future.join(); return jobSummaries; }