Search in sources :

Example 16 with ReportJobStatus

use of com.google.api.ads.admanager.axis.v202202.ReportJobStatus in project googleads-java-lib by googleads.

the class ReportDownloader method getDownloadUrl.

/**
 * Gets the download URL for a GZip or plain-text format report. If you requested a compressed
 * report, you may want to save your file with a gz or zip extension.
 *
 * <pre><code>
 *  URL url = new URL(reportDownloader.getDownloadUrl(options));
 *  Resources.asByteSource(url).copyTo(Files.asByteSink(file));
 * </code></pre>
 *
 * @param options the options to download the report with
 * @return the URL for the report download
 * @throws ApiException_Exception if there was an error performing any jaxws call
 * @throws MalformedURLException if there is an error forming the download URL
 * @throws IllegalStateException if the report is not ready to be downloaded
 */
public URL getDownloadUrl(ReportDownloadOptions options) throws ApiException_Exception, MalformedURLException {
    ReportJobStatus status = reportService.getReportJobStatus(reportJobId);
    Preconditions.checkState(status == ReportJobStatus.COMPLETED, "Report " + reportJobId + " must be completed before downloading. It is currently: " + status);
    return new URL(reportService.getReportDownloadUrlWithOptions(reportJobId, options));
}
Also used : ReportJobStatus(com.google.api.ads.admanager.jaxws.v202111.ReportJobStatus) URL(java.net.URL)

Aggregations

URL (java.net.URL)8 ReportJobStatus (com.google.api.ads.admanager.axis.v202105.ReportJobStatus)2 ReportJobStatus (com.google.api.ads.admanager.axis.v202108.ReportJobStatus)2 ReportJobStatus (com.google.api.ads.admanager.axis.v202111.ReportJobStatus)2 ReportJobStatus (com.google.api.ads.admanager.axis.v202202.ReportJobStatus)2 ReportJobStatus (com.google.api.ads.admanager.jaxws.v202105.ReportJobStatus)2 ReportJobStatus (com.google.api.ads.admanager.jaxws.v202108.ReportJobStatus)2 ReportJobStatus (com.google.api.ads.admanager.jaxws.v202111.ReportJobStatus)2 ReportJobStatus (com.google.api.ads.admanager.jaxws.v202202.ReportJobStatus)2