code: @GET
    @Produces(APPLICATION_JSON)
    @Timed
    @ExceptionMetered
    public Map<JobId, Job> list(
        @QueryParam("q") @DefaultValue("") final String query,
        @QueryParam("hostPattern") @DefaultValue("") final String hostPattern) {
  
      final Map<JobId, Job> allJobs;
      if (!hostPattern.isEmpty()) {
        // for each host that matches this pattern...
        allJobs = model.listHosts(hostPattern).stream()
            // get the host status
            .map(model::getHostStatus)
            // then flat map over the jobs deployed to this host
            .flatMap(hostStatus -> hostStatus.getJobs().keySet().stream())
            .distinct()
            .collect(Collectors.toMap(Function.identity(), model::getJob));
      } else {
        allJobs = model.getJobs();
      }
  
      // Return all jobs if the query string is empty
      if (query.isEmpty()) {
        metrics.jobsInJobList(allJobs.size());
        return allJobs;
      }
  
      // Filter jobs by jobname query
      final Map<JobId, Job> filteredJobs = Maps.newHashMap();
      for (final Map.Entry<JobId, Job> entry : allJobs.entrySet()) {
        if (entry.getKey().toString().contains(query)) {
          filteredJobs.put(entry.getKey(), entry.getValue());
        }
      }
  
      metrics.jobsInJobList(filteredJobs.size());
      return filteredJobs;
    }
docs: Returns a {@link Map} of job id to job definition for all jobs known.  If the query
  parameter {@code q} is specified it will only return jobs whose job id contains the string.
  
  @param query The query string.
  
  @return A map of Job IDs to Jobs.