public String readFromAmbari(String path, String method, String data, Map<String, String> headers) throws AmbariApiException, AmbariHttpException {
    String response;

    try {

      if (context.getAmbariClusterStreamProvider() == null) {
        throw new NoClusterAssociatedException(
            "RA060 View is not associated with any cluster. No way to request Ambari.");
      }

      InputStream inputStream = context.getAmbariClusterStreamProvider().readFrom(path, method, data, addRequestedByHeader(headers));
      response = IOUtils.toString(inputStream);
    } catch (IOException e) {
      throw new AmbariApiException("RA050 I/O error while requesting Ambari", e);
    }

    return response;
  }
Request to Ambari REST API. Supports both local and remote cluster
@param path REST API path, e.g. /api/v1/clusters/mycluster/
@param method HTTP method
@param data HTTP data
@param headers HTTP headers
@return response
@throws AmbariApiException IO error or not associated with cluster
contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApi.java