public static BigQueryOptions getDefaultInstance() { return newBuilder().build(); }
return; BigQueryOptions.Builder optionsBuilder = BigQueryOptions.newBuilder(); BigQueryAction action; String actionName;
@Test public void testInvalidTransport() { thrown.expect(IllegalArgumentException.class); BigQueryOptions.newBuilder().setTransportOptions(EasyMock.createMock(TransportOptions.class)); } }
@Override protected Restorable<?>[] restorableObjects() { BigQueryOptions options = BigQueryOptions.newBuilder().setProjectId("p2").build(); // avoid closing when you don't want partial writes upon failure @SuppressWarnings("resource") TableDataWriteChannel writer = new TableDataWriteChannel(options, LOAD_CONFIGURATION, "upload-id"); return new Restorable<?>[] {writer}; } }
@Before public void setUp() { rpcFactoryMock = createMock(BigQueryRpcFactory.class); bigqueryRpcMock = createMock(BigQueryRpc.class); bigqueryFactoryMock = createMock(BigQueryFactory.class); bigqueryMock = createMock(BigQuery.class); expect(bigqueryMock.getOptions()).andReturn(options).anyTimes(); replay(bigqueryMock); job = new Job(bigqueryMock, new JobInfo.BuilderImpl(JOB_INFO)); expect(rpcFactoryMock.create(anyObject(BigQueryOptions.class))).andReturn(bigqueryRpcMock); expect(bigqueryFactoryMock.create(anyObject(BigQueryOptions.class))) .andReturn(bigqueryMock) .anyTimes(); replay(rpcFactoryMock, bigqueryFactoryMock); options = BigQueryOptions.newBuilder() .setProjectId("projectid") .setServiceRpcFactory(rpcFactoryMock) .setServiceFactory(bigqueryFactoryMock) .build(); }
.build(); BigQueryOptions bigqueryOptions = BigQueryOptions.newBuilder() .setCredentials(ServiceAccountCredentials.fromStream(keyStream)) .setProjectId(projectId)
@Override protected BigQueryOptions getServiceOptions(ProcessContext context, GoogleCredentials credentials) { final String projectId = context.getProperty(PROJECT_ID).evaluateAttributeExpressions().getValue(); final Integer retryCount = Integer.valueOf(context.getProperty(RETRY_COUNT).getValue()); final BigQueryOptions.Builder builder = BigQueryOptions.newBuilder(); if (!StringUtils.isBlank(projectId)) { builder.setProjectId(projectId); } return builder.setCredentials(credentials) .setRetrySettings(RetrySettings.newBuilder().setMaxAttempts(retryCount).build()) .setTransportOptions(getTransportOptions(context)) .build(); }
private BigQueryOptions createBigQueryOptionsForProject( String project, BigQueryRpcFactory rpcFactory) { return BigQueryOptions.newBuilder() .setProjectId(project) .setServiceRpcFactory(rpcFactory) .setRetrySettings(ServiceOptions.getNoRetrySettings()) .build(); }
private BigQueryOptions createBigQueryOptionsForProjectWithLocation( String project, BigQueryRpcFactory rpcFactory) { return BigQueryOptions.newBuilder() .setProjectId(project) .setLocation(LOCATION) .setServiceRpcFactory(rpcFactory) .setRetrySettings(ServiceOptions.getNoRetrySettings()) .build(); }
/** * Creates a {@code RemoteBigQueryHelper} object using default project id and authentication * credentials. */ public static RemoteBigQueryHelper create() { HttpTransportOptions transportOptions = BigQueryOptions.getDefaultHttpTransportOptions(); transportOptions = transportOptions .toBuilder() .setConnectTimeout(connectTimeout) .setReadTimeout(connectTimeout) .build(); BigQueryOptions bigqueryOptions = BigQueryOptions.newBuilder() .setRetrySettings(retrySettings()) .setTransportOptions(transportOptions) .build(); return new RemoteBigQueryHelper(bigqueryOptions); }
@Override protected Serializable[] serializableObjects() { BigQueryOptions options = BigQueryOptions.newBuilder() .setProjectId("p1") .setCredentials(NoCredentials.getInstance())
public static void explicit() throws IOException { // Load credentials from JSON key file. If you can't set the GOOGLE_APPLICATION_CREDENTIALS // environment variable, you can explicitly load the credentials file to construct the // credentials. GoogleCredentials credentials; File credentialsPath = new File("service_account.json"); // TODO: update to your key path. try (FileInputStream serviceAccountStream = new FileInputStream(credentialsPath)) { credentials = ServiceAccountCredentials.fromStream(serviceAccountStream); } // Instantiate a client. BigQuery bigquery = BigQueryOptions.newBuilder().setCredentials(credentials).build().getService(); // Use the client. System.out.println("Datasets:"); for (Dataset dataset : bigquery.listDatasets().iterateAll()) { System.out.printf("%s%n", dataset.getDatasetId().getDataset()); } } // [END bigquery_client_json_credentials]
public static BigQueryOptions getDefaultInstance() { return newBuilder().build(); }
@Bean public BigQueryDatasetCreator getBigQueryTrainingDatasetCreator( BigQueryDatasetTemplater templater, @Value("${feast.core.projectId}") String projectId, @Value("${feast.core.datasetPrefix}") String datasetPrefix) { BigQuery bigquery = BigQueryOptions.newBuilder().setProjectId(projectId).build().getService(); Clock clock = Clock.systemUTC(); return new BigQueryDatasetCreator(templater, bigquery, clock, projectId, datasetPrefix); } }
public BigQuery bigQuery() { if (bigQuery == null) { bigQuery = BigQueryOptions.newBuilder().setCredentials(credentials).setProjectId(projectId).build().getService(); } return bigQuery; }
/** * Returns a default {@link BigQuery} instance for the specified project with no authentication * credentials, which can then be used for creating, updating, and inserting into tables from * specific datasets. * * @param projectName The name of the BigQuery project to work with * @return The resulting BigQuery object. */ public BigQuery connect(String projectName) { logger.debug("Attempting to access BigQuery without authentication"); return new BigQueryOptions.DefaultBigQueryFactory().create( BigQueryOptions.newBuilder() .setProjectId(projectName) .build() ); } }
/** * Creates the publisher with a application default credentials from the environment and default * project name. */ public static BigQueryClient create(String dataset) { BigQueryOptions options = BigQueryOptions.newBuilder().build(); return new BigQueryClient(options.getService(), options.getProjectId(), dataset); }
public static BigQuery createClient(BigQueryDatastoreProperties datastore) { if (StringUtils.isEmpty(datastore.serviceAccountFile.getValue())) { return BigQueryOptions.getDefaultInstance().getService(); } else { return BigQueryOptions.newBuilder().setProjectId(datastore.projectName.getValue()) .setCredentials(createCredentials(datastore)).build().getService(); } }
public static BigQuery createClient(BigQueryDatastoreProperties datastore) { if (StringUtils.isEmpty(datastore.serviceAccountFile.getValue())) { return BigQueryOptions.getDefaultInstance().getService(); } else { return BigQueryOptions.newBuilder().setProjectId(datastore.projectName.getValue()) .setCredentials(createCredentials(datastore)).build().getService(); } }
/** * Creates a {@code RemoteBigQueryHelper} object using default project id and authentication * credentials. */ public static RemoteBigQueryHelper create() { HttpTransportOptions transportOptions = BigQueryOptions.getDefaultHttpTransportOptions(); transportOptions = transportOptions .toBuilder() .setConnectTimeout(connectTimeout) .setReadTimeout(connectTimeout) .build(); BigQueryOptions bigqueryOptions = BigQueryOptions.newBuilder() .setRetrySettings(retrySettings()) .setTransportOptions(transportOptions) .build(); return new RemoteBigQueryHelper(bigqueryOptions); }