code: public MigrationJob[] retrieveJobs(int batchSize, int startIndex, JobType jobType)
              throws IOException, LightblueException {
          LOGGER.debug("Retrieving jobs: batchSize={}, startIndex={}", batchSize, startIndex);
  
          DataFindRequest findRequest = new DataFindRequest("migrationJob", null);
  
          List<Query> conditions = new ArrayList<>(Arrays.asList(new Query[] {
                  // get jobs for this configuration
                  Query.withValue("configurationName", Query.eq, migrationConfiguration.getConfigurationName()),
                  // get jobs whose state ara available
                  Query.withValue("status", Query.eq, "available"),
                  // only get jobs that are
                  Query.withValue("scheduledDate", Query.lte, new Date())
          }));
  
          if (jobType == JobType.GENERATED) {
              LOGGER.debug("Looking for generated job");
              conditions.add(Query.withValue("generated", Query.eq, true));
          } else if (jobType == JobType.NONGENERATED) {
              LOGGER.debug("Looking for non generated job");
              conditions.add(Query.withValue("generated", Query.eq, false));
          }
  
          findRequest.where(Query.and(conditions));
  
          findRequest.select(Projection.includeField("*"));
  
          findRequest.range(startIndex, startIndex + batchSize - 1);
  
          LOGGER.debug("Finding Jobs to execute: {}", findRequest.getBody());
  
          return lbClient.data(findRequest, MigrationJob[].class);
      }
docs: Retrieves jobs that are available, and their scheduled time has passed.
  Returns at most batchSize jobs starting at startIndex