EntityConfigResource extends AbstractBrooklynRestResource implements EntityConfigApi { @Override public List<ConfigSummary> list(final String application, final String entityToken) { final Entity entity = brooklyn().getEntity(application, entityToken); if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_ENTITY, entity)) { throw WebResourceUtils.forbidden("User '%s' is not authorized to see entity '%s'", Entitlements.getEntitlementContext().user(), entity); } List<ConfigSummary> result = Lists.newArrayList(); for (ConfigKey<?> key : entity.getEntityType().getConfigKeys()) { if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_CONFIG, new EntityAndItem<String>(entity, key.getName()))) { LOG.trace("User {} not authorized to see config {} of entity {}; excluding from ConfigKey list results", new Object[] {Entitlements.getEntitlementContext().user(), key.getName(), entity}); continue; } result.add(ConfigTransformer.of(key).on(entity).includeLinks(ui.getBaseUriBuilder(), true, true).transform()); } return result; }  @Override List<ConfigSummary> list(final String application, final String entityToken); @Override Map<String, Object> batchConfigRead(String application, String entityToken, Boolean raw); @Override Object get(String application, String entityToken, String configKeyName, Boolean raw); @Override String getPlain(String application, String entityToken, String configKeyName, Boolean raw); Object get(boolean preferJson, String application, String entityToken, String configKeyName, Boolean raw); @SuppressWarnings({ "rawtypes", "unchecked" }) @Override void setFromMap(String application, String entityToken, Boolean recurse, Map newValues); @SuppressWarnings({ "rawtypes", "unchecked" }) @Override void set(String application, String entityToken, String configName, Boolean recurse, Object newValue);  }
@Test public void testList() throws Exception { List<EntityConfigSummary> entityConfigSummaries = client().path( URI.create("/applications/simple-app/entities/simple-ent/config")) .get(new GenericType<List<EntityConfigSummary>>() { }); Optional<EntityConfigSummary> configKeyOptional = Iterables.tryFind(entityConfigSummaries, new Predicate<EntityConfigSummary>() { @Override public boolean apply(@Nullable EntityConfigSummary input) { return input != null && "install.version".equals(input.getName()); } }); assertTrue(configKeyOptional.isPresent()); assertEquals(configKeyOptional.get().getType(), "java.lang.String"); assertEquals(configKeyOptional.get().getDescription(), "The suggested version of the software to be installed"); assertFalse(configKeyOptional.get().isReconfigurable()); assertNull(configKeyOptional.get().getDefaultValue()); assertNull(configKeyOptional.get().getLabel()); assertNull(configKeyOptional.get().getPriority()); }