Search in sources :

Example 16 with HttpTransport

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());
}
Also used : HttpTransport(com.google.api.client.http.HttpTransport) GoogleNetHttpTransport(com.google.api.client.googleapis.javanet.GoogleNetHttpTransport) GoogleCredential(com.google.api.client.googleapis.auth.oauth2.GoogleCredential) Credential(com.google.api.client.auth.oauth2.Credential) Storage(com.google.api.services.storage.Storage) JsonFactory(com.google.api.client.json.JsonFactory) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory)

Aggregations

HttpTransport (com.google.api.client.http.HttpTransport)16 NetHttpTransport (com.google.api.client.http.javanet.NetHttpTransport)10 HttpRequest (com.google.api.client.http.HttpRequest)9 HttpResponse (com.google.api.client.http.HttpResponse)8 GoogleCredential (com.google.api.client.googleapis.auth.oauth2.GoogleCredential)6 GenericUrl (com.google.api.client.http.GenericUrl)6 JsonFactory (com.google.api.client.json.JsonFactory)6 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)6 GoogleNetHttpTransport (com.google.api.client.googleapis.javanet.GoogleNetHttpTransport)5 HttpRequestFactory (com.google.api.client.http.HttpRequestFactory)4 IOException (java.io.IOException)4 HttpRequestInitializer (com.google.api.client.http.HttpRequestInitializer)3 MockHttpTransport (com.google.api.client.testing.http.MockHttpTransport)3 Storage (com.google.api.services.storage.Storage)3 ErrorInfo (com.google.api.client.googleapis.json.GoogleJsonError.ErrorInfo)2 LowLevelHttpRequest (com.google.api.client.http.LowLevelHttpRequest)2 GenericJson (com.google.api.client.json.GenericJson)2 MockLowLevelHttpRequest (com.google.api.client.testing.http.MockLowLevelHttpRequest)2 MockLowLevelHttpResponse (com.google.api.client.testing.http.MockLowLevelHttpResponse)2 File (com.google.api.services.drive.model.File)2