use of com.google.api.services.bigquery.Bigquery.Builder in project bqjdbc by looker-open-source.
the class Oauth2Bigquery method createBqBuilderForCredential.
/**
* Creates a Bigquery.Builder using the provided GoogleCredential
*
* @param credential a valid GoogleCredential
* @return Bigquery.Builder suitable for initalizing a MinifiedBigquery
*/
private static Bigquery.Builder createBqBuilderForCredential(GoogleCredentials credential, Integer connectTimeout, Integer readTimeout, HttpTransport httpTransport, String userAgent, String rootUrl, List<String> targetServiceAccounts, @Nullable String oauthToken, @Nullable String projectId) {
// If targetServiceAccounts is empty this returns the original credential
credential = impersonateServiceAccount(credential, targetServiceAccounts, projectId);
HttpRequestTimeoutInitializer httpRequestInitializer = createRequestTimeoutInitalizer(credential, connectTimeout, readTimeout);
Bigquery.Builder bqBuilder = new Builder(httpTransport, JSON_FACTORY, httpRequestInitializer).setApplicationName(applicationName);
if (oauthToken != null || userAgent != null) {
BigQueryRequestUserAgentInitializer requestInitializer = new BigQueryRequestUserAgentInitializer();
if (userAgent != null) {
requestInitializer.setUserAgent(userAgent);
}
if (oauthToken != null) {
requestInitializer.setOauthToken(oauthToken);
}
bqBuilder.setBigqueryRequestInitializer(requestInitializer);
}
if (rootUrl != null) {
bqBuilder.setRootUrl(rootUrl);
}
return bqBuilder;
}
Aggregations