mirror of https://github.com/apache/nifi.git
NIFI-11844 - CLI - command to stop version control of a process group
This closes #7513 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
969679e43b
commit
d9b04770ef
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.nifi.toolkit.cli.impl.client.nifi;
|
||||
|
||||
import org.apache.nifi.web.api.entity.ProcessGroupEntity;
|
||||
import org.apache.nifi.web.api.entity.StartVersionControlRequestEntity;
|
||||
import org.apache.nifi.web.api.entity.VersionControlInformationEntity;
|
||||
import org.apache.nifi.web.api.entity.VersionedFlowUpdateRequestEntity;
|
||||
|
@ -35,6 +36,8 @@ public interface VersionsClient {
|
|||
|
||||
VersionControlInformationEntity startVersionControl(String processGroupId, StartVersionControlRequestEntity startVersionControlRequestEntity) throws IOException, NiFiClientException;
|
||||
|
||||
VersionControlInformationEntity stopVersionControl(ProcessGroupEntity processGroupEntity) throws IOException, NiFiClientException;
|
||||
|
||||
VersionedFlowUpdateRequestEntity initiateRevertFlowVersion(String processGroupId, VersionControlInformationEntity versionControlInformation) throws IOException, NiFiClientException;
|
||||
|
||||
VersionedFlowUpdateRequestEntity getRevertFlowVersionRequest(String requestId) throws IOException, NiFiClientException;
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException;
|
||||
import org.apache.nifi.toolkit.cli.impl.client.nifi.RequestConfig;
|
||||
import org.apache.nifi.toolkit.cli.impl.client.nifi.VersionsClient;
|
||||
import org.apache.nifi.web.api.entity.ProcessGroupEntity;
|
||||
import org.apache.nifi.web.api.entity.StartVersionControlRequestEntity;
|
||||
import org.apache.nifi.web.api.entity.VersionControlInformationEntity;
|
||||
import org.apache.nifi.web.api.entity.VersionedFlowUpdateRequestEntity;
|
||||
|
@ -139,6 +140,26 @@ public class JerseyVersionsClient extends AbstractJerseyClient implements Versio
|
|||
});
|
||||
}
|
||||
|
||||
// DELETE /versions/process-groups/{id}
|
||||
|
||||
@Override
|
||||
public VersionControlInformationEntity stopVersionControl(ProcessGroupEntity processGroupEntity) throws IOException, NiFiClientException {
|
||||
final String pgId = processGroupEntity.getId();
|
||||
|
||||
if (StringUtils.isBlank(pgId)) {
|
||||
throw new IllegalArgumentException("Process group id cannot be null or blank");
|
||||
}
|
||||
|
||||
return executeAction("Error stopping version control", () -> {
|
||||
final WebTarget target = versionsTarget
|
||||
.path("process-groups/{id}")
|
||||
.queryParam("version", processGroupEntity.getRevision().getVersion())
|
||||
.resolveTemplate("id", pgId);
|
||||
|
||||
return getRequestBuilder(target).delete(VersionControlInformationEntity.class);
|
||||
});
|
||||
}
|
||||
|
||||
// POST /versions/revert-requests/process-groups/id
|
||||
|
||||
@Override
|
||||
|
|
|
@ -77,6 +77,7 @@ import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGSetVar;
|
|||
import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGStart;
|
||||
import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGStatus;
|
||||
import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGStop;
|
||||
import org.apache.nifi.toolkit.cli.impl.command.nifi.pg.PGStopVersionControl;
|
||||
import org.apache.nifi.toolkit.cli.impl.command.nifi.policies.GetAccessPolicy;
|
||||
import org.apache.nifi.toolkit.cli.impl.command.nifi.policies.UpdateAccessPolicy;
|
||||
import org.apache.nifi.toolkit.cli.impl.command.nifi.registry.CreateRegistryClient;
|
||||
|
@ -130,6 +131,7 @@ public class NiFiCommandGroup extends AbstractCommandGroup {
|
|||
commands.add(new PGGetVars());
|
||||
commands.add(new PGSetVar());
|
||||
commands.add(new PGGetVersion());
|
||||
commands.add(new PGStopVersionControl());
|
||||
commands.add(new PGChangeVersion());
|
||||
commands.add(new PGGetAllVersions());
|
||||
commands.add(new PGList());
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.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.AbstractNiFiCommand;
|
||||
import org.apache.nifi.toolkit.cli.impl.result.nifi.VersionControlInfoResult;
|
||||
import org.apache.nifi.web.api.entity.ProcessGroupEntity;
|
||||
import org.apache.nifi.web.api.entity.VersionControlInformationEntity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Command to get the version control info for a given process group.
|
||||
*/
|
||||
public class PGStopVersionControl extends AbstractNiFiCommand<VersionControlInfoResult> {
|
||||
|
||||
public PGStopVersionControl() {
|
||||
super("pg-stop-version-control", VersionControlInfoResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Stops version control for the specified process group.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInitialize(final Context context) {
|
||||
addOption(CommandOption.PG_ID.createOption());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionControlInfoResult doExecute(final NiFiClient client, final Properties properties)
|
||||
throws NiFiClientException, IOException, MissingOptionException, CommandException {
|
||||
final String pgId = getRequiredArg(properties, CommandOption.PG_ID);
|
||||
final ProcessGroupEntity pgEntity = client.getProcessGroupClient().getProcessGroup(pgId);
|
||||
final VersionControlInformationEntity entity = client.getVersionsClient().stopVersionControl(pgEntity);
|
||||
return new VersionControlInfoResult(getResultType(properties), entity);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue