use of com.google.api.services.analytics.Analytics.Management.UnsampledReports.Insert in project incubator-gobblin by apache.
the class GoogleAnalyticsUnsampledExtractor method requestUnsampledReport.
@VisibleForTesting
UnsampledReport requestUnsampledReport(UnsampledReport request) throws IOException {
String accountId = request.getAccountId();
String webPropertyId = request.getWebPropertyId();
String profileId = request.getProfileId();
// GA somehow does not allow these values in it.
request.setAccountId(null).setWebPropertyId(null).setProfileId(null);
final String endDate = request.getEndDate();
final Insert insertRequest = gaService.management().unsampledReports().insert(accountId, webPropertyId, profileId, request);
Config config = ConfigBuilder.create().loadProps(wuState.getProperties(), REQUEST_RETRY_PREFIX).build();
Retryer<UnsampledReport> retryer = RetryerFactory.newInstance(config);
LOG.info("Requesting to create unsampled report " + request);
try {
return retryer.call(new Callable<UnsampledReport>() {
@Override
public UnsampledReport call() throws Exception {
UnsampledReport response = insertRequest.execute();
if (ReportCreationStatus.FAILED.name().equals(response.getStatus())) {
// No retry if it's explicitly failed from server
throw new NonTransientException("Failed to create unsampled report " + response);
}
// response does not have end date where we need it later for next watermark calculation.
response.setEndDate(endDate);
return response;
}
});
} catch (ExecutionException e) {
throw new IOException(e);
} catch (RetryException e) {
throw new RuntimeException(e);
}
}
Aggregations