use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class TopologySourceCatalogResource method getTopologySourceByIdAndVersion.
@GET
@Path("/topologies/{topologyId}/versions/{versionId}/sources/{id}")
@Timed
public Response getTopologySourceByIdAndVersion(@PathParam("topologyId") Long topologyId, @PathParam("id") Long sourceId, @PathParam("versionId") Long versionId, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
TopologySource source = catalogService.getTopologySource(topologyId, sourceId, versionId);
if (source != null) {
return WSUtils.respondEntity(source, OK);
}
throw EntityNotFoundException.byVersion(buildMessageForCompositeId(topologyId, sourceId), versionId.toString());
}
use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class TopologySourceCatalogResource method removeTopologySource.
/**
* <p>
* Removes a topology source.
* </p>
* <b>DELETE /api/v1/catalog/topologies/:TOPOLOGY_ID/sources/:SOURCE_ID</b>
* <pre>
* {
* "responseCode": 1000,
* "responseMessage": "Success",
* "entity": {
* "id": 1,
* "topologyId": 1,
* "name": "kafkaDataSource",
* "config": {
* "properties": {
* "zkUrl": "localhost:2181",
* "zkPath": "/brokers",
* "refreshFreqSecs": 60
* }
* },
* "type": "KAFKA",
* "outputStreams": [{stream1 data..}, {stream2 data..}]
* }
* }
* </pre>
*/
@DELETE
@Path("/topologies/{topologyId}/sources/{id}")
@Timed
public Response removeTopologySource(@PathParam("topologyId") Long topologyId, @PathParam("id") Long sourceId, @javax.ws.rs.QueryParam("removeEdges") boolean removeEdges, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
TopologySource topologySource = catalogService.removeTopologySource(topologyId, sourceId, removeEdges);
if (topologySource != null) {
return WSUtils.respondEntity(topologySource, OK);
}
throw EntityNotFoundException.byId(buildMessageForCompositeId(topologyId, sourceId));
}
use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class TopologyTestRunResource method addOrUpdateTestRunCaseSource.
@PUT
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sources/{id}")
public Response addOrUpdateTestRunCaseSource(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @PathParam("id") Long id, TopologyTestRunCaseSource testRunCaseSource, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE);
testRunCaseSource.setId(id);
testRunCaseSource.setTestCaseId(testCaseId);
TopologySource topologySource = getAssociatedTopologySource(topologyId, testCaseId, testRunCaseSource.getSourceId());
testRunCaseSource.setVersionId(topologySource.getVersionId());
TopologyTestRunCaseSource updatedCase = catalogService.addOrUpdateTopologyTestRunCaseSource(testRunCaseSource.getId(), testRunCaseSource);
return WSUtils.respondEntity(updatedCase, OK);
}
use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class TopologyTestRunResource method getAssociatedTopologySource.
private TopologySource getAssociatedTopologySource(Long topologyId, Long testCaseId, Long topologySourceId) {
TopologyTestRunCase testCase = catalogService.getTopologyTestRunCase(topologyId, testCaseId);
if (testCase == null) {
throw EntityNotFoundException.byId("Topology test case with topology id " + topologyId + " and test case id " + testCaseId);
}
TopologySource topologySource = catalogService.getTopologySource(topologyId, topologySourceId, testCase.getVersionId());
if (topologySource == null) {
throw EntityNotFoundException.byId("Topology source with topology id " + topologyId + " and version id " + testCase.getVersionId());
} else if (!testCase.getVersionId().equals(topologySource.getVersionId())) {
throw new IllegalStateException("Test case and topology source point to the different version id: " + "version id of test case: " + testCase.getVersionId() + " / " + "version id of topology source: " + topologySource.getVersionId());
}
return topologySource;
}
use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class TopologyTestRunResource method addTestRunCaseSource.
@POST
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sources")
public Response addTestRunCaseSource(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, TopologyTestRunCaseSource testRunCaseSource, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE);
TopologySource topologySource = getAssociatedTopologySource(topologyId, testCaseId, testRunCaseSource.getSourceId());
testRunCaseSource.setVersionId(topologySource.getVersionId());
TopologyTestRunCaseSource addedCaseSource = catalogService.addTopologyTestRunCaseSource(testRunCaseSource);
return WSUtils.respondEntity(addedCaseSource, CREATED);
}
Aggregations