Search in sources :

Example 11 with TopologyBranchRule

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());
}
Also used : TopologyBranchRule(com.hortonworks.streamline.streams.catalog.TopologyBranchRule) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 12 with TopologyBranchRule

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);
}
Also used : TopologyBranchRule(com.hortonworks.streamline.streams.catalog.TopologyBranchRule) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) PUT(javax.ws.rs.PUT)

Aggregations

TopologyBranchRule (com.hortonworks.streamline.streams.catalog.TopologyBranchRule)12 Timed (com.codahale.metrics.annotation.Timed)5 TopologyRule (com.hortonworks.streamline.streams.catalog.TopologyRule)5 Path (javax.ws.rs.Path)5 TopologyWindow (com.hortonworks.streamline.streams.catalog.TopologyWindow)4 QueryParam (com.hortonworks.registries.common.QueryParam)3 StorableKey (com.hortonworks.registries.storage.StorableKey)3 WSUtils.buildEdgesFromQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam)3 WSUtils.buildEdgesToQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)3 WSUtils.currentVersionQueryParam (com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam)3 WSUtils.versionIdQueryParam (com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam)3 BaseTopologyRule (com.hortonworks.streamline.streams.catalog.BaseTopologyRule)3 Rule (com.hortonworks.streamline.streams.layout.component.rule.Rule)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 TopologyEdge (com.hortonworks.streamline.streams.catalog.TopologyEdge)2 TopologyProcessor (com.hortonworks.streamline.streams.catalog.TopologyProcessor)2 TopologySink (com.hortonworks.streamline.streams.catalog.TopologySink)2 TopologySource (com.hortonworks.streamline.streams.catalog.TopologySource)2 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)2 TopologyTestRunCaseSink (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink)2