Search in sources :

Example 1 with ReportJobStatus

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

the class ReportDownloader method waitForReportReady.

/**
 * Blocks and waits for a report to be ready. When a {@link ReportJobStatus} is received that is
 * not {@code ReportJobStatus#Pending} or {@code ReportJobStatus#InProgress}, the report is
 * considered finished, and the method is returned with a {@code true} if the report was
 * successful, or an {@code false} if not.
 *
 * @return {@code true} if the report was successful, {@code false} otherwise
 * @throws ApiException_Exception if there was an error performing one of the SOAP calls
 * @throws InterruptedException if the thread was interrupted
 */
public boolean waitForReportReady() throws InterruptedException, ApiException_Exception {
    ReportJobStatus status = reportService.getReportJobStatus(reportJobId);
    while (status == ReportJobStatus.IN_PROGRESS) {
        Thread.sleep(SLEEP_TIMER);
        status = reportService.getReportJobStatus(reportJobId);
    }
    return status == ReportJobStatus.COMPLETED;
}
Also used : ReportJobStatus(com.google.api.ads.admanager.jaxws.v202105.ReportJobStatus)

Example 2 with ReportJobStatus

use of com.google.api.ads.admanager.axis.v202111.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.v202105.ReportJobStatus) URL(java.net.URL)

Example 3 with ReportJobStatus

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

the class ReportDownloader method waitForReportReady.

/**
 * Blocks and waits for a report to be ready. When a {@link ReportJobStatus} is received that is
 * not {@code ReportJobStatus#Pending} or {@code ReportJobStatus#InProgress}, the report is
 * considered finished, and the method is returned with a {@code true} if the report was
 * successful, or an {@code false} if not.
 *
 * @return {@code true} if the report was successful, {@code false} otherwise
 * @throws ApiException_Exception if there was an error performing one of the SOAP calls
 * @throws InterruptedException if the thread was interrupted
 */
public boolean waitForReportReady() throws InterruptedException, ApiException_Exception {
    ReportJobStatus status = reportService.getReportJobStatus(reportJobId);
    while (status == ReportJobStatus.IN_PROGRESS) {
        Thread.sleep(SLEEP_TIMER);
        status = reportService.getReportJobStatus(reportJobId);
    }
    return status == ReportJobStatus.COMPLETED;
}
Also used : ReportJobStatus(com.google.api.ads.admanager.jaxws.v202108.ReportJobStatus)

Example 4 with ReportJobStatus

use of com.google.api.ads.admanager.axis.v202111.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.v202108.ReportJobStatus) URL(java.net.URL)

Example 5 with ReportJobStatus

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

the class ReportDownloader method waitForReportReady.

/**
 * Blocks and waits for a report to be ready. When a {@link ReportJobStatus} is received that is
 * not {@code ReportJobStatus#Pending} or {@code ReportJobStatus#InProgress}, the report is
 * considered finished, and the method is returned with a {@code true} if the report was
 * successful, or an {@code false} if not.
 *
 * @return {@code true} if the report was successful, {@code false} otherwise
 * @throws ApiException_Exception if there was an error performing one of the SOAP calls
 * @throws InterruptedException if the thread was interrupted
 */
public boolean waitForReportReady() throws InterruptedException, ApiException_Exception {
    ReportJobStatus status = reportService.getReportJobStatus(reportJobId);
    while (status == ReportJobStatus.IN_PROGRESS) {
        Thread.sleep(SLEEP_TIMER);
        status = reportService.getReportJobStatus(reportJobId);
    }
    return status == ReportJobStatus.COMPLETED;
}
Also used : ReportJobStatus(com.google.api.ads.admanager.jaxws.v202202.ReportJobStatus)

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