private Resource toResource(String clusterName, AlertGroupEntity entity,
      Set<String> requestedIds) {

    Resource resource = new ResourceImpl(Resource.Type.AlertGroup);
    resource.setProperty(ALERT_GROUP_ID, entity.getGroupId());
    resource.setProperty(ALERT_GROUP_NAME, entity.getGroupName());
    resource.setProperty(ALERT_GROUP_CLUSTER_NAME, clusterName);

    setResourceProperty(resource, ALERT_GROUP_DEFAULT, entity.isDefault(),
        requestedIds);

    // only set the definitions if requested
    if (BaseProvider.isPropertyRequested(ALERT_GROUP_DEFINITIONS, requestedIds)) {
      Set<AlertDefinitionEntity> definitions = entity.getAlertDefinitions();
      List<AlertDefinitionResponse> definitionList = new ArrayList<>(
        definitions.size());

      for (AlertDefinitionEntity definition : definitions) {
        AlertDefinitionResponse response = AlertDefinitionResponse.coerce(definition);
        definitionList.add(response);
      }

      resource.setProperty(ALERT_GROUP_DEFINITIONS, definitionList);
    }

    if (BaseProvider.isPropertyRequested(ALERT_GROUP_TARGETS, requestedIds)) {
      Set<AlertTargetEntity> targetEntities = entity.getAlertTargets();

      List<AlertTarget> targets = new ArrayList<>(
        targetEntities.size());

      for (AlertTargetEntity targetEntity : targetEntities) {
        AlertTarget target = AlertTarget.coerce(targetEntity);
        targets.add(target);
      }

      resource.setProperty(ALERT_GROUP_TARGETS, targets);
    }

    return resource;
  }
Convert the given {@link AlertGroupEntity} to a {@link Resource}.

@param entity
         the entity to convert.
@param requestedIds
         the properties that were requested or {@code null} for all.
@return the resource representation of the entity (never {@code null}).
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertGroupResourceProvider.java