Github user mcgilman commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2051#discussion_r131997934
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java
 ---
    @@ -325,6 +441,859 @@ public Response updateProcessGroup(
             );
         }
     
    +
    +    @GET
    +    @Consumes(MediaType.WILDCARD)
    +    @Produces(MediaType.APPLICATION_JSON)
    +    @Path("{groupId}/variable-registry/update-requests/{updateId}")
    +    @ApiOperation(value = "Gets a process group's variable registry", 
response = VariableRegistryUpdateRequestEntity.class, authorizations = {
    +        @Authorization(value = "Read - /process-groups/{uuid}", type = "")
    +    })
    +    @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 getVariableRegistryUpdateRequest(
    +        @ApiParam(value = "The process group id.", required = true) 
@PathParam("groupId") final String groupId,
    +        @ApiParam(value = "The ID of the Variable Registry Update 
Request", required = true) @PathParam("updateId") final String updateId) {
    +
    +        if (groupId == null || updateId == null) {
    +            throw new IllegalArgumentException("Group ID and Update ID 
must both be specified.");
    +        }
    +
    +        if (isReplicateRequest()) {
    +            return replicate(HttpMethod.GET);
    +        }
    +
    +        // authorize access
    +        serviceFacade.authorizeAccess(lookup -> {
    +            final Authorizable processGroup = 
lookup.getProcessGroup(groupId).getAuthorizable();
    +            processGroup.authorize(authorizer, RequestAction.READ, 
NiFiUserUtils.getNiFiUser());
    +        });
    +
    +        final VariableRegistryUpdateRequest request = 
varRegistryUpdateRequests.get(updateId);
    +        if (request == null) {
    +            throw new ResourceNotFoundException("Could not find a Variable 
Registry Update Request with identifier " + updateId);
    +        }
    +
    +        if (!groupId.equals(request.getProcessGroupId())) {
    +            throw new ResourceNotFoundException("Could not find a Variable 
Registry Update Request with identifier " + updateId + " for Process Group with 
identifier " + groupId);
    +        }
    +
    +        final VariableRegistryUpdateRequestEntity entity = new 
VariableRegistryUpdateRequestEntity();
    +        entity.setId(request.getRequestId());
    +        
entity.setRequestDto(dtoFactory.createVariableRegistryUpdateRequestDto(request));
    +        entity.setUri(generateResourceUri("process-groups", groupId, 
"variable-registry", updateId));
    +        return generateOkResponse(entity).build();
    +    }
    +
    +
    +    @DELETE
    +    @Consumes(MediaType.WILDCARD)
    +    @Produces(MediaType.APPLICATION_JSON)
    +    @Path("{groupId}/variable-registry/update-requests/{updateId}")
    +    @ApiOperation(value = "Deletes an update request for a process group's 
variable registry. If the request is not yet complete, it will automatically be 
cancelled.",
    +        response = VariableRegistryUpdateRequestEntity.class, 
authorizations = {
    +            @Authorization(value = "Read - /process-groups/{uuid}", type = 
"")
    +    })
    +    @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 deleteVariableRegistryUpdateRequest(
    +        @ApiParam(value = "The process group id.", required = true) 
@PathParam("groupId") final String groupId,
    +        @ApiParam(value = "The ID of the Variable Registry Update 
Request", required = true) @PathParam("updateId") final String updateId) {
    +
    +        if (groupId == null || updateId == null) {
    +            throw new IllegalArgumentException("Group ID and Update ID 
must both be specified.");
    +        }
    +
    +        if (isReplicateRequest()) {
    +            return replicate(HttpMethod.DELETE);
    +        }
    +
    +        // authorize access
    +        serviceFacade.authorizeAccess(lookup -> {
    +            final Authorizable processGroup = 
lookup.getProcessGroup(groupId).getAuthorizable();
    +            processGroup.authorize(authorizer, RequestAction.READ, 
NiFiUserUtils.getNiFiUser());
    +        });
    +
    +        final VariableRegistryUpdateRequest request = 
varRegistryUpdateRequests.remove(updateId);
    +        if (request == null) {
    +            throw new ResourceNotFoundException("Could not find a Variable 
Registry Update Request with identifier " + updateId);
    +        }
    +
    +        if (!groupId.equals(request.getProcessGroupId())) {
    +            throw new ResourceNotFoundException("Could not find a Variable 
Registry Update Request with identifier " + updateId + " for Process Group with 
identifier " + groupId);
    +        }
    +
    +        request.cancel();
    +
    +        final VariableRegistryUpdateRequestEntity entity = new 
VariableRegistryUpdateRequestEntity();
    --- End diff --
    
    Can we set the permissions on this entity for consistency with all of the 
other endpoints?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to