use of com.google.api.client.http.HttpTransport in project gradle by gradle.
the class GcsClient method create.
public static GcsClient create(GcsConnectionProperties gcsConnectionProperties) throws GeneralSecurityException, IOException {
HttpTransport transport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = new JacksonFactory();
Storage.Builder builder = new Storage.Builder(transport, jsonFactory, null);
if (gcsConnectionProperties.requiresAuthentication()) {
Supplier<Credential> credentialSupplier = getCredentialSupplier(transport, jsonFactory);
builder.setHttpRequestInitializer(new RetryHttpInitializerWrapper(credentialSupplier));
}
if (gcsConnectionProperties.getEndpoint().isPresent()) {
builder.setRootUrl(gcsConnectionProperties.getEndpoint().get().toString());
}
if (gcsConnectionProperties.getServicePath().isPresent()) {
builder.setServicePath(gcsConnectionProperties.getServicePath().get());
}
builder.setApplicationName("gradle");
return new GcsClient(builder.build());
}
Aggregations