本文整理汇总了Java中com.google.api.services.bigquery.BigqueryScopes类的典型用法代码示例。如果您正苦于以下问题:Java BigqueryScopes类的具体用法?Java BigqueryScopes怎么用?Java BigqueryScopes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BigqueryScopes类属于com.google.api.services.bigquery包,在下文中一共展示了BigqueryScopes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BigQueryExporter
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
public BigQueryExporter(BigQueryExporterConfiguration config) {
this.config = config;
this.checkedSchemas = new HashSet<String>();
this.existingSchemaMap = new HashMap<String, com.google.api.services.bigquery.model.TableSchema>();
HttpTransport transport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
GoogleCredential credential;
try {
credential = GoogleCredential.getApplicationDefault(transport,
jsonFactory);
} catch (IOException e) {
throw new RuntimeException(e);
}
if (credential.createScopedRequired()) {
credential = credential.createScoped(BigqueryScopes.all());
}
this.bq = new Bigquery.Builder(transport, jsonFactory, credential)
.setApplicationName(this.config.applicationName).build();
}
示例2: create
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
/**
* Returns a new connection to Bigquery, first ensuring that the given dataset exists in the
* project with the given id, creating it if required.
*/
public Bigquery create(String projectId, String datasetId) throws IOException {
Bigquery bigquery = create(
getClass().getSimpleName(),
new UrlFetchTransport(),
new JacksonFactory(),
new AppIdentityCredential(BigqueryScopes.all()));
// Note: it's safe for multiple threads to call this as the dataset will only be created once.
if (!knownExistingDatasets.contains(datasetId)) {
ensureDataset(bigquery, projectId, datasetId);
knownExistingDatasets.add(datasetId);
}
return bigquery;
}
示例3: Parser
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
/**
* Initialize the parser by setting up the BigQuery client ready to take take commands.
*
* @throws GeneralSecurityException
* @throws IOException
*/
private Parser() throws GeneralSecurityException, IOException {
final HttpTransport http = GoogleNetHttpTransport.newTrustedTransport();
final JsonFactory jsonFactory = new JacksonFactory();
final KeyStore keyStore = SecurityUtils.getPkcs12KeyStore();
final InputStream key = getClass().getClassLoader().getResourceAsStream(keyFile);
final PrivateKey p12 = SecurityUtils.loadPrivateKeyFromKeyStore(keyStore, key, "notasecret", "privatekey", "notasecret");
final GoogleCredential.Builder credential = new GoogleCredential.Builder();
credential.setTransport(http);
credential.setJsonFactory(jsonFactory);
credential.setServiceAccountId(account);
credential.setServiceAccountScopes(Arrays.asList(BigqueryScopes.BIGQUERY));
credential.setServiceAccountPrivateKey(p12);
final Bigquery.Builder bq = new Bigquery.Builder(http, jsonFactory, credential.build());
bq.setApplicationName(project);
client = bq.build();
}
示例4: client
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
@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();
}
示例5: getDefaultCredential
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
private 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.CLOUD_PLATFORM_READ_ONLY);
credential = credential.createScoped(bigqueryScope);
}
return credential;
}
示例6: provideBigquery
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
@Provides
static Bigquery provideBigquery(
HttpTransport transport,
JsonFactory jsonFactory,
Function<Set<String>, ? extends HttpRequestInitializer> credential,
@Config("projectId") String projectId) {
return new Bigquery.Builder(transport, jsonFactory, credential.apply(BigqueryScopes.all()))
.setApplicationName(projectId)
.build();
}
示例7: createAuthorizedClient
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
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();
}
示例8: createAuthorizedClient
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
private static Bigquery createAuthorizedClient() throws IOException {
Collection<String> BIGQUERY_SCOPES = BigqueryScopes.all();
HttpTransport TRANSPORT = new NetHttpTransport();
JsonFactory JSON_FACTORY = new JacksonFactory();
GoogleCredential credential = GoogleCredential.getApplicationDefault(TRANSPORT, JSON_FACTORY);
if(credential.createScopedRequired()){
credential = credential.createScoped(BIGQUERY_SCOPES);
}
return new Bigquery.Builder(TRANSPORT, JSON_FACTORY, credential).setApplicationName("BigQuery Samples").build();
}
示例9: client
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
@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();
}
示例10: bqClient
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
private Bigquery bqClient(GoogleCredential credential)
{
if (credential.createScopedRequired()) {
credential = credential.createScoped(BigqueryScopes.all());
}
return new Bigquery.Builder(transport, jsonFactory, credential)
.setApplicationName("digdag-test")
.build();
}
示例11: createCredentials
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
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());
}
}
示例12: provideBigquery
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
/** Provides the authenticated Bigquery API object. */
@Provides
@Singleton
Bigquery provideBigquery() {
return new Bigquery.Builder(
new UrlFetchTransport(),
new JacksonFactory(),
new AppIdentityCredential(BigqueryScopes.all()))
.setApplicationName(BigQueryModule.class.getName())
.build();
}
示例13: authorizeviainstalled
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
/**
* Authorizes a bigquery Connection with the given "Installed Application"
* Clientid and Clientsecret
*
* @param clientid
* @param clientsecret
* @return Authorized bigquery Connection
* @throws SQLException
*/
public static Bigquery authorizeviainstalled(String clientid,
String clientsecret,
String userAgent) throws SQLException {
LocalServerReceiver rcvr = new LocalServerReceiver();
List<String> Scopes = new ArrayList<String>();
Scopes.add(BigqueryScopes.BIGQUERY);
Credential credential = null;
try {
logger.debug("Authorizing as installed app.");
credential = Oauth2Bigquery.authorize(
CmdlineUtils.getHttpTransport(),
CmdlineUtils.getJsonFactory(), rcvr, Scopes, clientid,
clientsecret);
} catch (Exception e) {
throw new SQLException(e);
}
logger.debug("Creating a new bigquery client.");
Builder bqBuilder = new Builder(
CmdlineUtils.getHttpTransport(),
CmdlineUtils.getJsonFactory(), credential
);
if (userAgent != null) {
BigQueryRequestUserAgentInitializer requestInitializer = new BigQueryRequestUserAgentInitializer();
requestInitializer.setUserAgent(userAgent);
bqBuilder.setBigqueryRequestInitializer(requestInitializer);
}
Bigquery bigquery = bqBuilder.build();
Oauth2Bigquery.servicepath = bigquery.getServicePath();
return bigquery;
}
示例14: GenerateScopes
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
private static List<String> GenerateScopes(){
List<String> scopes = new ArrayList<String>();
scopes.add(BigqueryScopes.BIGQUERY);
// don't have access to DriveScopes without requiring the entire google drive sdk.
scopes.add(DRIVE_SCOPE);
return scopes;
}
示例15: getBigqueryServiceDomainWide
import com.google.api.services.bigquery.BigqueryScopes; //导入依赖的package包/类
public static Bigquery getBigqueryServiceDomainWide() throws GeneralSecurityException, IOException {
return new Bigquery.Builder(GoogleServices.getInstance().httpTransport, GoogleServices.getInstance().jsonFactory, null)
.setHttpRequestInitializer(GoogleServices.getCredentialDomainWide(Arrays.asList(BigqueryScopes.BIGQUERY)))
.setApplicationName(Config.get(Config.APPLICATION_NAME))
.build();
}