Search in sources :

Example 1 with ClusterEntity

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

the class ControllerResource method getCluster.

// -------
// cluster
// -------
/**
 * Gets the contents of this NiFi cluster. This includes all nodes and their status.
 *
 * @return A clusterEntity
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("cluster")
@ApiOperation(value = "Gets the contents of the cluster", notes = "Returns the contents of the cluster including all nodes and their status.", response = ClusterEntity.class, authorizations = { @Authorization(value = "Read - /controller") })
@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 = 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 getCluster() {
    authorizeController(RequestAction.READ);
    // ensure connected to the cluster
    if (!isConnectedToCluster()) {
        throw new IllegalClusterResourceRequestException("Only a node connected to a cluster can process the request.");
    }
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET, getClusterCoordinatorNode());
    }
    final ClusterDTO dto = serviceFacade.getCluster();
    // create entity
    final ClusterEntity entity = new ClusterEntity();
    entity.setCluster(dto);
    // generate the response
    return generateOkResponse(entity).build();
}
Also used : IllegalClusterResourceRequestException(org.apache.nifi.web.IllegalClusterResourceRequestException) ClusterDTO(org.apache.nifi.web.api.dto.ClusterDTO) ClusterEntity(org.apache.nifi.web.api.entity.ClusterEntity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 IllegalClusterResourceRequestException (org.apache.nifi.web.IllegalClusterResourceRequestException)1 ClusterDTO (org.apache.nifi.web.api.dto.ClusterDTO)1 ClusterEntity (org.apache.nifi.web.api.entity.ClusterEntity)1