Search in sources :

Example 11 with ReportJobStatus

use of com.google.api.ads.admanager.axis.v202205.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 = 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 RemoteException if there was an error performing any Axis 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 RemoteException, 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.axis.v202202.ReportJobStatus) URL(java.net.URL)

Example 12 with ReportJobStatus

use of com.google.api.ads.admanager.axis.v202205.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 = 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 RemoteException if there was an error performing any Axis 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 RemoteException, 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.axis.v202205.ReportJobStatus) URL(java.net.URL)

Example 13 with ReportJobStatus

use of com.google.api.ads.admanager.axis.v202205.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 RemoteException if there was an error performing one of the SOAP calls
 * @throws InterruptedException if the thread was interrupted
 */
public boolean waitForReportReady() throws RemoteException, InterruptedException {
    ReportJobStatus status = reportService.getReportJobStatus(reportJobId);
    while (status == ReportJobStatus.IN_PROGRESS) {
        sleeper.sleep(SLEEP_TIMER);
        status = reportService.getReportJobStatus(reportJobId);
    }
    return status == ReportJobStatus.COMPLETED;
}
Also used : ReportJobStatus(com.google.api.ads.admanager.axis.v202202.ReportJobStatus)

Example 14 with ReportJobStatus

use of com.google.api.ads.admanager.axis.v202205.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 RemoteException if there was an error performing one of the SOAP calls
 * @throws InterruptedException if the thread was interrupted
 */
public boolean waitForReportReady() throws RemoteException, InterruptedException {
    ReportJobStatus status = reportService.getReportJobStatus(reportJobId);
    while (status == ReportJobStatus.IN_PROGRESS) {
        sleeper.sleep(SLEEP_TIMER);
        status = reportService.getReportJobStatus(reportJobId);
    }
    return status == ReportJobStatus.COMPLETED;
}
Also used : ReportJobStatus(com.google.api.ads.admanager.axis.v202205.ReportJobStatus)

Example 15 with ReportJobStatus

use of com.google.api.ads.admanager.axis.v202205.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 RemoteException if there was an error performing one of the SOAP calls
 * @throws InterruptedException if the thread was interrupted
 */
public boolean waitForReportReady() throws RemoteException, InterruptedException {
    ReportJobStatus status = reportService.getReportJobStatus(reportJobId);
    while (status == ReportJobStatus.IN_PROGRESS) {
        sleeper.sleep(SLEEP_TIMER);
        status = reportService.getReportJobStatus(reportJobId);
    }
    return status == ReportJobStatus.COMPLETED;
}
Also used : ReportJobStatus(com.google.api.ads.admanager.axis.v202108.ReportJobStatus)

Aggregations

URL (java.net.URL)10 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.axis.v202205.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 ReportJobStatus (com.google.api.ads.admanager.jaxws.v202205.ReportJobStatus)2