NIFI-10116 Added CLI toolkit command to delete report tasks

This closes #6126

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Zoltan Kornel Torok 2022-06-14 15:06:13 +02:00 committed by exceptionfactory
parent 6a285c67e5
commit a30ac23e90
No known key found for this signature in database
GPG Key ID: 29B6A52D2AAE8DBA
3 changed files with 69 additions and 1 deletions

View File

@ -110,6 +110,7 @@ The following are available commands:
nifi get-reporting-task
nifi get-reporting-tasks
nifi create-reporting-task
nifi delete-reporting-task
nifi set-param
nifi delete-param
nifi list-param-contexts
@ -293,7 +294,7 @@ Typing "nifi " and then a tab will show the sub-commands for NiFi:
delete-param get-service pg-get-param-context update-reg-client
delete-param-context get-services pg-get-services update-user-group
disable-services import-param-context pg-get-vars upload-template
disconnect-node list-param-contexts pg-get-version
disconnect-node list-param-contexts pg-get-version delete-reporting-task
download-template list-reg-clients pg-import
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:

View File

@ -74,6 +74,7 @@ import org.apache.nifi.toolkit.cli.impl.command.nifi.registry.CreateRegistryClie
import org.apache.nifi.toolkit.cli.impl.command.nifi.registry.GetRegistryClientId;
import org.apache.nifi.toolkit.cli.impl.command.nifi.registry.ListRegistryClients;
import org.apache.nifi.toolkit.cli.impl.command.nifi.registry.UpdateRegistryClient;
import org.apache.nifi.toolkit.cli.impl.command.nifi.reporting.DeleteReportingTask;
import org.apache.nifi.toolkit.cli.impl.command.nifi.templates.DownloadTemplate;
import org.apache.nifi.toolkit.cli.impl.command.nifi.templates.ListTemplates;
import org.apache.nifi.toolkit.cli.impl.command.nifi.templates.UploadTemplate;
@ -140,6 +141,7 @@ public class NiFiCommandGroup extends AbstractCommandGroup {
commands.add(new GetReportingTasks());
commands.add(new GetReportingTask());
commands.add(new CreateReportingTask());
commands.add(new DeleteReportingTask());
commands.add(new StartReportingTasks());
commands.add(new StopReportingTasks());
commands.add(new ListUsers());

View File

@ -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.reporting;
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.NiFiClient;
import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException;
import org.apache.nifi.toolkit.cli.impl.client.nifi.ReportingTasksClient;
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.ReportingTaskResult;
import org.apache.nifi.web.api.entity.ReportingTaskEntity;
import java.io.IOException;
import java.util.Properties;
/**
* Command for creating a reporting task.
*/
public class DeleteReportingTask extends AbstractNiFiCommand<ReportingTaskResult> {
public DeleteReportingTask() {
super("delete-reporting-task", ReportingTaskResult.class);
}
@Override
public String getDescription() {
return "Delete a reporting task.";
}
@Override
public void doInitialize(final Context context) {
addOption(CommandOption.RT_ID.createOption());
}
@Override
public ReportingTaskResult doExecute(final NiFiClient client, final Properties properties)
throws NiFiClientException, IOException, MissingOptionException, CommandException {
final String reportingTaskId = getRequiredArg(properties, CommandOption.RT_ID);
final ReportingTasksClient reportingTasksClient = client.getReportingTasksClient();
ReportingTaskEntity reportingTask = reportingTasksClient.getReportingTask(reportingTaskId);
final ReportingTaskEntity deletedReportingTaskEntity = reportingTasksClient.deleteReportingTask(reportingTask);
return new ReportingTaskResult(getResultType(properties), deletedReportingTaskEntity);
}
}