code: def query_pending_jobs(auth, repo_name=None, return_raw=False):
      
      url = '%s/pending?format=json' % HOST_ROOT
      LOG.debug('About to fetch %s' % url)
      req = requests.get(url, auth=auth, timeout=TCP_TIMEOUT)
  
      # If the revision doesn't exist on buildapi, that means there are
      # no builapi jobs for this revision
      if req.status_code not in [200]:
          return []
  
      raw = req.json()
  
      # If we don't want the data structure to be reduced
      if return_raw:
          return raw
  
      # If we only want pending jobs of a specific repo
      if repo_name and repo_name in list(raw['pending'].keys()):
          repo_list = [repo_name]
      else:
          repo_list = list(raw['pending'].keys())
  
      # Data structure to return
      data = {}
      for repo in repo_list:
          data[repo] = {}
          repo_jobs = raw['pending'][repo]
          for revision in repo_jobs.items():
              data[repo][revision[0]] = revision[1]
  
      return data
docs: Return pending jobs