use of com.hortonworks.streamline.streams.catalog.TopologyBranchRule in project streamline by hortonworks.
the class BranchRuleCatalogResource method getTopologyBranchRuleByIdAndVersion.
@GET
@Path("/topologies/{topologyId}/versions/{versionId}/branchrules/{id}")
@Timed
public Response getTopologyBranchRuleByIdAndVersion(@PathParam("topologyId") Long topologyId, @PathParam("id") Long ruleId, @PathParam("versionId") Long versionId, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
TopologyBranchRule topologyBranchRule = catalogService.getBranchRule(topologyId, ruleId, versionId);
if (topologyBranchRule != null) {
return WSUtils.respondEntity(topologyBranchRule, OK);
}
throw EntityNotFoundException.byVersion(buildMessageForCompositeId(topologyId, ruleId), versionId.toString());
}
use of com.hortonworks.streamline.streams.catalog.TopologyBranchRule in project streamline by hortonworks.
the class BranchRuleCatalogResource method addOrUpdateRule.
/**
* <p>Updates a topology branch rule.</p>
* <p>
* <b>PUT /api/v1/catalog/topologies/:TOPOLOGY_ID/branchrules/:RULE_ID</b>
* <pre>
* {
* "name": "rule1",
* "description": "rule test",
* "condition": "humidity > 90 AND celciusToFarenheit(temperature) > 80",
* "actions": ...
* }
* </pre>
* <i>Sample success response: </i>
* <pre>
* {
* "responseCode": 1000,
* "responseMessage": "Success",
* "entity": {
* "id": 1,
* "topologyId": 1,
* "name": "rule1",
* "description": "rule test",
* "condition": "humidity > 90 AND celciusToFarenheit(temperature) > 80",
* "actions": ...
* }
* }
* </pre>
*/
@PUT
@Path("/topologies/{topologyId}/branchrules/{id}")
@Timed
public Response addOrUpdateRule(@PathParam("topologyId") Long topologyId, @PathParam("id") Long ruleId, TopologyBranchRule brRuleInfo, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, Topology.NAMESPACE, topologyId, WRITE);
TopologyBranchRule createdRuleInfo = catalogService.addOrUpdateBranchRule(topologyId, ruleId, brRuleInfo);
return WSUtils.respondEntity(createdRuleInfo, CREATED);
}
Aggregations