private Response addRoleUsers(Long roleId, Set<Long> userIds) { List<UserRole> userRoles = new ArrayList<>(); userIds.forEach(userId -> { userRoles.add(catalogService.addUserRole(userId, roleId)); }); return WSUtils.respondEntities(userRoles, OK); }
private Response buildNamespacesGetResponse(Collection<Namespace> namespaces, Boolean detail) { if (BooleanUtils.isTrue(detail)) { List<CatalogResourceUtil.NamespaceWithMapping> namespacesWithMapping = namespaces.stream() .map(namespace -> CatalogResourceUtil.enrichNamespace(namespace, environmentService)) .collect(toList()); return WSUtils.respondEntities(namespacesWithMapping, OK); } else { return WSUtils.respondEntities(namespaces, OK); } }
private Response buildClustersGetResponse(Collection<Cluster> clusters, Boolean detail) { if (BooleanUtils.isTrue(detail)) { List<ClusterResourceUtil.ClusterServicesImportResult> clustersWithServices = clusters.stream() .map(c -> ClusterResourceUtil.enrichCluster(c, environmentService)) .collect(Collectors.toList()); return WSUtils.respondEntities(clustersWithServices, OK); } else { return WSUtils.respondEntities(clusters, OK); } }
@GET @Path("ml/models") @Produces(MediaType.APPLICATION_JSON) @Timed public Response listModelInfos() { return WSUtils.respondEntities(modelRegistryService.listModelInfos(), OK); }
public Response listChildRoles(Long roleId, @Context SecurityContext securityContext) throws Exception { Collection<Role> roles = catalogService.getChildRoles(roleId); if (roles != null) { return WSUtils.respondEntities(roles, OK); } throw EntityNotFoundException.byId(roleId.toString()); }
private Response getRoleUsers(Long roleId) { Role role = catalogService.getRole(roleId); Set<Role> rolesToQuery = new HashSet<>(); if (role != null) { rolesToQuery.add(role); rolesToQuery.addAll(catalogService.getChildRoles(roleId)); Set<User> res = rolesToQuery.stream().flatMap(r -> catalogService.listUsers(r).stream()).collect(Collectors.toSet()); return WSUtils.respondEntities(res, OK); } throw EntityNotFoundException.byId(roleId.toString()); }
@GET @Path("/topologies/{topologyId}/testcases/{testCaseId}/sources") public Response listTestRunCaseSource(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @Context SecurityContext securityContext) { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); Collection<TopologyTestRunCaseSource> sources = catalogService.listTopologyTestRunCaseSource(testCaseId); if (sources == null) { throw EntityNotFoundException.byFilter("topologyId: " + topologyId + " / testCaseId: " + testCaseId); } return WSUtils.respondEntities(sources, OK); }
@GET @Path("/topologies/{topologyId}/testcases/{testCaseId}/sinks") public Response listTestRunCaseSink(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @Context SecurityContext securityContext) { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); Collection<TopologyTestRunCaseSink> sinks = catalogService.listTopologyTestRunCaseSink(testCaseId); if (sinks == null) { throw EntityNotFoundException.byFilter("topologyId: " + topologyId + " / testCaseId: " + testCaseId); } return WSUtils.respondEntities(sinks, OK); }
@GET @Path("/{dashboardId}/datasources") @Timed public Response listDatasources(@PathParam("dashboardId") Long dashboardId, @Context UriInfo uriInfo) { List<QueryParam> queryParams = buildDashboardIdAwareQueryParams(dashboardId, uriInfo); Collection<Datasource> datasources = dashboardCatalogService.listDatasources(queryParams); if (datasources != null) { return WSUtils.respondEntities(datasources, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
private Response listTopologySources(List<QueryParam> queryParams, Long topologyId, SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); Collection<TopologySource> sources = catalogService.listTopologySources(queryParams); if (sources != null) { return WSUtils.respondEntities(sources, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
private Response listTopologyStreams(List<QueryParam> queryParams, Long topologyId, SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); Collection<TopologyStream> sources = catalogService.listStreamInfos(queryParams); if (sources != null) { return WSUtils.respondEntities(sources, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
private Response listTopologyRules(List<QueryParam> queryParams, Long topologyId, SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); Collection<TopologyRule> topologyRules = catalogService.listRules(queryParams); if (topologyRules != null) { return WSUtils.respondEntities(topologyRules, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
private Response listTopologyProcessors(List<QueryParam> queryParams, Long topologyId, SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); Collection<TopologyProcessor> sources = catalogService.listTopologyProcessors(queryParams); if (sources != null) { return WSUtils.respondEntities(sources, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
private Response listTopologyEdges(List<QueryParam> queryParams, Long topologyId, SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); Collection<TopologyEdge> edges = catalogService.listTopologyEdges(queryParams); if (edges != null) { return WSUtils.respondEntities(edges, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
private Response listTopologyBranchRules(List<QueryParam> queryParams, Long topologyId, SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); Collection<TopologyBranchRule> topologyBranchRules = catalogService.listBranchRules(queryParams); if (topologyBranchRules != null) { return WSUtils.respondEntities(topologyBranchRules, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
private Response listTopologySinks(List<QueryParam> queryParams, Long topologyId, SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); Collection<TopologySink> sinks = catalogService.listTopologySinks(queryParams); if (sinks != null) { return WSUtils.respondEntities(sinks, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
private Response listTopologyWindows(List<QueryParam> queryParams, Long topologyId, SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); Collection<TopologyWindow> topologyWindows = catalogService.listWindows(queryParams); if (topologyWindows != null) { return WSUtils.respondEntities(topologyWindows, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
private Response getEventsOfTestRunTopologyHistory(Long topologyId, Long historyId, String componentName, SecurityContext securityContext) throws IOException { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); File eventLogFile = getEventLogFile(topologyId, historyId); Stream<EventInformation> eventsStream = eventLogFileReader.loadEventLogFileAsStream(eventLogFile); if (!StringUtils.isEmpty(componentName)) { eventsStream = eventsStream.filter(event -> { String eventComponentName = event.getComponentName(); return eventComponentName != null && eventComponentName.equals(componentName); }); } return WSUtils.respondEntities(eventsStream.collect(toList()), OK); }
/** * List ALL configurations or the ones matching specific query params. */ @GET @Path("/services/{serviceId}/configurations") @Timed public Response listServiceConfigurations(@PathParam("serviceId") Long serviceId, @Context UriInfo uriInfo, @Context SecurityContext securityContext) { SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, getClusterId(serviceId), READ); List<QueryParam> queryParams = buildServiceIdAwareQueryParams(serviceId, uriInfo); Collection<ServiceConfiguration> configurations = environmentService.listServiceConfigurations(queryParams); if (configurations != null) { return WSUtils.respondEntities(configurations, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
@GET @Path("/files") @Timed public Response listFiles(@Context UriInfo uriInfo, @Context SecurityContext securityContext) { Collection<File> files = null; MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); if (params == null || params.isEmpty()) { files = catalogService.listFiles(); } else { files = catalogService.listFiles(WSUtils.buildQueryParameters(params)); } Collection<File> result = SecurityUtil.filter(authorizer, securityContext, File.NAMESPACE, files, READ); return WSUtils.respondEntities(result, OK); }