Search in sources :

Example 1 with RemoteProcessGroupPortEntity

use of org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity in project nifi by apache.

the class EntityFactory method createRemoteProcessGroupPortEntity.

public RemoteProcessGroupPortEntity createRemoteProcessGroupPortEntity(final RemoteProcessGroupPortDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
    final RemoteProcessGroupPortEntity entity = new RemoteProcessGroupPortEntity();
    entity.setRevision(revision);
    if (dto != null) {
        entity.setPermissions(permissions);
        entity.setId(dto.getId());
        if (permissions != null && permissions.getCanRead()) {
            entity.setRemoteProcessGroupPort(dto);
        }
    }
    return entity;
}
Also used : RemoteProcessGroupPortEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity)

Example 2 with RemoteProcessGroupPortEntity

use of org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity in project nifi by apache.

the class RemoteProcessGroupResource method updateRemoteProcessGroupInputPort.

/**
 * Updates the specified remote process group input port.
 *
 * @param httpServletRequest           request
 * @param id                           The id of the remote process group to update.
 * @param portId                       The id of the input port to update.
 * @param requestRemoteProcessGroupPortEntity The remoteProcessGroupPortEntity
 * @return A remoteProcessGroupPortEntity
 */
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/input-ports/{port-id}")
@ApiOperation(value = "Updates a remote port", notes = NON_GUARANTEED_ENDPOINT, response = RemoteProcessGroupPortEntity.class, authorizations = { @Authorization(value = "Write - /remote-process-groups/{uuid}") })
@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 updateRemoteProcessGroupInputPort(@Context final HttpServletRequest httpServletRequest, @ApiParam(value = "The remote process group id.", required = true) @PathParam("id") final String id, @ApiParam(value = "The remote process group port id.", required = true) @PathParam("port-id") final String portId, @ApiParam(value = "The remote process group port.", required = true) final RemoteProcessGroupPortEntity requestRemoteProcessGroupPortEntity) {
    if (requestRemoteProcessGroupPortEntity == null || requestRemoteProcessGroupPortEntity.getRemoteProcessGroupPort() == null) {
        throw new IllegalArgumentException("Remote process group port details must be specified.");
    }
    if (requestRemoteProcessGroupPortEntity.getRevision() == null) {
        throw new IllegalArgumentException("Revision must be specified.");
    }
    // ensure the ids are the same
    final RemoteProcessGroupPortDTO requestRemoteProcessGroupPort = requestRemoteProcessGroupPortEntity.getRemoteProcessGroupPort();
    if (!portId.equals(requestRemoteProcessGroupPort.getId())) {
        throw new IllegalArgumentException(String.format("The remote process group port id (%s) in the request body does not equal the " + "remote process group port id of the requested resource (%s).", requestRemoteProcessGroupPort.getId(), portId));
    }
    // ensure the group ids are the same
    if (!id.equals(requestRemoteProcessGroupPort.getGroupId())) {
        throw new IllegalArgumentException(String.format("The remote process group id (%s) in the request body does not equal the " + "remote process group id of the requested resource (%s).", requestRemoteProcessGroupPort.getGroupId(), id));
    }
    if (isReplicateRequest()) {
        return replicate(HttpMethod.PUT, requestRemoteProcessGroupPortEntity);
    }
    final Revision requestRevision = getRevision(requestRemoteProcessGroupPortEntity, id);
    return withWriteLock(serviceFacade, requestRemoteProcessGroupPortEntity, requestRevision, lookup -> {
        final Authorizable remoteProcessGroup = lookup.getRemoteProcessGroup(id);
        remoteProcessGroup.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
    }, () -> serviceFacade.verifyUpdateRemoteProcessGroupInputPort(id, requestRemoteProcessGroupPort), (revision, remoteProcessGroupPortEntity) -> {
        final RemoteProcessGroupPortDTO remoteProcessGroupPort = remoteProcessGroupPortEntity.getRemoteProcessGroupPort();
        // update the specified remote process group
        final RemoteProcessGroupPortEntity controllerResponse = serviceFacade.updateRemoteProcessGroupInputPort(revision, id, remoteProcessGroupPort);
        // get the updated revision
        final RevisionDTO updatedRevision = controllerResponse.getRevision();
        // build the response entity
        final RemoteProcessGroupPortEntity entity = new RemoteProcessGroupPortEntity();
        entity.setRevision(updatedRevision);
        entity.setRemoteProcessGroupPort(controllerResponse.getRemoteProcessGroupPort());
        return generateOkResponse(entity).build();
    });
}
Also used : Revision(org.apache.nifi.web.Revision) RemoteProcessGroupPortEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity) Authorizable(org.apache.nifi.authorization.resource.Authorizable) RemoteProcessGroupPortDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 3 with RemoteProcessGroupPortEntity

