From issues-return-91601-archive-asf-public=cust-asf.ponee.io@nifi.apache.org Thu Feb 6 13:56:48 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 9E92818064E for ; Thu, 6 Feb 2020 14:56:47 +0100 (CET) Received: (qmail 53418 invoked by uid 500); 6 Feb 2020 13:56:47 -0000 Mailing-List: contact issues-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list issues@nifi.apache.org Received: (qmail 53408 invoked by uid 99); 6 Feb 2020 13:56:47 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Feb 2020 13:56:47 +0000 From: GitBox To: issues@nifi.apache.org Subject: [GitHub] [nifi] jsferner commented on a change in pull request #4023: NIFI-6873: Added support for replacing a process group via import Message-ID: <158099740697.25286.14400677822033072624.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Thu, 06 Feb 2020 13:56:46 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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_r375847118 ########## 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(); + if (versionedFlowSnapshot == null) { + throw new IllegalArgumentException("Versioned Flow Snapshot must be supplied"); + } + + return initiateFlowUpdate(groupId, importEntity, true, "replace-requests", + "/nifi-api/process-groups/" + groupId + "/replace", importEntity::getVersionedFlowSnapshot); + } + + /** + * Replace the Process Group with the given ID with the specified Process Group. + * + * This is the endpoint used in a cluster update replication scenario. + * + * @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 ProcessGroupImportEntity. + */ + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("{id}/replace") Review comment: Done ---------------------------------------------------------------- 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: users@infra.apache.org With regards, Apache Git Services