use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyCatalogResource method importTopology.
/**
* curl -X POST 'http://localhost:8080/api/v1/catalog/topologies/actions/import' -F file=@/tmp/topology.json -F namespaceId=1
*/
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/topologies/actions/import")
@Timed
public Response importTopology(@FormDataParam("file") final InputStream inputStream, @FormDataParam("namespaceId") final Long namespaceId, @FormDataParam("topologyName") final String topologyName, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_TOPOLOGY_ADMIN);
if (namespaceId == null) {
throw new IllegalArgumentException("Missing namespaceId");
}
TopologyData topologyData = new ObjectMapper().readValue(inputStream, TopologyData.class);
if (topologyName != null && !topologyName.isEmpty()) {
topologyData.setTopologyName(topologyName);
}
Topology importedTopology = catalogService.importTopology(namespaceId, topologyData);
return WSUtils.respondEntity(importedTopology, OK);
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyDashboardResource method getTopologyById.
@GET
@Path("/topologies/{topologyId}/dashboard")
@Timed
public Response getTopologyById(@PathParam("topologyId") Long topologyId, @javax.ws.rs.QueryParam("latencyTopN") Integer latencyTopN, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, NAMESPACE, topologyId, READ);
String asUser = WSUtils.getUserFromSecurityContext(securityContext);
Topology result = catalogService.getTopology(topologyId);
if (result != null) {
CatalogResourceUtil.TopologyDashboardResponse topologyDetailed = CatalogResourceUtil.enrichTopology(result, asUser, latencyTopN, environmentService, actionsService, metricsService, catalogService);
return WSUtils.respondEntity(topologyDetailed, OK);
}
throw EntityNotFoundException.byId(topologyId.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyDashboardResource method getTopologyByIdAndVersion.
@GET
@Path("/topologies/{topologyId}/versions/{versionId}/dashboard")
@Timed
public Response getTopologyByIdAndVersion(@PathParam("topologyId") Long topologyId, @PathParam("versionId") Long versionId, @javax.ws.rs.QueryParam("latencyTopN") Integer latencyTopN, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, NAMESPACE, topologyId, READ);
String asUser = WSUtils.getUserFromSecurityContext(securityContext);
Topology result = catalogService.getTopology(topologyId, versionId);
if (result != null) {
CatalogResourceUtil.TopologyDashboardResponse topologyDetailed = CatalogResourceUtil.enrichTopology(result, asUser, latencyTopN, environmentService, actionsService, metricsService, catalogService);
return WSUtils.respondEntity(topologyDetailed, OK);
}
throw EntityNotFoundException.byId(topologyId.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyTestHelper method createTopology.
public static Topology createTopology(Long id, Long versionId, Long namespaceId) {
Topology topology = new Topology();
topology.setId(id);
topology.setName("testTopology_" + id);
topology.setNamespaceId(namespaceId);
topology.setVersionId(versionId);
topology.setVersionTimestamp(System.currentTimeMillis());
return topology;
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class StreamCatalogServiceTest method createTopology.
private Topology createTopology(String name) {
Topology topology = new Topology();
topology.setName(name);
return topology;
}
Aggregations