Search in sources :

Example 1 with Builder

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;
}
Also used : Builder(com.google.api.services.bigquery.Bigquery.Builder) Bigquery(com.google.api.services.bigquery.Bigquery) MinifiedBigquery(com.google.api.services.bigquery.MinifiedBigquery) Builder(com.google.api.services.bigquery.Bigquery.Builder)

Aggregations

Bigquery (com.google.api.services.bigquery.Bigquery)1 Builder (com.google.api.services.bigquery.Bigquery.Builder)1 MinifiedBigquery (com.google.api.services.bigquery.MinifiedBigquery)1