private static Optional<ClusterRequest> createConfigRequestForConfigTypes(
    Stream<String> configTypes,
    AddServiceInfo addServiceRequest,
    Map<String, Map<String, String>> fullProperties,
    Map<String, Map<String, Map<String, String>>> fullAttributes
  ) {
    List<ConfigurationRequest> configRequests = configTypes
      .peek(configType -> LOG.info("Creating request for config type {} for {}", configType, addServiceRequest))
      .map(configType -> new ConfigurationRequest(addServiceRequest.clusterName(), configType, "ADD_SERVICE_" + System.currentTimeMillis(),
        fullProperties.getOrDefault(configType, ImmutableMap.of()),
        fullAttributes.getOrDefault(configType, ImmutableMap.of())))
      .collect(toList());

    if (configRequests.isEmpty()) {
      return Optional.empty();
    }

    ClusterRequest clusterRequest = new ClusterRequest(null, addServiceRequest.clusterName(), null, null);
    clusterRequest.setDesiredConfig(configRequests);
    return Optional.of(clusterRequest);
  }
Creates a {@link ConfigurationRequest} for each config type in the {@code configTypes} stream.

@return an {@code Optional} {@link ClusterRequest} with desired configs set to all the {@code ConfigurationRequests},
or an empty {@code Optional} if the incoming {@code configTypes} stream is empty
ambari-server/src/main/java/org/apache/ambari/server/topology/addservice/ResourceProviderAdapter.java