You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "tpalfy (via GitHub)" <gi...@apache.org> on 2024/06/11 15:44:02 UTC

[PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

tpalfy opened a new pull request, #8954:
URL: https://github.com/apache/nifi/pull/8954

   <!-- 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. -->
   
   # Summary
   
   [NIFI-13388](https://issues.apache.org/jira/browse/NIFI-13388)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [ ] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [ ] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [ ] Pull Request based on current revision of the `main` branch
   - [ ] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [ ] Build completed using `mvn clean install -P contrib-check`
     - [ ] JDK 21
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip commented on code in PR #8954:
URL: https://github.com/apache/nifi/pull/8954#discussion_r1636738794


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/flow/DisableFlowAnalysisRules.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.flow;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.toolkit.cli.api.CommandException;
+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.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiActivateCommand;
+import org.apache.nifi.toolkit.cli.impl.result.VoidResult;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleEntity;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleRunStatusEntity;
+import org.apache.nifi.web.api.entity.FlowAnalysisRulesEntity;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Command for enabling flow analysis rule.

Review Comment:
   ```suggestion
    * Command for disabling flow analysis rule.
   ```



##########
nifi-system-tests/nifi-system-test-suite/src/test/resources/conf/default/bootstrap.conf:
##########
@@ -27,7 +27,7 @@ java.arg.3=-Xmx512m
 
 java.arg.14=-Djava.awt.headless=true
 
-#java.arg.debug=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8002
+java.arg.debug=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8002

Review Comment:
   This may be added unintentionally.



##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/flow/DeleteFlowAnalysisRule.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.flow;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.nifi.toolkit.cli.api.CommandException;
+import org.apache.nifi.toolkit.cli.api.Context;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.ControllerClient;
+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.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand;
+import org.apache.nifi.toolkit.cli.impl.result.nifi.FlowAnalysisRuleResult;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleEntity;
+
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Command for creating a flow analysis rule.

Review Comment:
   ```suggestion
    * Command for deleting a flow analysis rule.
   ```



##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ControllerClient.java:
##########
@@ -61,6 +66,26 @@ public interface ControllerClient {
     VersionedReportingTaskImportResponseEntity importReportingTasks(VersionedReportingTaskImportRequestEntity importRequestEntity)
             throws NiFiClientException, IOException;
 
+    FlowAnalysisRulesEntity getFlowAnalysisRules() throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity getFlowAnalysisRule(final String id) throws NiFiClientException, IOException;
+
+    PropertyDescriptorEntity getFlowAnalysisRulePropertyDescriptor(final String componentId, final String propertyName, final Boolean sensitive) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity createFlowAnalysisRule(FlowAnalysisRuleEntity reportingTask) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity updateFlowAnalysisRule(final FlowAnalysisRuleEntity flowAnalysisRuleEntity) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity activateFlowAnalysisRule(final String id, final FlowAnalysisRuleRunStatusEntity runStatusEntity) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity deleteFlowAnalysisRule(final FlowAnalysisRuleEntity flowAnalysisRule) throws NiFiClientException, IOException;
+
+    VerifyConfigRequestEntity submitFlowAnalysisRuleConfigVerificationRequest(final VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException;
+
+    VerifyConfigRequestEntity getFlowAnalysisRuleConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException;
+
+    VerifyConfigRequestEntity deleteFlowAnalysisRuleConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException;

Review Comment:
   What is the purpose of these methods? They seemed to be unused.



##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ControllerClient.java:
##########
@@ -61,6 +66,26 @@ public interface ControllerClient {
     VersionedReportingTaskImportResponseEntity importReportingTasks(VersionedReportingTaskImportRequestEntity importRequestEntity)
             throws NiFiClientException, IOException;
 
+    FlowAnalysisRulesEntity getFlowAnalysisRules() throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity getFlowAnalysisRule(final String id) throws NiFiClientException, IOException;
+
+    PropertyDescriptorEntity getFlowAnalysisRulePropertyDescriptor(final String componentId, final String propertyName, final Boolean sensitive) throws NiFiClientException, IOException;

Review Comment:
   This method is called from a test only.



##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/flow/EnableFlowAnalysisRules.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.flow;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.toolkit.cli.api.CommandException;
+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.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiActivateCommand;
+import org.apache.nifi.toolkit.cli.impl.result.VoidResult;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleEntity;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleRunStatusEntity;
+import org.apache.nifi.web.api.entity.FlowAnalysisRulesEntity;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Command for enabling flow analysis rule.
+ */
+public class EnableFlowAnalysisRules extends AbstractNiFiActivateCommand<FlowAnalysisRuleEntity,
+        FlowAnalysisRuleRunStatusEntity> {
+
+    public EnableFlowAnalysisRules() {
+        super("enable-flow-analysis-rules");
+    }
+
+    @Override
+    public String getDescription() {
+        return "Attempts to enable all flow analysis rules. In stand-alone mode this command " +

Review Comment:
   The command can also be used for enabling a single rule by id (not only all rules).



##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/flow/GetFlowAnalysisRule.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.flow;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.nifi.toolkit.cli.api.CommandException;
+import org.apache.nifi.toolkit.cli.api.Context;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.ControllerClient;
+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.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand;
+import org.apache.nifi.toolkit.cli.impl.result.nifi.FlowAnalysisRuleResult;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleEntity;
+
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Command for retrieving the status of a flow analysis rule.
+ */
+public class GetFlowAnalysisRule extends AbstractNiFiCommand<FlowAnalysisRuleResult> {
+
+    public GetFlowAnalysisRule() {
+        super("get-flow-analysis-rule", FlowAnalysisRuleResult.class);
+    }
+
+    @Override
+    public String getDescription() {
+        return "Retrieves the status for a flow analysis rule.";

Review Comment:
   Not sure what _status_ means here. The command prints more info than `GetFlowAnalysisRules` and _status_ is not mentioned there.
   ```suggestion
           return "Retrieves a flow analysis rule.";
   ```



##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/flow/GetFlowAnalysisRule.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.flow;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.nifi.toolkit.cli.api.CommandException;
+import org.apache.nifi.toolkit.cli.api.Context;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.ControllerClient;
+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.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand;
+import org.apache.nifi.toolkit.cli.impl.result.nifi.FlowAnalysisRuleResult;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleEntity;
+
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Command for retrieving the status of a flow analysis rule.
+ */
+public class GetFlowAnalysisRule extends AbstractNiFiCommand<FlowAnalysisRuleResult> {

Review Comment:
   ```suggestion
   /**
    * Command for retrieving a flow analysis rule.
    */
   public class GetFlowAnalysisRule extends AbstractNiFiCommand<FlowAnalysisRuleResult> {
   ```



##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/flow/DisableFlowAnalysisRules.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.flow;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.toolkit.cli.api.CommandException;
+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.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiActivateCommand;
+import org.apache.nifi.toolkit.cli.impl.result.VoidResult;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleEntity;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleRunStatusEntity;
+import org.apache.nifi.web.api.entity.FlowAnalysisRulesEntity;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Command for enabling flow analysis rule.
+ */
+public class DisableFlowAnalysisRules extends AbstractNiFiActivateCommand<FlowAnalysisRuleEntity,
+        FlowAnalysisRuleRunStatusEntity> {
+
+    public DisableFlowAnalysisRules() {
+        super("disable-flow-analysis-rules");
+    }
+
+    @Override
+    public String getDescription() {
+        return "Attempts to disable all flow analysis rules. In stand-alone mode this command " +

Review Comment:
   The command can also be used for disabling a single rule by id (not only all rules).



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip commented on code in PR #8954:
URL: https://github.com/apache/nifi/pull/8954#discussion_r1640035334


##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java:
##########
@@ -395,6 +399,153 @@ public void deleteReportingTasks() throws NiFiClientException, IOException {
         }
     }
 
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type) throws NiFiClientException, IOException {
+        return createFlowAnalysisRule(NiFiSystemIT.TEST_FLOW_ANALYSIS_RULE_PACKAGE + "." + type, getTestBundle());
+    }
+
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type, final BundleDTO bundle) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO dto = new FlowAnalysisRuleDTO();
+        dto.setBundle(bundle);
+        dto.setType(type);
+
+        final FlowAnalysisRuleEntity entity = new FlowAnalysisRuleEntity();
+        entity.setComponent(dto);
+        entity.setRevision(createNewRevision());
+        entity.setDisconnectedNodeAcknowledged(true);
+
+        final FlowAnalysisRuleEntity rlowAnalysisRule = nifiClient.getControllerClient().createFlowAnalysisRule(entity);
+        logger.info("Created Flow Analysis Rule [type={}, id={}] for Test [{}]", simpleName(type), rlowAnalysisRule.getId(), testName);
+
+        return rlowAnalysisRule;
+    }
+
+    public FlowAnalysisRuleEntity updateFlowAnalysisRuleProperties(final FlowAnalysisRuleEntity currentEntity, final Map<String, String> properties) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO taskDto = new FlowAnalysisRuleDTO();

Review Comment:
   Copy-paste error:
   ```suggestion
           final FlowAnalysisRuleDTO ruleDto = new FlowAnalysisRuleDTO();
   ```



##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java:
##########
@@ -395,6 +399,153 @@ public void deleteReportingTasks() throws NiFiClientException, IOException {
         }
     }
 
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type) throws NiFiClientException, IOException {
+        return createFlowAnalysisRule(NiFiSystemIT.TEST_FLOW_ANALYSIS_RULE_PACKAGE + "." + type, getTestBundle());
+    }
+
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type, final BundleDTO bundle) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO dto = new FlowAnalysisRuleDTO();
+        dto.setBundle(bundle);
+        dto.setType(type);
+
+        final FlowAnalysisRuleEntity entity = new FlowAnalysisRuleEntity();
+        entity.setComponent(dto);
+        entity.setRevision(createNewRevision());
+        entity.setDisconnectedNodeAcknowledged(true);
+
+        final FlowAnalysisRuleEntity rlowAnalysisRule = nifiClient.getControllerClient().createFlowAnalysisRule(entity);
+        logger.info("Created Flow Analysis Rule [type={}, id={}] for Test [{}]", simpleName(type), rlowAnalysisRule.getId(), testName);
+
+        return rlowAnalysisRule;
+    }
+
+    public FlowAnalysisRuleEntity updateFlowAnalysisRuleProperties(final FlowAnalysisRuleEntity currentEntity, final Map<String, String> properties) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO taskDto = new FlowAnalysisRuleDTO();
+        taskDto.setProperties(properties);
+        taskDto.setId(currentEntity.getId());
+
+        final FlowAnalysisRuleEntity updatedEntity = new FlowAnalysisRuleEntity();
+        updatedEntity.setRevision(currentEntity.getRevision());
+        updatedEntity.setComponent(taskDto);
+        updatedEntity.setId(currentEntity.getId());
+        updatedEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().updateFlowAnalysisRule(updatedEntity);
+
+    }
+
+    public FlowAnalysisRuleEntity enableFlowAnalysisRule(final FlowAnalysisRuleEntity entity) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleRunStatusEntity runStatusEntity = new FlowAnalysisRuleRunStatusEntity();
+        runStatusEntity.setState("ENABLED");
+        runStatusEntity.setRevision(entity.getRevision());
+        runStatusEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().activateFlowAnalysisRule(entity.getId(), runStatusEntity);
+    }
+
+    public FlowAnalysisRuleEntity disableFlowAnalysisRule(final FlowAnalysisRuleEntity entity) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleRunStatusEntity runStatusEntity = new FlowAnalysisRuleRunStatusEntity();
+        runStatusEntity.setState("DISABLED");
+        runStatusEntity.setRevision(entity.getRevision());
+        runStatusEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().activateFlowAnalysisRule(entity.getId(), runStatusEntity);
+    }
+
+    public void disableFlowAnalysisRues() throws NiFiClientException, IOException {
+        final FlowAnalysisRulesEntity rules = nifiClient.getControllerClient().getFlowAnalysisRules();
+
+        Collection<String> toBeDisabledRuleIds = new ArrayList<>();
+        for (final FlowAnalysisRuleEntity rule : rules.getFlowAnalysisRules()) {
+            disableFlowAnalysisRule(rule);
+            toBeDisabledRuleIds.add(rule.getId());
+        }
+
+        waitForFlowAnalysisRuleState("DISABLED", toBeDisabledRuleIds);
+    }
+
+    public void deleteFlowAnalysisRules() throws NiFiClientException, IOException {
+        final FlowAnalysisRulesEntity tasksEntity = nifiClient.getControllerClient().getFlowAnalysisRules();

Review Comment:
   Copy-paste error:
   ```suggestion
           final FlowAnalysisRulesEntity rulesEntity = nifiClient.getControllerClient().getFlowAnalysisRules();
   ```



##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java:
##########
@@ -395,6 +399,153 @@ public void deleteReportingTasks() throws NiFiClientException, IOException {
         }
     }
 
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type) throws NiFiClientException, IOException {
+        return createFlowAnalysisRule(NiFiSystemIT.TEST_FLOW_ANALYSIS_RULE_PACKAGE + "." + type, getTestBundle());
+    }
+
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type, final BundleDTO bundle) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO dto = new FlowAnalysisRuleDTO();
+        dto.setBundle(bundle);
+        dto.setType(type);
+
+        final FlowAnalysisRuleEntity entity = new FlowAnalysisRuleEntity();
+        entity.setComponent(dto);
+        entity.setRevision(createNewRevision());
+        entity.setDisconnectedNodeAcknowledged(true);
+
+        final FlowAnalysisRuleEntity rlowAnalysisRule = nifiClient.getControllerClient().createFlowAnalysisRule(entity);
+        logger.info("Created Flow Analysis Rule [type={}, id={}] for Test [{}]", simpleName(type), rlowAnalysisRule.getId(), testName);
+
+        return rlowAnalysisRule;
+    }
+
+    public FlowAnalysisRuleEntity updateFlowAnalysisRuleProperties(final FlowAnalysisRuleEntity currentEntity, final Map<String, String> properties) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO taskDto = new FlowAnalysisRuleDTO();
+        taskDto.setProperties(properties);
+        taskDto.setId(currentEntity.getId());
+
+        final FlowAnalysisRuleEntity updatedEntity = new FlowAnalysisRuleEntity();
+        updatedEntity.setRevision(currentEntity.getRevision());
+        updatedEntity.setComponent(taskDto);
+        updatedEntity.setId(currentEntity.getId());
+        updatedEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().updateFlowAnalysisRule(updatedEntity);
+
+    }
+
+    public FlowAnalysisRuleEntity enableFlowAnalysisRule(final FlowAnalysisRuleEntity entity) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleRunStatusEntity runStatusEntity = new FlowAnalysisRuleRunStatusEntity();
+        runStatusEntity.setState("ENABLED");
+        runStatusEntity.setRevision(entity.getRevision());
+        runStatusEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().activateFlowAnalysisRule(entity.getId(), runStatusEntity);
+    }
+
+    public FlowAnalysisRuleEntity disableFlowAnalysisRule(final FlowAnalysisRuleEntity entity) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleRunStatusEntity runStatusEntity = new FlowAnalysisRuleRunStatusEntity();
+        runStatusEntity.setState("DISABLED");
+        runStatusEntity.setRevision(entity.getRevision());
+        runStatusEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().activateFlowAnalysisRule(entity.getId(), runStatusEntity);
+    }
+
+    public void disableFlowAnalysisRues() throws NiFiClientException, IOException {
+        final FlowAnalysisRulesEntity rules = nifiClient.getControllerClient().getFlowAnalysisRules();
+
+        Collection<String> toBeDisabledRuleIds = new ArrayList<>();
+        for (final FlowAnalysisRuleEntity rule : rules.getFlowAnalysisRules()) {
+            disableFlowAnalysisRule(rule);
+            toBeDisabledRuleIds.add(rule.getId());
+        }
+
+        waitForFlowAnalysisRuleState("DISABLED", toBeDisabledRuleIds);
+    }
+
+    public void deleteFlowAnalysisRules() throws NiFiClientException, IOException {
+        final FlowAnalysisRulesEntity tasksEntity = nifiClient.getControllerClient().getFlowAnalysisRules();
+        for (final FlowAnalysisRuleEntity taskEntity : tasksEntity.getFlowAnalysisRules()) {
+            taskEntity.setDisconnectedNodeAcknowledged(true);
+            nifiClient.getControllerClient().deleteFlowAnalysisRule(taskEntity);
+        }
+    }
+
+    public void waitForFlowAnalysisRulesDisabled(final String... ruleIdsOfInterest) throws NiFiClientException, IOException {
+        waitForFlowAnalysisRuleState("DISABLED", Arrays.asList(ruleIdsOfInterest));
+    }
+
+    public void waitForFlowAnalysisRulesEnabled(final String... ruleIdsOfInterest) throws NiFiClientException, IOException {
+        waitForFlowAnalysisRuleState("ENABLED", Arrays.asList(ruleIdsOfInterest));
+    }
+
+    public void waitForFlowAnalysisRulesEnabled(final List<String> ruleIdsOfInterest) throws NiFiClientException, IOException {
+        waitForFlowAnalysisRuleState("ENABLED", ruleIdsOfInterest);
+    }
+
+    public void waitForFlowAnalysisRuleState(final String desiredState, final Collection<String> ruleIdsOfInterest) throws NiFiClientException, IOException {
+        final long maxTimestamp = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(2L);
+
+        while (System.currentTimeMillis() < maxTimestamp) {
+            final List<FlowAnalysisRuleEntity> nonDisabledRules = getFlowAnalysisRulesNotInState(desiredState, ruleIdsOfInterest);

Review Comment:
   ` nonDisabledRules` has a wrong name because `desiredState` can be `ENABLED` or `DISABLED`.
   Maybe `nonDesiredStateRules`?



##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java:
##########
@@ -395,6 +399,153 @@ public void deleteReportingTasks() throws NiFiClientException, IOException {
         }
     }
 
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type) throws NiFiClientException, IOException {
+        return createFlowAnalysisRule(NiFiSystemIT.TEST_FLOW_ANALYSIS_RULE_PACKAGE + "." + type, getTestBundle());
+    }
+
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type, final BundleDTO bundle) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO dto = new FlowAnalysisRuleDTO();
+        dto.setBundle(bundle);
+        dto.setType(type);
+
+        final FlowAnalysisRuleEntity entity = new FlowAnalysisRuleEntity();
+        entity.setComponent(dto);
+        entity.setRevision(createNewRevision());
+        entity.setDisconnectedNodeAcknowledged(true);
+
+        final FlowAnalysisRuleEntity rlowAnalysisRule = nifiClient.getControllerClient().createFlowAnalysisRule(entity);
+        logger.info("Created Flow Analysis Rule [type={}, id={}] for Test [{}]", simpleName(type), rlowAnalysisRule.getId(), testName);
+
+        return rlowAnalysisRule;
+    }
+
+    public FlowAnalysisRuleEntity updateFlowAnalysisRuleProperties(final FlowAnalysisRuleEntity currentEntity, final Map<String, String> properties) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO taskDto = new FlowAnalysisRuleDTO();
+        taskDto.setProperties(properties);
+        taskDto.setId(currentEntity.getId());
+
+        final FlowAnalysisRuleEntity updatedEntity = new FlowAnalysisRuleEntity();
+        updatedEntity.setRevision(currentEntity.getRevision());
+        updatedEntity.setComponent(taskDto);
+        updatedEntity.setId(currentEntity.getId());
+        updatedEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().updateFlowAnalysisRule(updatedEntity);
+
+    }
+
+    public FlowAnalysisRuleEntity enableFlowAnalysisRule(final FlowAnalysisRuleEntity entity) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleRunStatusEntity runStatusEntity = new FlowAnalysisRuleRunStatusEntity();
+        runStatusEntity.setState("ENABLED");
+        runStatusEntity.setRevision(entity.getRevision());
+        runStatusEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().activateFlowAnalysisRule(entity.getId(), runStatusEntity);
+    }
+
+    public FlowAnalysisRuleEntity disableFlowAnalysisRule(final FlowAnalysisRuleEntity entity) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleRunStatusEntity runStatusEntity = new FlowAnalysisRuleRunStatusEntity();
+        runStatusEntity.setState("DISABLED");
+        runStatusEntity.setRevision(entity.getRevision());
+        runStatusEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().activateFlowAnalysisRule(entity.getId(), runStatusEntity);
+    }
+
+    public void disableFlowAnalysisRues() throws NiFiClientException, IOException {
+        final FlowAnalysisRulesEntity rules = nifiClient.getControllerClient().getFlowAnalysisRules();
+
+        Collection<String> toBeDisabledRuleIds = new ArrayList<>();
+        for (final FlowAnalysisRuleEntity rule : rules.getFlowAnalysisRules()) {
+            disableFlowAnalysisRule(rule);
+            toBeDisabledRuleIds.add(rule.getId());
+        }
+
+        waitForFlowAnalysisRuleState("DISABLED", toBeDisabledRuleIds);
+    }
+
+    public void deleteFlowAnalysisRules() throws NiFiClientException, IOException {
+        final FlowAnalysisRulesEntity tasksEntity = nifiClient.getControllerClient().getFlowAnalysisRules();
+        for (final FlowAnalysisRuleEntity taskEntity : tasksEntity.getFlowAnalysisRules()) {
+            taskEntity.setDisconnectedNodeAcknowledged(true);
+            nifiClient.getControllerClient().deleteFlowAnalysisRule(taskEntity);
+        }
+    }
+
+    public void waitForFlowAnalysisRulesDisabled(final String... ruleIdsOfInterest) throws NiFiClientException, IOException {
+        waitForFlowAnalysisRuleState("DISABLED", Arrays.asList(ruleIdsOfInterest));
+    }
+
+    public void waitForFlowAnalysisRulesEnabled(final String... ruleIdsOfInterest) throws NiFiClientException, IOException {
+        waitForFlowAnalysisRuleState("ENABLED", Arrays.asList(ruleIdsOfInterest));
+    }
+
+    public void waitForFlowAnalysisRulesEnabled(final List<String> ruleIdsOfInterest) throws NiFiClientException, IOException {
+        waitForFlowAnalysisRuleState("ENABLED", ruleIdsOfInterest);
+    }

