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));
}
Aggregations