use of org.apache.nifi.web.api.entity.ComponentEntity in project nifi by apache.
the class ProvenanceResource method deleteProvenance.
/**
* Deletes the provenance with the specified id.
*
* @param httpServletRequest request
* @param id The id of the provenance
* @param clusterNodeId The id of node in the cluster to search. This is optional and only relevant when clustered. If clustered and it is not specified the entire cluster is searched.
* @return A provenanceEntity
*/
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@ApiOperation(value = "Deletes a provenance query", response = ProvenanceEntity.class, authorizations = { @Authorization(value = "Read - /provenance") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response deleteProvenance(@Context final HttpServletRequest httpServletRequest, @ApiParam(value = "The id of the node where this query exists if clustered.", required = false) @QueryParam("clusterNodeId") final String clusterNodeId, @ApiParam(value = "The id of the provenance query.", required = true) @PathParam("id") final String id) {
// replicate if cluster manager
if (isReplicateRequest()) {
// determine where this request should be sent
if (clusterNodeId == null) {
// replicate to all nodes
return replicate(HttpMethod.DELETE);
} else {
return replicate(HttpMethod.DELETE, clusterNodeId);
}
}
final ComponentEntity requestEntity = new ComponentEntity();
requestEntity.setId(id);
return withWriteLock(serviceFacade, requestEntity, lookup -> authorizeProvenanceRequest(), null, (entity) -> {
// delete the provenance
serviceFacade.deleteProvenance(entity.getId());
// generate the response
return generateOkResponse(new ProvenanceEntity()).build();
});
}
use of org.apache.nifi.web.api.entity.ComponentEntity in project nifi by apache.
the class ProvenanceResource method deleteLineage.
/**
* Deletes the lineage with the specified id.
*
* @param httpServletRequest request
* @param clusterNodeId The id of node in the cluster that the event/flowfile originated from. This is only required when clustered.
* @param id The id of the lineage
* @return A lineageEntity
*/
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("lineage/{id}")
@ApiOperation(value = "Deletes a lineage query", response = LineageEntity.class, authorizations = { @Authorization(value = "Read - /provenance") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response deleteLineage(@Context final HttpServletRequest httpServletRequest, @ApiParam(value = "The id of the node where this query exists if clustered.", required = false) @QueryParam("clusterNodeId") final String clusterNodeId, @ApiParam(value = "The id of the lineage query.", required = true) @PathParam("id") final String id) {
// replicate if cluster manager
if (isReplicateRequest()) {
return replicate(HttpMethod.DELETE, clusterNodeId);
}
final ComponentEntity requestEntity = new ComponentEntity();
requestEntity.setId(id);
return withWriteLock(serviceFacade, requestEntity, lookup -> authorizeProvenanceRequest(), null, (entity) -> {
// delete the lineage
serviceFacade.deleteLineage(entity.getId());
// generate the response
return generateOkResponse(new LineageEntity()).build();
});
}
use of org.apache.nifi.web.api.entity.ComponentEntity in project nifi by apache.
the class ComponentEntityMerger method merge.
/**
* Merges the ComponentEntity responses according to their {@link org.apache.nifi.web.api.dto.PermissionsDTO}s. Responsible for invoking
* {@link ComponentEntityMerger#mergeComponents(EntityType, Map)}.
*
* @param clientEntity the entity being returned to the client
* @param entityMap all node responses
*/
@SuppressWarnings("unchecked")
default void merge(final EntityType clientEntity, final Map<NodeIdentifier, EntityType> entityMap) {
for (final Map.Entry<NodeIdentifier, EntityType> entry : entityMap.entrySet()) {
final EntityType entity = entry.getValue();
PermissionsDtoMerger.mergePermissions(clientEntity.getPermissions(), entity.getPermissions());
}
if (clientEntity.getPermissions().getCanRead()) {
final Map<NodeIdentifier, List<BulletinEntity>> bulletinEntities = new HashMap<>();
for (final Map.Entry<NodeIdentifier, ? extends ComponentEntity> entry : entityMap.entrySet()) {
final NodeIdentifier nodeIdentifier = entry.getKey();
final ComponentEntity entity = entry.getValue();
// consider the bulletins if present and authorized
if (entity.getBulletins() != null) {
entity.getBulletins().forEach(bulletin -> {
bulletinEntities.computeIfAbsent(nodeIdentifier, nodeId -> new ArrayList<>()).add(bulletin);
});
}
}
clientEntity.setBulletins(BulletinMerger.mergeBulletins(bulletinEntities, entityMap.size()));
// sort the results
Collections.sort(clientEntity.getBulletins(), BULLETIN_COMPARATOR);
// prune the response to only include the max number of bulletins
if (clientEntity.getBulletins().size() > MAX_BULLETINS_PER_COMPONENT) {
clientEntity.setBulletins(clientEntity.getBulletins().subList(0, MAX_BULLETINS_PER_COMPONENT));
}
mergeComponents(clientEntity, entityMap);
} else {
clientEntity.setBulletins(null);
// unchecked warning suppressed
clientEntity.setComponent(null);
}
}
use of org.apache.nifi.web.api.entity.ComponentEntity in project nifi by apache.
the class JerseyFlowClient method getSuggestedProcessGroupCoordinates.
@Override
public ProcessGroupBox getSuggestedProcessGroupCoordinates(final String parentId) throws NiFiClientException, IOException {
if (StringUtils.isBlank(parentId)) {
throw new IllegalArgumentException("Process group id cannot be null");
}
final ProcessGroupFlowEntity processGroup = getProcessGroup(parentId);
final ProcessGroupFlowDTO processGroupFlowDTO = processGroup.getProcessGroupFlow();
final FlowDTO flowDTO = processGroupFlowDTO.getFlow();
final List<ComponentEntity> pgComponents = new ArrayList<>();
pgComponents.addAll(flowDTO.getProcessGroups());
pgComponents.addAll(flowDTO.getProcessors());
pgComponents.addAll(flowDTO.getRemoteProcessGroups());
pgComponents.addAll(flowDTO.getConnections());
pgComponents.addAll(flowDTO.getFunnels());
pgComponents.addAll(flowDTO.getInputPorts());
pgComponents.addAll(flowDTO.getOutputPorts());
pgComponents.addAll(flowDTO.getLabels());
final Set<PositionDTO> positions = pgComponents.stream().map(ComponentEntity::getPosition).collect(Collectors.toSet());
if (positions.isEmpty()) {
return ProcessGroupBox.CANVAS_CENTER;
}
final List<ProcessGroupBox> coords = positions.stream().filter(Objects::nonNull).map(p -> new ProcessGroupBox(p.getX().intValue(), p.getY().intValue())).collect(Collectors.toList());
final ProcessGroupBox freeSpot = coords.get(0).findFreeSpace(coords);
return freeSpot;
}
use of org.apache.nifi.web.api.entity.ComponentEntity in project nifi by apache.
the class CountersResource method updateCounter.
/**
* Update the specified counter. This will reset the counter value to 0.
*
* @param httpServletRequest request
* @param id The id of the counter.
* @return A counterEntity.
*/
@PUT
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@ApiOperation(value = "Updates the specified counter. This will reset the counter value to 0", notes = NON_GUARANTEED_ENDPOINT, response = CounterEntity.class, authorizations = { @Authorization(value = "Write - /counters") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response updateCounter(@Context final HttpServletRequest httpServletRequest, @ApiParam(value = "The id of the counter.") @PathParam("id") final String id) {
if (isReplicateRequest()) {
return replicate(HttpMethod.PUT);
}
final ComponentEntity requestComponentEntity = new ComponentEntity();
requestComponentEntity.setId(id);
return withWriteLock(serviceFacade, requestComponentEntity, lookup -> {
authorizeCounters(RequestAction.WRITE);
}, null, (componentEntity) -> {
// reset the specified counter
final CounterDTO counter = serviceFacade.updateCounter(componentEntity.getId());
// create the response entity
final CounterEntity entity = new CounterEntity();
entity.setCounter(counter);
// generate the response
return generateOkResponse(entity).build();
});
}
Aggregations