options .toBuilder() .setRetrySettings(ServiceOptions.getDefaultRetrySettings()) .build() .getService(); InsertAllResponse response = bigquery.insertAll(request);
if (args.length >= 2 && !ACTIONS.containsKey(args[0])) { actionName = args[1]; optionsBuilder.setProjectId(args[0]); action = ACTIONS.get(args[1]); args = Arrays.copyOfRange(args, 2, args.length); return; BigQuery bigquery = optionsBuilder.build().getService(); Object arg; try {
BigQueryOptions bigqueryOptions = BigQueryOptions.newBuilder() .setCredentials(ServiceAccountCredentials.fromStream(keyStream)) .setProjectId(projectId) .setRetrySettings(retrySettings()) .setTransportOptions(transportOptions) .build(); return new RemoteBigQueryHelper(bigqueryOptions); } catch (IOException ex) {
String bqProjectId = options.get(BigQueryStorageManager.OPT_BIGQUERY_PROJECT); BigQuery bigQuery = BigQueryOptions.newBuilder().setProjectId(bqProjectId).build().getService(); storageManager = new BigQueryStorageManager(id, bigQuery, bqProjectId, datasetName, viewTemplater);
BigQueryOptions bigqueryOptions = BigQueryOptions.newBuilder() .setCredentials(ServiceAccountCredentials.fromStream(keyStream)) .setProjectId(projectId) .setRetrySettings(retrySettings()) .setTransportOptions(transportOptions) .build(); return new RemoteBigQueryHelper(bigqueryOptions); } catch (IOException ex) {
/** * Returns a default {@link BigQuery} instance for the specified project with credentials provided * in the specified file, 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 * @param keyFilename The name of a file containing a JSON key that can be used to provide * credentials to BigQuery, or null if no authentication should be performed. * @return The resulting BigQuery object. */ public BigQuery connect(String projectName, String keyFilename) { if (keyFilename == null) { return connect(projectName); } logger.debug("Attempting to open file {} for service account json key", keyFilename); try (InputStream credentialsStream = new FileInputStream(keyFilename)) { logger.debug("Attempting to authenticate with BigQuery using provided json key"); return new BigQueryOptions.DefaultBigQueryFactory().create( BigQueryOptions.newBuilder() .setProjectId(projectName) .setCredentials(GoogleCredentials.fromStream(credentialsStream)) .build() ); } catch (IOException err) { throw new BigQueryConnectException("Failed to access json key file", err); } }
/** * Creates a {@code RemoteBigQueryHelper} object for the given project id and JSON key input * stream. * * @param projectId id of the project to be used for running the tests * @param keyStream input stream for a JSON key * @return A {@code RemoteBigQueryHelper} object for the provided options * @throws BigQueryHelperException if {@code keyStream} is not a valid JSON key stream */ public static RemoteBigQueryHelper create(String projectId, InputStream keyStream) throws BigQueryHelperException { try { BigQueryOptions bigqueryOptions = BigQueryOptions.builder() .authCredentials(AuthCredentials.createForJson(keyStream)) .projectId(projectId) .retryParams(retryParams()) .connectTimeout(60000) .readTimeout(60000) .build(); return new RemoteBigQueryHelper(bigqueryOptions); } catch (IOException ex) { if (log.isLoggable(Level.WARNING)) { log.log(Level.WARNING, ex.getMessage()); } throw BigQueryHelperException.translate(ex); } }
/** * 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 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); }
public static BigQueryOptions defaultInstance() { return builder().build(); }
public static BigQueryOptions getDefaultInstance() { return newBuilder().build(); }
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(); } }
@SuppressWarnings("unchecked") @Override public Builder toBuilder() { return new Builder(this); }
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() { BigQueryOptions bigqueryOptions = BigQueryOptions.builder() .retryParams(retryParams()) .connectTimeout(60000) .readTimeout(60000) .build(); return new RemoteBigQueryHelper(bigqueryOptions); }
/** * 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 Builder builder() { return new Builder(); } }
public static Builder newBuilder() { return new Builder(); } }
@SuppressWarnings("unchecked") @Override public Builder toBuilder() { return new Builder(this); }
public BigQuery bigQuery() { if (bigQuery == null) { bigQuery = BigQueryOptions.newBuilder().setCredentials(credentials).setProjectId(projectId).build().getService(); } return bigQuery; }