@GET
  @Path("/")
  @Produces({"text/plain", "application/json"})
  public Response getValue(@Context HttpHeaders headers, @Context UriInfo ui) {

    StringBuilder sb = new StringBuilder();
    try {
        InputStream in = null;

        //
        // do I have a cluster associated with this view instance?
        //
        Cluster c = context.getCluster();
        if (c != null) {
            AmbariStreamProvider stream = context.getAmbariStreamProvider();

            // use the cluster name and AmbariStreamProvider to access Ambari REST API
            String clusterName = c.getName();
            in = stream.readFrom("/api/v1/clusters/"+clusterName, "GET", null, null, true);
        } else {
            URLStreamProvider stream = context.getURLStreamProvider();
            
            // use the view instance configuration to access Ambari REST API
            String baseUrl = context.getProperties().get("ambari.server.url");
            String username = context.getProperties().get("ambari.server.username");
            String password = context.getProperties().get("ambari.server.password");

            HashMap<String, String> hds = new HashMap<String, String>();
            hds.put("X-Requested-By", "auto-cluster-view");

            String authString = username + ":" + password;
            byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
            String authStringEnc = new String(authEncBytes);

            hds.put("Authorization", "Basic " + authStringEnc);

            in = stream.readFrom(baseUrl, "GET", null, hds);
        }
        
        BufferedReader r = new BufferedReader(new InputStreamReader(in));
        String str = null;
        while ((str = r.readLine()) != null) {
            sb.append(str);
        }
        
    } catch (java.io.IOException ioe) {
        ioe.printStackTrace(); //!!!
    }
        
    return Response.ok(sb.toString()).build();
  }
Handles: GET /.

@param headers   http headers
@param ui        uri info

@return value JSON representation
ambari-views/examples/auto-cluster-view/src/main/java/org/apache/ambari/view/examples/AutoClusterService.java