Search in sources :

Example 1 with PipelineStructureViewModel

use of com.thoughtworks.go.apiv1.internalpipelinestructure.models.PipelineStructureViewModel in project gocd by gocd.

the class InternalPipelineStructureControllerV1 method index.

public String index(Request request, Response response) throws IOException {
    String pipelineGroupAuthorizationType = request.queryParamOrDefault("pipeline_group_authorization", "view");
    String templateAuthorizationType = request.queryParamOrDefault("template_authorization", "view");
    Supplier<PipelineGroups> pipelineGroupsSupplier = pipelineGroupAuthorizationRegistry.get(pipelineGroupAuthorizationType);
    Supplier<TemplatesConfig> templatesConfigSupplier = templateAuthorizationRegistry.get(templateAuthorizationType);
    if (pipelineGroupsSupplier == null || templatesConfigSupplier == null) {
        HaltApiResponses.haltBecauseOfReason("Bad query parameter.");
    }
    EnvironmentsConfig environments = new EnvironmentsConfig();
    environments.addAll(environmentConfigService.getEnvironments());
    Hashtable<CaseInsensitiveString, Node> dependencyTable = goConfigService.getCurrentConfig().getDependencyTable();
    PipelineStructureViewModel pipelineStructureViewModel = new PipelineStructureViewModel().setPipelineGroups(pipelineGroupsSupplier.get()).setTemplatesConfig(templatesConfigSupplier.get()).setEnvironmentsConfig(environments).setPipelineDependencyTable(dependencyTable);
    boolean withAdditionalInfo = parseBoolean(request.queryParams("with_additional_info"));
    if (!withAdditionalInfo) {
        return writerForTopLevelObject(request, response, outputWriter -> InternalPipelineStructuresRepresenter.toJSON(outputWriter, pipelineStructureViewModel));
    }
    Collection<String> users = userService.allUsernames();
    Collection<String> roles = userService.allRoleNames();
    return writerForTopLevelObject(request, response, outputWriter -> InternalPipelineStructuresRepresenter.toJSON(outputWriter, pipelineStructureViewModel, users, roles));
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) TemplatesConfig(com.thoughtworks.go.config.TemplatesConfig) Node(com.thoughtworks.go.util.Node) PipelineStructureViewModel(com.thoughtworks.go.apiv1.internalpipelinestructure.models.PipelineStructureViewModel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) EnvironmentsConfig(com.thoughtworks.go.config.EnvironmentsConfig)

Aggregations

PipelineStructureViewModel (com.thoughtworks.go.apiv1.internalpipelinestructure.models.PipelineStructureViewModel)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 EnvironmentsConfig (com.thoughtworks.go.config.EnvironmentsConfig)1 TemplatesConfig (com.thoughtworks.go.config.TemplatesConfig)1 PipelineGroups (com.thoughtworks.go.domain.PipelineGroups)1 Node (com.thoughtworks.go.util.Node)1