Search in sources :

Example 1 with ELASTIC_AGENT_PROFILE

use of com.thoughtworks.go.config.policy.SupportedEntity.ELASTIC_AGENT_PROFILE in project gocd by gocd.

the class ElasticAgentProfilePermission method permissions.

@Override
public Map<String, Object> permissions(Username username) {
    SupportedEntity entityType = ELASTIC_AGENT_PROFILE;
    List<ElasticProfile> elasticProfiles = config().getElasticConfig().getProfiles();
    LinkedHashMap<String, Object> json = new LinkedHashMap<>();
    json.put(VIEW.getAction(), elasticProfiles.stream().filter(profile -> canView(entityType, profile.getId(), profile.getClusterProfileId())).map(ElasticProfile::getId).collect(Collectors.toList()));
    json.put(ADMINISTER.getAction(), elasticProfiles.stream().filter(profile -> canAdminister(entityType, profile.getId(), profile.getClusterProfileId())).map(ElasticProfile::getId).collect(Collectors.toList()));
    return json;
}
Also used : ELASTIC_AGENT_PROFILE(com.thoughtworks.go.config.policy.SupportedEntity.ELASTIC_AGENT_PROFILE) SupportedEntity(com.thoughtworks.go.config.policy.SupportedEntity) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) LinkedHashMap(java.util.LinkedHashMap) ADMINISTER(com.thoughtworks.go.config.policy.SupportedAction.ADMINISTER) PermissionProvider(com.thoughtworks.go.server.service.permissions.PermissionProvider) Component(org.springframework.stereotype.Component) List(java.util.List) Username(com.thoughtworks.go.server.domain.Username) VIEW(com.thoughtworks.go.config.policy.SupportedAction.VIEW) SecurityService(com.thoughtworks.go.server.service.SecurityService) Map(java.util.Map) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) SupportedEntity(com.thoughtworks.go.config.policy.SupportedEntity) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)1 ADMINISTER (com.thoughtworks.go.config.policy.SupportedAction.ADMINISTER)1 VIEW (com.thoughtworks.go.config.policy.SupportedAction.VIEW)1 SupportedEntity (com.thoughtworks.go.config.policy.SupportedEntity)1 ELASTIC_AGENT_PROFILE (com.thoughtworks.go.config.policy.SupportedEntity.ELASTIC_AGENT_PROFILE)1 Username (com.thoughtworks.go.server.domain.Username)1 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)1 SecurityService (com.thoughtworks.go.server.service.SecurityService)1 PermissionProvider (com.thoughtworks.go.server.service.permissions.PermissionProvider)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Component (org.springframework.stereotype.Component)1