You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ex...@apache.org on 2024/10/28 20:20:54 UTC
(nifi) branch main updated: NIFI-13868 Added pg-delete command to NiFi Toolkit CLI (#9388)
This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 90d3b9da31 NIFI-13868 Added pg-delete command to NiFi Toolkit CLI (#9388)
90d3b9da31 is described below
commit 90d3b9da318b32e513451e1c5fa9352294f4105c
Author: Greg Solovyev <gr...@users.noreply.github.com>
AuthorDate: Mon Oct 28 13:20:49 2024 -0700
NIFI-13868 Added pg-delete command to NiFi Toolkit CLI (#9388)
Signed-off-by: David Handermann <ex...@apache.org>
---
nifi-docs/src/main/asciidoc/toolkit-guide.adoc | 24 ++++----
.../cli/impl/command/nifi/NiFiCommandGroup.java | 2 +
.../toolkit/cli/impl/command/nifi/pg/PGDelete.java | 65 ++++++++++++++++++++++
3 files changed, 80 insertions(+), 11 deletions(-)
diff --git a/nifi-docs/src/main/asciidoc/toolkit-guide.adoc b/nifi-docs/src/main/asciidoc/toolkit-guide.adoc
index 5aa3721a9d..fffb5b8ba4 100644
--- a/nifi-docs/src/main/asciidoc/toolkit-guide.adoc
+++ b/nifi-docs/src/main/asciidoc/toolkit-guide.adoc
@@ -91,6 +91,7 @@ The following are available commands:
nifi pg-set-param-context
nifi pg-replace
nifi pg-export
+ nifi pg-delete
nifi get-services
nifi get-service
nifi create-service
@@ -312,18 +313,19 @@ For example, typing tab at an empty prompt should display possible commands for
Typing "nifi " and then a tab will show the sub-commands for NiFi:
#> nifi
- change-version-processor delete-flow-analysis-rule export-reporting-task get-policy list-user-groups pg-export pg-stop-version-control
- cluster-summary delete-node export-reporting-tasks get-reg-client-id list-users pg-get-all-versions remove-inherited-param-contexts
+ change-version-processor delete-flow-analysis-rule export-reporting-task get-policy list-user-groups pg-export pg-delete
+ cluster-summary delete-node export-reporting-tasks get-reg-client-id list-users pg-get-all-versions pg-stop-version-control
connect-node delete-param fetch-params get-reporting-task logout-access-token pg-get-param-context set-inherited-param-contexts
- create-flow-analysis-rule delete-param-context get-access-token get-reporting-tasks merge-param-context pg-get-services set-param
- create-param-context delete-param-provider get-access-token-spnego get-root-id offload-node pg-get-version set-param-provider-property
- create-param-provider delete-reporting-task get-controller-configuration get-service pg-change-all-versions pg-import start-reporting-tasks
- create-reg-client disable-flow-analysis-rules get-flow-analysis-rule get-services pg-change-version pg-list stop-reporting-tasks
- create-reporting-task disable-services get-flow-analysis-rules import-param-context pg-connect pg-replace update-controller-configuration
- create-service disconnect-node get-node import-reporting-tasks pg-create pg-set-param-context update-policy
- create-user enable-flow-analysis-rules get-nodes list-param-contexts pg-create-service pg-start update-reg-client
- create-user-group enable-services get-param-context list-param-providers pg-disable-services pg-status update-user-group
- current-user export-param-context get-param-provider list-reg-clients pg-enable-services pg-stop
+ create-flow-analysis-rule delete-param-context get-access-token get-reporting-tasks merge-param-context pg-get-services remove-inherited-param-contexts
+ create-param-context delete-param-provider get-access-token-spnego get-root-id offload-node pg-get-version set-param
+ create-param-provider delete-reporting-task get-controller-configuration get-service pg-change-all-versions pg-import set-param-provider-property
+ create-reg-client disable-flow-analysis-rules get-flow-analysis-rule get-services pg-change-version pg-list start-reporting-tasks
+ create-reporting-task disable-services get-flow-analysis-rules import-param-context pg-connect pg-replace stop-reporting-tasks
+ create-service disconnect-node get-node import-reporting-tasks pg-create pg-set-param-context update-controller-configuration
+ create-user enable-flow-analysis-rules get-nodes list-param-contexts pg-create-service pg-start update-policy
+ create-user-group enable-services get-param-context list-param-providers pg-disable-services pg-status update-reg-client
+ current-user export-param-context get-param-provider list-reg-clients pg-enable-services pg-stop update-user-group
+
Arguments that represent a path to a file, such as `-p` or when setting a properties file in the session, will auto-complete the path being typed:
diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/NiFiCommandGroup.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/NiFiCommandGroup.java
index d3b6092918..2e958d4ce2 100644
--- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/NiFiCommandGroup.java
+++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/NiFiCommandGroup.java
@@ -84,6 +84,7 @@ import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGChangeVersion;
import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGConnect;
import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGCreate;
import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGCreateControllerService;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGDelete;
import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGDisableControllerServices;
import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGEmptyQueues;
import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGEnableControllerServices;
@@ -165,6 +166,7 @@ public class NiFiCommandGroup extends AbstractCommandGroup {
commands.add(new PGReplace());
commands.add(new PGExport());
commands.add(new PGEmptyQueues());
+ commands.add(new PGDelete());
commands.add(new GetControllerServices());
commands.add(new GetControllerService());
commands.add(new CreateControllerService());
diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGDelete.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGDelete.java
new file mode 100644
index 0000000000..787ecc537b
--- /dev/null
+++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGDelete.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.toolkit.cli.impl.command.nifi.pg;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.nifi.toolkit.cli.api.Context;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClient;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.ProcessGroupClient;
+import org.apache.nifi.toolkit.cli.impl.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand;
+import org.apache.nifi.toolkit.cli.impl.result.StringResult;
+import org.apache.nifi.web.api.entity.ProcessGroupEntity;
+
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Command to delete a process group.
+ */
+public class PGDelete extends AbstractNiFiCommand<StringResult> {
+
+ public PGDelete() {
+ super("pg-delete", StringResult.class);
+ }
+
+ @Override
+ public String getDescription() {
+ return "Deletes the given process group. Deleting a process group requires, stopping all Processors, disabling all Controller Services, and emptying all Queues.";
+ }
+
+ @Override
+ protected void doInitialize(final Context context) {
+ addOption(CommandOption.PG_ID.createOption());
+ }
+
+ @Override
+ public StringResult doExecute(final NiFiClient client, final Properties properties)
+ throws NiFiClientException, IOException, MissingOptionException {
+
+ final String pgId = getRequiredArg(properties, CommandOption.PG_ID);
+
+ final ProcessGroupClient pgClient = client.getProcessGroupClient();
+ final ProcessGroupEntity pgEntity = pgClient.getProcessGroup(pgId);
+ if (pgEntity == null) {
+ throw new NiFiClientException("Process group with id " + pgId + " not found.");
+ }
+ pgClient.deleteProcessGroup(pgEntity);
+ return new StringResult(pgId, isInteractive());
+ }
+}
\ No newline at end of file