protected Resource toResource(BlueprintEntity entity, Set<String> requestedIds) throws NoSuchResourceException {
    StackEntity stackEntity = entity.getStack();
    Resource resource = new ResourceImpl(Resource.Type.Blueprint);
    setResourceProperty(resource, BLUEPRINT_NAME_PROPERTY_ID, entity.getBlueprintName(), requestedIds);
    setResourceProperty(resource, STACK_NAME_PROPERTY_ID, stackEntity.getStackName(), requestedIds);
    setResourceProperty(resource, STACK_VERSION_PROPERTY_ID, stackEntity.getStackVersion(), requestedIds);

    List<Map<String, Object>> listGroupProps = new ArrayList<>();
    Collection<HostGroupEntity> hostGroups = entity.getHostGroups();
    for (HostGroupEntity hostGroup : hostGroups) {
      Map<String, Object> mapGroupProps = new HashMap<>();
      mapGroupProps.put(HOST_GROUP_NAME_PROPERTY_ID, hostGroup.getName());
      listGroupProps.add(mapGroupProps);
      mapGroupProps.put(HOST_GROUP_CARDINALITY_PROPERTY_ID, hostGroup.getCardinality());

      List<Map<String, String>> listComponentProps = new ArrayList<>();
      Collection<HostGroupComponentEntity> components = hostGroup.getComponents();
      for (HostGroupComponentEntity component : components) {
        Map<String, String> mapComponentProps = new HashMap<>();
        mapComponentProps.put(COMPONENT_NAME_PROPERTY_ID, component.getName());

        if (component.getProvisionAction() != null) {
          mapComponentProps.put(COMPONENT_PROVISION_ACTION_PROPERTY_ID, component.getProvisionAction().toString());
        }

        listComponentProps.add(mapComponentProps);
      }
      mapGroupProps.put(COMPONENT_PROPERTY_ID, listComponentProps);
      mapGroupProps.put(CONFIGURATION_PROPERTY_ID, populateConfigurationList(
          hostGroup.getConfigurations()));
    }
    setResourceProperty(resource, HOST_GROUP_PROPERTY_ID, listGroupProps, requestedIds);
    setResourceProperty(resource, CONFIGURATION_PROPERTY_ID,
      populateConfigurationList(entity.getConfigurations()), requestedIds);
    setResourceProperty(resource, SETTING_PROPERTY_ID,
      populateSettingList(entity.getSettings()), requestedIds);

    if (entity.getSecurityType() != null) {
      Map<String, String> securityConfigMap = new LinkedHashMap<>();
      securityConfigMap.put(SecurityConfigurationFactory.TYPE_PROPERTY_ID, entity.getSecurityType().name());
      if(entity.getSecurityType() == SecurityType.KERBEROS) {
        securityConfigMap.put(SecurityConfigurationFactory.KERBEROS_DESCRIPTOR_REFERENCE_PROPERTY_ID, entity.getSecurityDescriptorReference());
      }
      setResourceProperty(resource, BLUEPRINT_SECURITY_PROPERTY_ID, securityConfigMap, requestedIds);
    }

    return resource;
  }
Create a resource instance from a blueprint entity.

@param entity        blueprint entity
@param requestedIds  requested id's

@return a new resource instance for the given blueprint entity
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintResourceProvider.java