jsferner commented on a change in pull request #4023: NIFI-6873: Added support 
for replacing a process group via import
URL: https://github.com/apache/nifi/pull/4023#discussion_r375827914
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java
 ##########
 @@ -3894,6 +3889,252 @@ public Response createControllerService(
         );
     }
 
+    /**
+     * Initiates the request to replace the Process Group with the given ID 
with the Process Group in the given import entity
+     *
+     * @param groupId          The id of the process group to replace
+     * @param importEntity     A request entity containing revision info and 
the process group to replace with
+     * @return A ProcessGroupReplaceRequestEntity.
+     */
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    @Path("{id}/replace-requests")
+    @ApiOperation(
+            value = "Initiate the Replace Request of a Process Group with the 
given ID",
+            response = ProcessGroupReplaceRequestEntity.class,
+            notes = "This will initiate the action of replacing a process 
group with the given process group. This can be a lengthy "
+                    + "process, as it will stop any Processors and disable any 
Controller Services necessary to perform the action and then restart them. As a 
result, "
+                    + "the endpoint will immediately return a 
ProcessGroupReplaceRequestEntity, and the process of replacing the flow will 
occur "
+                    + "asynchronously in the background. The client may then 
periodically poll the status of the request by issuing a GET request to "
+                    + "/process-groups/replace-requests/{requestId}. Once the 
request is completed, the client is expected to issue a DELETE request to "
+                    + "/process-groups/replace-requests/{requestId}. " + 
NON_GUARANTEED_ENDPOINT,
+            authorizations = {
+                    @Authorization(value = "Read - /process-groups/{uuid}"),
+                    @Authorization(value = "Write - /process-groups/{uuid}"),
+                    @Authorization(value = "Read - /{component-type}/{uuid} - 
For all encapsulated components"),
+                    @Authorization(value = "Write - /{component-type}/{uuid} - 
For all encapsulated components"),
+                    @Authorization(value = "Write - if the template contains 
any restricted components - /restricted-components"),
+                    @Authorization(value = "Read - /parameter-contexts/{uuid} 
- For any Parameter Context that is referenced by a Property that is changed, 
added, or removed")
+            }
+    )
+    @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 initiateReplaceProcessGroup(@ApiParam(value = "The process 
group id.", required = true) @PathParam("id") final String groupId,
+                                                @ApiParam(value = "The process 
group replace request entity", required = true) final ProcessGroupImportEntity 
importEntity) {
+        // replacing a flow under version control is not permitted via import. 
Versioned flows have additional requirements to allow
+        // them only to be replaced by a different version of the same flow.
+        if (serviceFacade.isAnyProcessGroupUnderVersionControl(groupId)) {
+            throw new IllegalStateException("Cannot replace a Process Group 
via import while it or its descendants are under Version Control.");
+        }
+
+        final VersionedFlowSnapshot versionedFlowSnapshot = 
importEntity.getVersionedFlowSnapshot();
 
 Review comment:
   agreed

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to