Search in sources :

Example 1 with SecretConfigsViewModel

use of com.thoughtworks.go.apiv1.internalsecretconfig.models.SecretConfigsViewModel in project gocd by gocd.

the class InternalSecretConfigControllerV1 method index.

public String index(Request request, Response response) throws Exception {
    SecretConfigs secretConfigs = secretConfigService.getAllSecretConfigs();
    SecretConfigsViewModel configsViewModel = new SecretConfigsViewModel().setSecretConfigs(secretConfigs);
    List<String> groups = pipelineConfigService.viewableGroupsFor(currentUsername()).stream().map(PipelineConfigs::getGroup).collect(toList());
    List<String> envNames = environmentConfigService.getEnvironmentNames();
    List<String> scms = pluggableScmService.listAllScms().stream().map(SCM::getName).collect(toList());
    List<String> pkgRepos = packageRepositoryService.getPackageRepositories().stream().map(PackageRepository::getName).collect(toList());
    List<String> clusterProfiles = clusterProfilesService.getPluginProfiles().stream().map(PluginProfile::getId).collect(toList());
    configsViewModel.getAutoSuggestions().put("pipeline_group", groups);
    configsViewModel.getAutoSuggestions().put("environment", envNames);
    configsViewModel.getAutoSuggestions().put("pluggable_scm", scms);
    configsViewModel.getAutoSuggestions().put("package_repository", pkgRepos);
    configsViewModel.getAutoSuggestions().put("cluster_profile", clusterProfiles);
    final String etag = etagFor(configsViewModel);
    if (fresh(request, etag)) {
        return notModified(response);
    }
    setEtagHeader(response, etag);
    return writerForTopLevelObject(request, response, writer -> SecretConfigsViewModelRepresenter.toJSON(writer, configsViewModel));
}
Also used : SecretConfigsViewModel(com.thoughtworks.go.apiv1.internalsecretconfig.models.SecretConfigsViewModel) SecretConfigs(com.thoughtworks.go.config.SecretConfigs)

Aggregations

SecretConfigsViewModel (com.thoughtworks.go.apiv1.internalsecretconfig.models.SecretConfigsViewModel)1 SecretConfigs (com.thoughtworks.go.config.SecretConfigs)1