Search in sources :

Example 1 with GrpcTransportOptions

use of com.google.cloud.grpc.GrpcTransportOptions in project google-cloud-java by GoogleCloudPlatform.

the class RemoteLoggingHelper method create.

/**
   * Creates a {@code RemoteLoggingHelper} 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 RemoteLoggingHelper} object for the provided options
   * @throws com.google.cloud.logging.testing.RemoteLoggingHelper.LoggingHelperException if
   *     {@code keyStream} is not a valid JSON key stream
   */
public static RemoteLoggingHelper create(String projectId, InputStream keyStream) throws LoggingHelperException {
    try {
        GrpcTransportOptions transportOptions = LoggingOptions.getDefaultGrpcTransportOptions();
        LoggingOptions storageOptions = LoggingOptions.newBuilder().setCredentials(ServiceAccountCredentials.fromStream(keyStream)).setProjectId(projectId).setRetrySettings(retrySettings()).setTransportOptions(transportOptions).build();
        return new RemoteLoggingHelper(storageOptions);
    } catch (IOException ex) {
        if (log.isLoggable(Level.WARNING)) {
            log.log(Level.WARNING, ex.getMessage());
        }
        throw LoggingHelperException.translate(ex);
    }
}
Also used : GrpcTransportOptions(com.google.cloud.grpc.GrpcTransportOptions) LoggingOptions(com.google.cloud.logging.LoggingOptions) IOException(java.io.IOException)

Example 2 with GrpcTransportOptions

use of com.google.cloud.grpc.GrpcTransportOptions in project google-cloud-java by GoogleCloudPlatform.

the class RemoteLoggingHelper method create.

/**
   * Creates a {@code RemoteLoggingHelper} object using default project id and authentication
   * credentials.
   */
public static RemoteLoggingHelper create() throws LoggingHelperException {
    GrpcTransportOptions transportOptions = LoggingOptions.getDefaultGrpcTransportOptions();
    LoggingOptions loggingOptions = LoggingOptions.newBuilder().setRetrySettings(retrySettings()).setTransportOptions(transportOptions).build();
    return new RemoteLoggingHelper(loggingOptions);
}
Also used : GrpcTransportOptions(com.google.cloud.grpc.GrpcTransportOptions) LoggingOptions(com.google.cloud.logging.LoggingOptions)

Example 3 with GrpcTransportOptions

use of com.google.cloud.grpc.GrpcTransportOptions in project google-cloud-java by GoogleCloudPlatform.

the class SerializationTest method serializableObjects.

@Override
protected Serializable[] serializableObjects() {
    GrpcTransportOptions transportOptions = LoggingOptions.getDefaultGrpcTransportOptions();
    LoggingOptions options = LoggingOptions.newBuilder().setProjectId("p1").setTransportOptions(transportOptions).build();
    return new Serializable[] { options, HTTP_REQUEST, OPERATION, STRING_PAYLOAD, JSON_PAYLOAD, PROTO_PAYLOAD, ENTRY, METRIC_INFO, METRIC, BUCKET_DESTINATION, DATASET_DESTINATION, TOPIC_DESTINATION, SINK_INFO, SINK, PAGE_TOKEN_OPTION, PAGE_SIZE_OPTION, LABELS_OPTION, LOG_OPTION, RESOURCE_OPTION, ENTRY_PAGE_TOKEN_OPTION, ENTRY_PAGE_SIZE_OPTION, ENTRY_FILTER_OPTION, ENTRY_SORT_ORDER_OPTION };
}
Also used : GrpcTransportOptions(com.google.cloud.grpc.GrpcTransportOptions) Serializable(java.io.Serializable)

Aggregations

GrpcTransportOptions (com.google.cloud.grpc.GrpcTransportOptions)3 LoggingOptions (com.google.cloud.logging.LoggingOptions)2 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1