use of com.sequenceiq.cloudbreak.cloud.azure.AzureTenantListResult in project cloudbreak by hortonworks.
the class TenantChecker method collectTenants.
private List<AzureTenant> collectTenants(String accessToken, Response response) throws InteractiveLoginException {
if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
AzureTenantListResult azureTenantListResult = response.readEntity(AzureTenantListResult.class);
List<AzureTenant> tenantList = azureTenantListResult.getValue();
if (azureTenantListResult.getNextLink() != null) {
tenantList.addAll(getNextSetOfTenants(azureTenantListResult.getNextLink(), accessToken));
}
return tenantList;
} else {
String errorResponse = response.readEntity(String.class);
try {
String errorMessage = new ObjectMapper().readTree(errorResponse).get("error").get("message").asText();
LOGGER.info("Tenant retrieve error:" + errorMessage);
throw new InteractiveLoginException("Error with the tenants, message: " + errorMessage);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}
Aggregations