elasticsearch api code call using highlevelrestclient

Java
Request request = new Request("GET", "/_cluster/health");
request.addParameter("wait_for_status", "green"); 
Response response = client.getLowLevelClient().performRequest(request); 

ClusterHealthStatus healthStatus;
try (InputStream is = response.getEntity().getContent()) { 
    Map<String, Object> map = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true); 
    healthStatus = ClusterHealthStatus.fromStringString) map.get("status"; 
}

if (healthStatus != ClusterHealthStatus.GREEN) {
    
}
Source

Also in Java: