use of org.sonar.alm.client.github.GithubBinding.GsonInstallations in project sonarqube by SonarSource.
the class GithubApplicationClientImpl method listOrganizations.
@Override
public Organizations listOrganizations(String appUrl, AccessToken accessToken, int page, int pageSize) {
checkPageArgs(page, pageSize);
try {
Organizations organizations = new Organizations();
GetResponse response = appHttpClient.get(appUrl, accessToken, String.format("/user/installations?page=%s&per_page=%s", page, pageSize));
Optional<GsonInstallations> gsonInstallations = response.getContent().map(content -> GSON.fromJson(content, GsonInstallations.class));
if (!gsonInstallations.isPresent()) {
return organizations;
}
organizations.setTotal(gsonInstallations.get().totalCount);
if (gsonInstallations.get().installations != null) {
organizations.setOrganizations(gsonInstallations.get().installations.stream().map(gsonInstallation -> new Organization(gsonInstallation.account.id, gsonInstallation.account.login, null, null, null, null, null, gsonInstallation.targetType)).collect(toList()));
}
return organizations;
} catch (IOException e) {
throw new IllegalStateException(format("Failed to list all organizations accessible by user access token on %s", appUrl), e);
}
}
Aggregations