Review Comment:
   These methods seem to be unused.



##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java:
##########
@@ -395,6 +399,153 @@ public void deleteReportingTasks() throws NiFiClientException, IOException {
         }
     }
 
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type) throws NiFiClientException, IOException {
+        return createFlowAnalysisRule(NiFiSystemIT.TEST_FLOW_ANALYSIS_RULE_PACKAGE + "." + type, getTestBundle());
+    }
+
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type, final BundleDTO bundle) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO dto = new FlowAnalysisRuleDTO();
+        dto.setBundle(bundle);
+        dto.setType(type);
+
+        final FlowAnalysisRuleEntity entity = new FlowAnalysisRuleEntity();
+        entity.setComponent(dto);
+        entity.setRevision(createNewRevision());
+        entity.setDisconnectedNodeAcknowledged(true);
+
+        final FlowAnalysisRuleEntity rlowAnalysisRule = nifiClient.getControllerClient().createFlowAnalysisRule(entity);

Review Comment:
   Typo:
   ```suggestion
           final FlowAnalysisRuleEntity flowAnalysisRule = nifiClient.getControllerClient().createFlowAnalysisRule(entity);
   ```



##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java:
##########
@@ -395,6 +399,153 @@ public void deleteReportingTasks() throws NiFiClientException, IOException {
         }
     }
 
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type) throws NiFiClientException, IOException {
+        return createFlowAnalysisRule(NiFiSystemIT.TEST_FLOW_ANALYSIS_RULE_PACKAGE + "." + type, getTestBundle());
+    }
+
+    public FlowAnalysisRuleEntity createFlowAnalysisRule(final String type, final BundleDTO bundle) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO dto = new FlowAnalysisRuleDTO();
+        dto.setBundle(bundle);
+        dto.setType(type);
+
+        final FlowAnalysisRuleEntity entity = new FlowAnalysisRuleEntity();
+        entity.setComponent(dto);
+        entity.setRevision(createNewRevision());
+        entity.setDisconnectedNodeAcknowledged(true);
+
+        final FlowAnalysisRuleEntity rlowAnalysisRule = nifiClient.getControllerClient().createFlowAnalysisRule(entity);
+        logger.info("Created Flow Analysis Rule [type={}, id={}] for Test [{}]", simpleName(type), rlowAnalysisRule.getId(), testName);
+
+        return rlowAnalysisRule;
+    }
+
+    public FlowAnalysisRuleEntity updateFlowAnalysisRuleProperties(final FlowAnalysisRuleEntity currentEntity, final Map<String, String> properties) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleDTO taskDto = new FlowAnalysisRuleDTO();
+        taskDto.setProperties(properties);
+        taskDto.setId(currentEntity.getId());
+
+        final FlowAnalysisRuleEntity updatedEntity = new FlowAnalysisRuleEntity();
+        updatedEntity.setRevision(currentEntity.getRevision());
+        updatedEntity.setComponent(taskDto);
+        updatedEntity.setId(currentEntity.getId());
+        updatedEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().updateFlowAnalysisRule(updatedEntity);
+
+    }
+
+    public FlowAnalysisRuleEntity enableFlowAnalysisRule(final FlowAnalysisRuleEntity entity) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleRunStatusEntity runStatusEntity = new FlowAnalysisRuleRunStatusEntity();
+        runStatusEntity.setState("ENABLED");
+        runStatusEntity.setRevision(entity.getRevision());
+        runStatusEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().activateFlowAnalysisRule(entity.getId(), runStatusEntity);
+    }
+
+    public FlowAnalysisRuleEntity disableFlowAnalysisRule(final FlowAnalysisRuleEntity entity) throws NiFiClientException, IOException {
+        final FlowAnalysisRuleRunStatusEntity runStatusEntity = new FlowAnalysisRuleRunStatusEntity();
+        runStatusEntity.setState("DISABLED");
+        runStatusEntity.setRevision(entity.getRevision());
+        runStatusEntity.setDisconnectedNodeAcknowledged(true);
+
+        return nifiClient.getControllerClient().activateFlowAnalysisRule(entity.getId(), runStatusEntity);
+    }
+
+    public void disableFlowAnalysisRues() throws NiFiClientException, IOException {

Review Comment:
   Typo:
   ```suggestion
       public void disableFlowAnalysisRules() throws NiFiClientException, IOException {
   ```



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "tpalfy (via GitHub)" <gi...@apache.org>.
tpalfy commented on code in PR #8954:
URL: https://github.com/apache/nifi/pull/8954#discussion_r1639692620


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/flow/EnableFlowAnalysisRules.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.flow;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.toolkit.cli.api.CommandException;
+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.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiActivateCommand;
+import org.apache.nifi.toolkit.cli.impl.result.VoidResult;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleEntity;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleRunStatusEntity;
+import org.apache.nifi.web.api.entity.FlowAnalysisRulesEntity;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Command for enabling flow analysis rule.
+ */
+public class EnableFlowAnalysisRules extends AbstractNiFiActivateCommand<FlowAnalysisRuleEntity,
+        FlowAnalysisRuleRunStatusEntity> {
+
+    public EnableFlowAnalysisRules() {
+        super("enable-flow-analysis-rules");
+    }
+
+    @Override
+    public String getDescription() {
+        return "Attempts to enable all flow analysis rules. In stand-alone mode this command " +

Review Comment:
   Yeah, I can modify the description.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "tpalfy (via GitHub)" <gi...@apache.org>.
tpalfy commented on code in PR #8954:
URL: https://github.com/apache/nifi/pull/8954#discussion_r1639697746


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/flow/GetFlowAnalysisRule.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.flow;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.nifi.toolkit.cli.api.CommandException;
+import org.apache.nifi.toolkit.cli.api.Context;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.ControllerClient;
+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.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand;
+import org.apache.nifi.toolkit.cli.impl.result.nifi.FlowAnalysisRuleResult;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleEntity;
+
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Command for retrieving the status of a flow analysis rule.
+ */
+public class GetFlowAnalysisRule extends AbstractNiFiCommand<FlowAnalysisRuleResult> {

Review Comment:
   I guess it's a general way of saying "everything available" used for other components as well. I didn't want to deviate. But I can apply this suggestion.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "tpalfy (via GitHub)" <gi...@apache.org>.
tpalfy commented on code in PR #8954:
URL: https://github.com/apache/nifi/pull/8954#discussion_r1639693492


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/flow/DisableFlowAnalysisRules.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.flow;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.toolkit.cli.api.CommandException;
+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.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiActivateCommand;
+import org.apache.nifi.toolkit.cli.impl.result.VoidResult;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleEntity;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleRunStatusEntity;
+import org.apache.nifi.web.api.entity.FlowAnalysisRulesEntity;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Command for enabling flow analysis rule.
+ */
+public class DisableFlowAnalysisRules extends AbstractNiFiActivateCommand<FlowAnalysisRuleEntity,
+        FlowAnalysisRuleRunStatusEntity> {
+
+    public DisableFlowAnalysisRules() {
+        super("disable-flow-analysis-rules");
+    }
+
+    @Override
+    public String getDescription() {
+        return "Attempts to disable all flow analysis rules. In stand-alone mode this command " +

Review Comment:
   Yeah, I can modify the description.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "asfgit (via GitHub)" <gi...@apache.org>.
asfgit closed pull request #8954: NIFI-13388 Add NiFi Cli support for Flow Analysis Rules
URL: https://github.com/apache/nifi/pull/8954


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "tpalfy (via GitHub)" <gi...@apache.org>.
tpalfy commented on code in PR #8954:
URL: https://github.com/apache/nifi/pull/8954#discussion_r1639696479


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/flow/GetFlowAnalysisRule.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.flow;
+
+import org.apache.commons.cli.MissingOptionException;
+import org.apache.nifi.toolkit.cli.api.CommandException;
+import org.apache.nifi.toolkit.cli.api.Context;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.ControllerClient;
+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.command.CommandOption;
+import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand;
+import org.apache.nifi.toolkit.cli.impl.result.nifi.FlowAnalysisRuleResult;
+import org.apache.nifi.web.api.entity.FlowAnalysisRuleEntity;
+
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Command for retrieving the status of a flow analysis rule.
+ */
+public class GetFlowAnalysisRule extends AbstractNiFiCommand<FlowAnalysisRuleResult> {
+
+    public GetFlowAnalysisRule() {
+        super("get-flow-analysis-rule", FlowAnalysisRuleResult.class);
+    }
+
+    @Override
+    public String getDescription() {
+        return "Retrieves the status for a flow analysis rule.";

Review Comment:
   I guess it's a general way of saying "everything available" used for other components as well. I didn't want to deviate. But I can apply this suggestion.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "tpalfy (via GitHub)" <gi...@apache.org>.
tpalfy commented on code in PR #8954:
URL: https://github.com/apache/nifi/pull/8954#discussion_r1639688086


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ControllerClient.java:
##########
@@ -61,6 +66,26 @@ public interface ControllerClient {
     VersionedReportingTaskImportResponseEntity importReportingTasks(VersionedReportingTaskImportRequestEntity importRequestEntity)
             throws NiFiClientException, IOException;
 
+    FlowAnalysisRulesEntity getFlowAnalysisRules() throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity getFlowAnalysisRule(final String id) throws NiFiClientException, IOException;
+
+    PropertyDescriptorEntity getFlowAnalysisRulePropertyDescriptor(final String componentId, final String propertyName, final Boolean sensitive) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity createFlowAnalysisRule(FlowAnalysisRuleEntity reportingTask) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity updateFlowAnalysisRule(final FlowAnalysisRuleEntity flowAnalysisRuleEntity) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity activateFlowAnalysisRule(final String id, final FlowAnalysisRuleRunStatusEntity runStatusEntity) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity deleteFlowAnalysisRule(final FlowAnalysisRuleEntity flowAnalysisRule) throws NiFiClientException, IOException;
+
+    VerifyConfigRequestEntity submitFlowAnalysisRuleConfigVerificationRequest(final VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException;
+
+    VerifyConfigRequestEntity getFlowAnalysisRuleConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException;
+
+    VerifyConfigRequestEntity deleteFlowAnalysisRuleConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException;

Review Comment:
   Similar methods are used by test for other components. I'll add the tests.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip commented on PR #8954:
URL: https://github.com/apache/nifi/pull/8954#issuecomment-2164924452

   @tpalfy Could you please also update the [Toolkit Guide](https://github.com/apache/nifi/blob/main/nifi-docs/src/main/asciidoc/toolkit-guide.adoc) with the new commands? Thanks


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "turcsanyip (via GitHub)" <gi...@apache.org>.
turcsanyip commented on code in PR #8954:
URL: https://github.com/apache/nifi/pull/8954#discussion_r1636833089


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ControllerClient.java:
##########
@@ -61,6 +66,26 @@ public interface ControllerClient {
     VersionedReportingTaskImportResponseEntity importReportingTasks(VersionedReportingTaskImportRequestEntity importRequestEntity)
             throws NiFiClientException, IOException;
 
+    FlowAnalysisRulesEntity getFlowAnalysisRules() throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity getFlowAnalysisRule(final String id) throws NiFiClientException, IOException;
+
+    PropertyDescriptorEntity getFlowAnalysisRulePropertyDescriptor(final String componentId, final String propertyName, final Boolean sensitive) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity createFlowAnalysisRule(FlowAnalysisRuleEntity reportingTask) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity updateFlowAnalysisRule(final FlowAnalysisRuleEntity flowAnalysisRuleEntity) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity activateFlowAnalysisRule(final String id, final FlowAnalysisRuleRunStatusEntity runStatusEntity) throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity deleteFlowAnalysisRule(final FlowAnalysisRuleEntity flowAnalysisRule) throws NiFiClientException, IOException;
+
+    VerifyConfigRequestEntity submitFlowAnalysisRuleConfigVerificationRequest(final VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException;
+
+    VerifyConfigRequestEntity getFlowAnalysisRuleConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException;
+
+    VerifyConfigRequestEntity deleteFlowAnalysisRuleConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException;

Review Comment:
   What is the purpose of these methods? They seem to be unused.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "tpalfy (via GitHub)" <gi...@apache.org>.
tpalfy commented on code in PR #8954:
URL: https://github.com/apache/nifi/pull/8954#discussion_r1639690768


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ControllerClient.java:
##########
@@ -61,6 +66,26 @@ public interface ControllerClient {
     VersionedReportingTaskImportResponseEntity importReportingTasks(VersionedReportingTaskImportRequestEntity importRequestEntity)
             throws NiFiClientException, IOException;
 
+    FlowAnalysisRulesEntity getFlowAnalysisRules() throws NiFiClientException, IOException;
+
+    FlowAnalysisRuleEntity getFlowAnalysisRule(final String id) throws NiFiClientException, IOException;
+
+    PropertyDescriptorEntity getFlowAnalysisRulePropertyDescriptor(final String componentId, final String propertyName, final Boolean sensitive) throws NiFiClientException, IOException;

Review Comment:
   Yes, and as I understand it it's normal to have API methods for system test purposes only.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-13388 Add NiFi Cli support for Flow Analysis Rules [nifi]

Posted by "tpalfy (via GitHub)" <gi...@apache.org>.
tpalfy commented on code in PR #8954:
URL: https://github.com/apache/nifi/pull/8954#discussion_r1639658384


##########
nifi-system-tests/nifi-system-test-suite/src/test/resources/conf/default/bootstrap.conf:
##########
@@ -27,7 +27,7 @@ java.arg.3=-Xmx512m
 
 java.arg.14=-Djava.awt.headless=true
 
-#java.arg.debug=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8002
+java.arg.debug=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8002

Review Comment:
   Indeed.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org