Search in sources :

Example 6 with HttpTransportOptions

use of com.google.cloud.http.HttpTransportOptions in project google-cloud-java by GoogleCloudPlatform.

the class RemoteTranslateHelper method create.

/**
   * Creates a {@code RemoteTranslateHelper} object for the given API key.
   *
   * @param apiKey API key used to issue requests to Google Translation.
   */
public static RemoteTranslateHelper create(String apiKey) {
    HttpTransportOptions transportOptions = TranslateOptions.getDefaultHttpTransportOptions();
    transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build();
    TranslateOptions translateOptions = TranslateOptions.newBuilder().setApiKey(apiKey).setRetrySettings(retryParams()).setTransportOptions(transportOptions).build();
    return new RemoteTranslateHelper(translateOptions);
}
Also used : TranslateOptions(com.google.cloud.translate.TranslateOptions) HttpTransportOptions(com.google.cloud.http.HttpTransportOptions)

Example 7 with HttpTransportOptions

use of com.google.cloud.http.HttpTransportOptions in project google-cloud-java by GoogleCloudPlatform.

the class RemoteBigQueryHelper method create.

/**
   * Creates a {@code RemoteBigQueryHelper} object using default project id and authentication
   * credentials.
   */
public static RemoteBigQueryHelper create() {
    HttpTransportOptions transportOptions = BigQueryOptions.getDefaultHttpTransportOptions();
    transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build();
    BigQueryOptions bigqueryOptions = BigQueryOptions.newBuilder().setRetrySettings(retrySettings()).setTransportOptions(transportOptions).build();
    return new RemoteBigQueryHelper(bigqueryOptions);
}
Also used : BigQueryOptions(com.google.cloud.bigquery.BigQueryOptions) HttpTransportOptions(com.google.cloud.http.HttpTransportOptions)

Example 8 with HttpTransportOptions

use of com.google.cloud.http.HttpTransportOptions in project google-cloud-java by GoogleCloudPlatform.

the class RemoteBigQueryHelper method create.

/**
   * 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 {
        HttpTransportOptions transportOptions = BigQueryOptions.getDefaultHttpTransportOptions();
        transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build();
        BigQueryOptions bigqueryOptions = BigQueryOptions.newBuilder().setCredentials(ServiceAccountCredentials.fromStream(keyStream)).setProjectId(projectId).setRetrySettings(retrySettings()).setTransportOptions(transportOptions).build();
        return new RemoteBigQueryHelper(bigqueryOptions);
    } catch (IOException ex) {
        if (log.isLoggable(Level.WARNING)) {
            log.log(Level.WARNING, ex.getMessage());
        }
        throw BigQueryHelperException.translate(ex);
    }
}
Also used : BigQueryOptions(com.google.cloud.bigquery.BigQueryOptions) IOException(java.io.IOException) HttpTransportOptions(com.google.cloud.http.HttpTransportOptions)

Example 9 with HttpTransportOptions

use of com.google.cloud.http.HttpTransportOptions in project google-cloud-java by GoogleCloudPlatform.

the class RemoteComputeHelper method create.

/**
   * Creates a {@code RemoteComputeHelper} object using default project id and authentication
   * credentials.
   */
public static RemoteComputeHelper create() {
    HttpTransportOptions transportOptions = ComputeOptions.getDefaultHttpTransportOptions();
    transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build();
    ComputeOptions computeOptions = ComputeOptions.newBuilder().setRetrySettings(retrySettings()).setTransportOptions(transportOptions).build();
    return new RemoteComputeHelper(computeOptions);
}
Also used : ComputeOptions(com.google.cloud.compute.ComputeOptions) HttpTransportOptions(com.google.cloud.http.HttpTransportOptions)

Aggregations

HttpTransportOptions (com.google.cloud.http.HttpTransportOptions)9 IOException (java.io.IOException)3 BigQueryOptions (com.google.cloud.bigquery.BigQueryOptions)2 ComputeOptions (com.google.cloud.compute.ComputeOptions)2 StorageOptions (com.google.cloud.storage.StorageOptions)2 TranslateOptions (com.google.cloud.translate.TranslateOptions)2 DatastoreOptions (com.google.cloud.datastore.DatastoreOptions)1