use of org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity in project nifi by apache.

the class RemoteProcessGroupResource method updateRemoteProcessGroupOutputPort.

/**
 * Updates the specified remote process group output port.
 *
 * @param httpServletRequest           request
 * @param id                           The id of the remote process group to update.
 * @param portId                       The id of the output port to update.
 * @param requestRemoteProcessGroupPortEntity The remoteProcessGroupPortEntity
 * @return A remoteProcessGroupPortEntity
 */
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/output-ports/{port-id}")
@ApiOperation(value = "Updates a remote port", notes = NON_GUARANTEED_ENDPOINT, response = RemoteProcessGroupPortEntity.class, authorizations = { @Authorization(value = "Write - /remote-process-groups/{uuid}") })
@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 updateRemoteProcessGroupOutputPort(@Context HttpServletRequest httpServletRequest, @ApiParam(value = "The remote process group id.", required = true) @PathParam("id") String id, @ApiParam(value = "The remote process group port id.", required = true) @PathParam("port-id") String portId, @ApiParam(value = "The remote process group port.", required = true) RemoteProcessGroupPortEntity requestRemoteProcessGroupPortEntity) {
    if (requestRemoteProcessGroupPortEntity == null || requestRemoteProcessGroupPortEntity.getRemoteProcessGroupPort() == null) {
        throw new IllegalArgumentException("Remote process group port details must be specified.");
    }
    if (requestRemoteProcessGroupPortEntity.getRevision() == null) {
        throw new IllegalArgumentException("Revision must be specified.");
    }
    // ensure the ids are the same
    final RemoteProcessGroupPortDTO requestRemoteProcessGroupPort = requestRemoteProcessGroupPortEntity.getRemoteProcessGroupPort();
    if (!portId.equals(requestRemoteProcessGroupPort.getId())) {
        throw new IllegalArgumentException(String.format("The remote process group port id (%s) in the request body does not equal the " + "remote process group port id of the requested resource (%s).", requestRemoteProcessGroupPort.getId(), portId));
    }
    // ensure the group ids are the same
    if (!id.equals(requestRemoteProcessGroupPort.getGroupId())) {
        throw new IllegalArgumentException(String.format("The remote process group id (%s) in the request body does not equal the " + "remote process group id of the requested resource (%s).", requestRemoteProcessGroupPort.getGroupId(), id));
    }
    if (isReplicateRequest()) {
        return replicate(HttpMethod.PUT, requestRemoteProcessGroupPortEntity);
    }
    // handle expects request (usually from the cluster manager)
    final Revision requestRevision = getRevision(requestRemoteProcessGroupPortEntity, id);
    return withWriteLock(serviceFacade, requestRemoteProcessGroupPortEntity, requestRevision, lookup -> {
        final Authorizable remoteProcessGroup = lookup.getRemoteProcessGroup(id);
        remoteProcessGroup.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
    }, () -> serviceFacade.verifyUpdateRemoteProcessGroupOutputPort(id, requestRemoteProcessGroupPort), (revision, remoteProcessGroupPortEntity) -> {
        final RemoteProcessGroupPortDTO remoteProcessGroupPort = remoteProcessGroupPortEntity.getRemoteProcessGroupPort();
        // update the specified remote process group
        final RemoteProcessGroupPortEntity controllerResponse = serviceFacade.updateRemoteProcessGroupOutputPort(revision, id, remoteProcessGroupPort);
        // get the updated revision
        final RevisionDTO updatedRevision = controllerResponse.getRevision();
        // build the response entity
        RemoteProcessGroupPortEntity entity = new RemoteProcessGroupPortEntity();
        entity.setRevision(updatedRevision);
        entity.setRemoteProcessGroupPort(controllerResponse.getRemoteProcessGroupPort());
        return generateOkResponse(entity).build();
    });
}
Also used : Revision(org.apache.nifi.web.Revision) RemoteProcessGroupPortEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity) Authorizable(org.apache.nifi.authorization.resource.Authorizable) RemoteProcessGroupPortDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

RemoteProcessGroupPortEntity (org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 Consumes (javax.ws.rs.Consumes)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Authorizable (org.apache.nifi.authorization.resource.Authorizable)2 Revision (org.apache.nifi.web.Revision)2 RemoteProcessGroupPortDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)2 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)2