private Resource.Type getCreateType(ResourceInstance resource, String subResourceName) throws IllegalArgumentException{
    if (subResourceName == null || subResourceName.equals("")) {
      throw new IllegalArgumentException("A sub-resource name must be supplied.");
    }
    ResourceInstance res = resource.getSubResources().get(subResourceName);

    if (res == null) {
      throw new IllegalArgumentException("The specified sub-resource name is not valid: '" + subResourceName + "'.");
    }

    return res.getResourceDefinition().getType();
  }
Determine the sub-resource type(s) to be created.

@param resource         the requests resource instance
@param subResourceName  the name of the sub-resource to be created
@return  the resource type

@throws IllegalArgumentException  if the specified sub-resource name is empty or it is not a valid
                                  sub-resource of the parent.
ambari-server/src/main/java/org/apache/ambari/server/api/handlers/QueryCreateHandler.java