Search in sources :

Example 1 with ResourceDTO

use of org.apache.nifi.web.api.dto.ResourceDTO in project nifi by apache.

the class ResourceResource method getResources.

/**
 * Gets the available resources that support access/authorization policies.
 *
 * @return A resourcesEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets the available resources that support access/authorization policies", response = ResourcesEntity.class, authorizations = { @Authorization(value = "Read - /resources") })
@ApiResponses(value = { @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request.") })
public Response getResources() {
    authorizeResource();
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }
    final List<ResourceDTO> resources = serviceFacade.getResources();
    // create the response
    final ResourcesEntity entity = new ResourcesEntity();
    entity.setResources(resources);
    // generate the response
    return generateOkResponse(entity).build();
}
Also used : ResourcesEntity(org.apache.nifi.web.api.entity.ResourcesEntity) ResourceDTO(org.apache.nifi.web.api.dto.ResourceDTO) 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)

Example 2 with ResourceDTO

use of org.apache.nifi.web.api.dto.ResourceDTO in project nifi by apache.

the class StandardNiFiServiceFacade method getResources.

@Override
public List<ResourceDTO> getResources() {
    final List<Resource> resources = controllerFacade.getResources();
    final List<ResourceDTO> resourceDtos = new ArrayList<>(resources.size());
    for (final Resource resource : resources) {
        resourceDtos.add(dtoFactory.createResourceDto(resource));
    }
    return resourceDtos;
}
Also used : EnforcePolicyPermissionsThroughBaseResource(org.apache.nifi.authorization.resource.EnforcePolicyPermissionsThroughBaseResource) Resource(org.apache.nifi.authorization.Resource) ArrayList(java.util.ArrayList) ResourceDTO(org.apache.nifi.web.api.dto.ResourceDTO)

Aggregations

ResourceDTO (org.apache.nifi.web.api.dto.ResourceDTO)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 ArrayList (java.util.ArrayList)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 Resource (org.apache.nifi.authorization.Resource)1 EnforcePolicyPermissionsThroughBaseResource (org.apache.nifi.authorization.resource.EnforcePolicyPermissionsThroughBaseResource)1 ResourcesEntity (org.apache.nifi.web.api.entity.ResourcesEntity)1