@SuppressWarnings("unchecked")
  ConfigGroupRequest getConfigGroupRequest(Map<String, Object> properties) {
    Object groupIdObj = properties.get(ID);
    Long groupId = null;
    if (groupIdObj != null)  {
      groupId = groupIdObj instanceof Long ? (Long) groupIdObj :
        Long.parseLong((String) groupIdObj);
    }

    ConfigGroupRequest request = new ConfigGroupRequest(
      groupId,
      (String) properties.get(CLUSTER_NAME),
      (String) properties.get(GROUP_NAME),
      (String) properties.get(TAG),
      (String) properties.get(SERVICE_NAME),
      (String) properties.get(DESCRIPTION),
      null,
      null);

    request.setServiceConfigVersionNote((String) properties.get(SERVICE_CONFIG_VERSION_NOTE));

    Map<String, Config> configurations = new HashMap<>();
    Set<String> hosts = new HashSet<>();

    String hostnameKey = HOST_NAME;
    Object hostObj = properties.get(HOSTS);
    if (hostObj == null) {
      hostnameKey = HOSTS_HOST_NAME;
      hostObj = properties.get(HOSTS_HOST_NAME);
    }
    if (hostObj != null) {
      if (hostObj instanceof HashSet<?>) {
        try {
          Set<Map<String, String>> hostsSet = (Set<Map<String, String>>) hostObj;
          for (Map<String, String> hostMap : hostsSet) {
            if (hostMap.containsKey(hostnameKey)) {
              String hostname = hostMap.get(hostnameKey);
              hosts.add(hostname);
            }
          }
        } catch (Exception e) {
          LOG.warn("Host json in unparseable format. " + hostObj, e);
        }
      } else {
        if (hostObj instanceof String) {
          hosts.add((String) hostObj);
        }
      }
    }

    Object configObj = properties.get(DESIRED_CONFIGS);
    if (configObj != null && configObj instanceof HashSet<?>) {
      try {
        Set<Map<String, Object>> configSet = (Set<Map<String, Object>>) configObj;
        for (Map<String, Object> configMap : configSet) {
          String type = (String) configMap.get(ConfigurationResourceProvider.TYPE);
          String tag = (String) configMap.get(ConfigurationResourceProvider.TAG);

          Map<String, String> configProperties = new HashMap<>();
          Map<String, Map<String, String>> configAttributes = new HashMap<>();

          for (Map.Entry<String, Object> entry : configMap.entrySet()) {
            String propertyCategory = PropertyHelper.getPropertyCategory(entry.getKey());
            if (propertyCategory != null && entry.getValue() != null) {
              if ("properties".equals(propertyCategory)) {
                configProperties.put(PropertyHelper.getPropertyName(entry.getKey()),
                    entry.getValue().toString());
              } else if ("properties_attributes".equals(PropertyHelper.getPropertyCategory(propertyCategory))) {
                String attributeName = PropertyHelper.getPropertyName(propertyCategory);
                if (!configAttributes.containsKey(attributeName)) {
                  configAttributes.put(attributeName, new HashMap<>());
                }
                Map<String, String> attributeValues
                    = configAttributes.get(attributeName);
                attributeValues.put(PropertyHelper.getPropertyName(entry.getKey()),
                    entry.getValue().toString());
              }
            }
          }

          Config config = configFactory.createReadOnly(type, tag, configProperties, configAttributes);
          configurations.put(config.getType(), config);
        }
      } catch (Exception e) {
        LOG.warn("Config json in unparseable format. " + configObj, e);
      }
    }

    request.setConfigs(configurations);
    request.setHosts(hosts);

    return request;
  }
Create configuration group resources based on set of config group requests.

@param requests  set of config group requests

@return a request status

@throws SystemException                an internal system exception occurred
@throws UnsupportedPropertyException   the request contains unsupported property ids
@throws ResourceAlreadyExistsException attempted to create a resource which already exists
@throws NoSuchParentResourceException  a parent resource of the resource to create doesn't exist
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java