protected Result createResult(RequestStatus requestStatus) {

    boolean            isSynchronous = requestStatus.getStatus() == RequestStatus.Status.Complete;
    Result             result        = new ResultImpl(isSynchronous);
    TreeNode<Resource> tree          = result.getResultTree();

    if (! isSynchronous) {
      tree.addChild(requestStatus.getRequestResource(), "request");
    }

    Set<Resource> setResources = requestStatus.getAssociatedResources();
    if (! setResources.isEmpty()) {
      TreeNode<Resource> resourcesNode = tree.addChild(null, RESOURCES_NODE_NAME);
      resourcesNode.setProperty("isCollection", "true");

      int count = 1;
      for (Resource resource : setResources) {
        //todo: provide a more meaningful node name
        resourcesNode.addChild(resource, resource.getType() + ":" + count++);
      }
    }
    result.setResultMetadata(convert(requestStatus.getStatusMetadata()));
    return result;
  }
Create a result from a request status.

@param requestStatus  the request status to build the result from.

@return  a Result instance for the provided request status
ambari-server/src/main/java/org/apache/ambari/server/api/handlers/BaseManagementHandler.java