code: def WaitForReport(self, report_job):
      
      service = self._GetReportService()
      report_job_id = service.runReportJob(report_job)['id']
  
      if self._version > 'v201502':
        status = service.getReportJobStatus(report_job_id)
      else:
        status = service.getReportJob(report_job_id)['reportJobStatus']
  
      while status != 'COMPLETED' and status != 'FAILED':
        _data_downloader_logger.debug('Report job status: %s', status)
        time.sleep(30)
        if self._version > 'v201502':
          status = service.getReportJobStatus(report_job_id)
        else:
          status = service.getReportJob(report_job_id)['reportJobStatus']
  
      if status == 'FAILED':
        raise googleads.errors.AdManagerReportError(report_job_id)
      else:
        _data_downloader_logger.debug('Report has completed successfully')
        return report_job_id
docs: Runs a report, then waits (blocks) for the report to finish generating.
  
      Args:
        report_job: The report job to wait for. This may be a dictionary or an
            instance of the SOAP ReportJob class.
  
      Returns:
        The completed report job's ID as a string.
  
      Raises:
        An AdManagerReportError if the report job fails to complete.