com.google.api.services.bigquery.BigqueryScopes Java Examples

The following examples show how to use com.google.api.services.bigquery.BigqueryScopes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BigqueryClient.java    From beam with Apache License 2.0 5 votes vote down vote up
private static Credentials getDefaultCredential() {
  GoogleCredentials credential;
  try {
    credential = GoogleCredentials.getApplicationDefault();
  } catch (IOException e) {
    throw new RuntimeException("Failed to get application default credential.", e);
  }

  if (credential.createScopedRequired()) {
    Collection<String> bigqueryScope = Lists.newArrayList(BigqueryScopes.all());
    credential = credential.createScoped(bigqueryScope);
  }
  return credential;
}
 
Example #2
Source File: BigQueryInterpreter.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
private static Bigquery createAuthorizedClient() throws IOException {
  HttpTransport transport = new NetHttpTransport();
  JsonFactory jsonFactory = new JacksonFactory();
  GoogleCredential credential =  GoogleCredential.getApplicationDefault(transport, jsonFactory);

  if (credential.createScopedRequired()) {
    Collection<String> bigqueryScopes = BigqueryScopes.all();
    credential = credential.createScoped(bigqueryScopes);
  }

  return new Bigquery.Builder(transport, jsonFactory, credential)
      .setApplicationName("Zeppelin/1.0 (GPN:Apache Zeppelin;)").build();
}
 
Example #3
Source File: BqClient.java    From digdag with Apache License 2.0 5 votes vote down vote up
@Override
protected Bigquery client(GoogleCredential credential, HttpTransport transport, JsonFactory jsonFactory)
{
    if (credential.createScopedRequired()) {
        credential = credential.createScoped(BigqueryScopes.all());
    }

    return new Bigquery.Builder(transport, jsonFactory, credential)
            .setApplicationName("Digdag")
            .build();
}
 
Example #4
Source File: GcsClient.java    From digdag with Apache License 2.0 5 votes vote down vote up
@Override
protected Storage client(GoogleCredential credential, HttpTransport transport, JsonFactory jsonFactory)
{
    if (credential.createScopedRequired()) {
        credential = credential.createScoped(BigqueryScopes.all());
    }

    return new Storage.Builder(transport, jsonFactory, credential)
            .setApplicationName("Digdag")
            .build();
}
 
Example #5
Source File: BigQueryIT.java    From digdag with Apache License 2.0 5 votes vote down vote up
private Bigquery bqClient(GoogleCredential credential)
{
    if (credential.createScopedRequired()) {
        credential = credential.createScoped(BigqueryScopes.all());
    }
    return new Bigquery.Builder(transport, jsonFactory, credential)
            .setApplicationName("digdag-test")
            .build();
}
 
Example #6
Source File: BigQueryConnection.java    From components with Apache License 2.0 5 votes vote down vote up
public static Credentials createCredentials(BigQueryDatastoreProperties datastore) {
    try {
        GoogleCredentials credential = GoogleCredentials
                .fromStream(new FileInputStream(datastore.serviceAccountFile.getValue())).createScoped(BigqueryScopes.all());
        return credential;
    } catch (IOException e) {
        throw new RuntimeException("Exception when read service account file: " + datastore.serviceAccountFile.getValue()
                + "\nMessage is:" + e.getMessage());
    }
}