Search in sources :

Example 1 with HttpTransportOptions

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

the class RemoteStorageHelper method create.

/**
   * Creates a {@code RemoteStorageHelper} 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 RemoteStorageHelper} object for the provided options
   * @throws com.google.cloud.storage.testing.RemoteStorageHelper.StorageHelperException if
   *     {@code keyStream} is not a valid JSON key stream
   */
public static RemoteStorageHelper create(String projectId, InputStream keyStream) throws StorageHelperException {
    try {
        HttpTransportOptions transportOptions = StorageOptions.getDefaultHttpTransportOptions();
        transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build();
        StorageOptions storageOptions = StorageOptions.newBuilder().setCredentials(GoogleCredentials.fromStream(keyStream)).setProjectId(projectId).setRetrySettings(retrySettings()).setTransportOptions(transportOptions).build();
        return new RemoteStorageHelper(storageOptions);
    } catch (IOException ex) {
        if (log.isLoggable(Level.WARNING)) {
            log.log(Level.WARNING, ex.getMessage());
        }
        throw StorageHelperException.translate(ex);
    }
}
Also used : StorageOptions(com.google.cloud.storage.StorageOptions) IOException(java.io.IOException) HttpTransportOptions(com.google.cloud.http.HttpTransportOptions)

Example 2 with HttpTransportOptions

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

the class RemoteStorageHelper method create.

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

Example 3 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 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 RemoteComputeHelper} object for the provided options
   * @throws ComputeHelperException if {@code keyStream} is not a valid JSON key stream
   */
public static RemoteComputeHelper create(String projectId, InputStream keyStream) {
    try {
        HttpTransportOptions transportOptions = ComputeOptions.getDefaultHttpTransportOptions();
        transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build();
        ComputeOptions computeOptions = ComputeOptions.newBuilder().setCredentials(ServiceAccountCredentials.fromStream(keyStream)).setProjectId(projectId).setRetrySettings(retrySettings()).setTransportOptions(transportOptions).build();
        return new RemoteComputeHelper(computeOptions);
    } catch (IOException ex) {
        if (log.isLoggable(Level.WARNING)) {
            log.log(Level.WARNING, ex.getMessage());
        }
        throw ComputeHelperException.translate(ex);
    }
}
Also used : ComputeOptions(com.google.cloud.compute.ComputeOptions) IOException(java.io.IOException) HttpTransportOptions(com.google.cloud.http.HttpTransportOptions)

Example 4 with HttpTransportOptions

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

the class RemoteDatastoreHelper method create.

/**
   * Creates a {@code RemoteStorageHelper} object.
   */
public static RemoteDatastoreHelper create() {
    HttpTransportOptions transportOptions = DatastoreOptions.getDefaultHttpTransportOptions();
    transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build();
    DatastoreOptions datastoreOption = DatastoreOptions.newBuilder().setNamespace(UUID.randomUUID().toString()).setRetrySettings(retrySettings()).setTransportOptions(transportOptions).build();
    return new RemoteDatastoreHelper(datastoreOption);
}
Also used : DatastoreOptions(com.google.cloud.datastore.DatastoreOptions) HttpTransportOptions(com.google.cloud.http.HttpTransportOptions)

Example 5 with HttpTransportOptions

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

the class RemoteTranslateHelper method create.

/**
   * Creates a {@code RemoteStorageHelper} object.
   */
public static RemoteTranslateHelper create() {
    HttpTransportOptions transportOptions = TranslateOptions.getDefaultHttpTransportOptions();
    transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build();
    TranslateOptions translateOption = TranslateOptions.newBuilder().setRetrySettings(retryParams()).setTransportOptions(transportOptions).build();
    return new RemoteTranslateHelper(translateOption);
}
Also used : TranslateOptions(com.google.cloud.translate.TranslateOptions) 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