try {
JsonElement jsonElement = doGetJson("/api/v1/clusters");
JsonObject jsonObject = jsonElement.getAsJsonObject();
JsonArray clustersArray = jsonObject.get("items").getAsJsonArray();
if (clustersArray.size() > 0) {
AmbariClusterInfo cluster = new AmbariClusterInfo();
JsonObject clusterObj = clustersArray.get(0).getAsJsonObject()
.get("Clusters").getAsJsonObject();
cluster.setName(clusterObj.get("cluster_name").getAsString());
cluster.setVersion(clusterObj.get("version").getAsString());
return cluster;
}
} catch (HttpException e) {
logger.warn("Unable to determine Ambari clusters", e);
throw new RuntimeException(e.getMessage(), e);