Search in sources :

Example 1 with ListReposResponse

use of com.google.api.services.source.model.ListReposResponse in project google-cloud-intellij by GoogleCloudPlatform.

the class RepositorySelectorTest method getPopulatedRepositoriesPanel.

private RepositorySelector getPopulatedRepositoriesPanel(boolean openPopup) {
    ListReposResponse reposResponse = new ListReposResponse();
    reposResponse.setRepos(createRepos());
    when(repositoryService.listAsync(any(CredentialedUser.class), anyString())).thenReturn(CompletableFuture.completedFuture(reposResponse));
    return getSelector(openPopup);
}
Also used : ListReposResponse(com.google.api.services.source.model.ListReposResponse) CredentialedUser(com.google.cloud.tools.intellij.login.CredentialedUser)

Example 2 with ListReposResponse

use of com.google.api.services.source.model.ListReposResponse in project google-cloud-intellij by GoogleCloudPlatform.

the class RepositorySelectorTest method getErrorRepositoryPanel.

private RepositorySelector getErrorRepositoryPanel() {
    CompletableFuture<ListReposResponse> failedListing = CompletableFuture.supplyAsync(() -> {
        throw new CloudRepositoryServiceException();
    });
    failedListing.completeExceptionally(new CloudRepositoryServiceException());
    when(repositoryService.listAsync(any(CredentialedUser.class), anyString())).thenReturn(failedListing);
    return getSelector(true);
}
Also used : ListReposResponse(com.google.api.services.source.model.ListReposResponse) CloudRepositoryServiceException(com.google.cloud.tools.intellij.csr.CloudRepositoryService.CloudRepositoryServiceException) CredentialedUser(com.google.cloud.tools.intellij.login.CredentialedUser)

Example 3 with ListReposResponse

use of com.google.api.services.source.model.ListReposResponse in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudRepositoryService method list.

@NotNull
public ListReposResponse list(CredentialedUser user, String cloudProject) throws CloudRepositoryServiceException {
    try {
        Credential credential = user.getCredential();
        HttpRequestInitializer initializer = httpRequest -> {
            HttpHeaders headers = new HttpHeaders();
            httpRequest.setConnectTimeout(LIST_TIMEOUT_MS);
            httpRequest.setReadTimeout(LIST_TIMEOUT_MS);
            httpRequest.setHeaders(headers);
            credential.initialize(httpRequest);
        };
        HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
        String userAgent = ServiceManager.getService(PluginInfoService.class).getUserAgent();
        Source source = new Source.Builder(httpTransport, JacksonFactory.getDefaultInstance(), initializer).setRootUrl(CLOUD_SOURCE_API_ROOT_URL).setServicePath("").setApplicationName(userAgent).build();
        return new CustomUrlSourceRequest(source, cloudProject).execute();
    } catch (IOException | GeneralSecurityException ex) {
        throw new CloudRepositoryServiceException();
    }
}
Also used : HttpHeaders(com.google.api.client.http.HttpHeaders) ListReposResponse(com.google.api.services.source.model.ListReposResponse) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory) HttpTransport(com.google.api.client.http.HttpTransport) GoogleNetHttpTransport(com.google.api.client.googleapis.javanet.GoogleNetHttpTransport) IOException(java.io.IOException) CompletableFuture(java.util.concurrent.CompletableFuture) Preconditions(com.google.api.client.util.Preconditions) Source(com.google.api.services.source.Source) ServiceManager(com.intellij.openapi.components.ServiceManager) GeneralSecurityException(java.security.GeneralSecurityException) HttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer) CredentialedUser(com.google.cloud.tools.intellij.login.CredentialedUser) PluginInfoService(com.google.cloud.tools.intellij.service.PluginInfoService) Key(com.google.api.client.util.Key) Credential(com.google.api.client.auth.oauth2.Credential) SourceRequest(com.google.api.services.source.SourceRequest) NotNull(org.jetbrains.annotations.NotNull) HttpHeaders(com.google.api.client.http.HttpHeaders) Credential(com.google.api.client.auth.oauth2.Credential) GeneralSecurityException(java.security.GeneralSecurityException) PluginInfoService(com.google.cloud.tools.intellij.service.PluginInfoService) IOException(java.io.IOException) Source(com.google.api.services.source.Source) HttpTransport(com.google.api.client.http.HttpTransport) GoogleNetHttpTransport(com.google.api.client.googleapis.javanet.GoogleNetHttpTransport) HttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ListReposResponse (com.google.api.services.source.model.ListReposResponse)3 CredentialedUser (com.google.cloud.tools.intellij.login.CredentialedUser)3 Credential (com.google.api.client.auth.oauth2.Credential)1 GoogleNetHttpTransport (com.google.api.client.googleapis.javanet.GoogleNetHttpTransport)1 HttpHeaders (com.google.api.client.http.HttpHeaders)1 HttpRequestInitializer (com.google.api.client.http.HttpRequestInitializer)1 HttpTransport (com.google.api.client.http.HttpTransport)1 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)1 Key (com.google.api.client.util.Key)1 Preconditions (com.google.api.client.util.Preconditions)1 Source (com.google.api.services.source.Source)1 SourceRequest (com.google.api.services.source.SourceRequest)1 CloudRepositoryServiceException (com.google.cloud.tools.intellij.csr.CloudRepositoryService.CloudRepositoryServiceException)1 PluginInfoService (com.google.cloud.tools.intellij.service.PluginInfoService)1 ServiceManager (com.intellij.openapi.components.ServiceManager)1 IOException (java.io.IOException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 NotNull (org.jetbrains.annotations.NotNull)1