Search in sources :

Example 1 with VersionedFlowSnapshotMetadataSetResult

use of org.apache.nifi.toolkit.cli.impl.result.VersionedFlowSnapshotMetadataSetResult in project nifi by apache.

the class PGGetAllVersions method doExecute.

@Override
public VersionedFlowSnapshotMetadataSetResult doExecute(final NiFiClient client, final Properties properties) throws NiFiClientException, IOException, MissingOptionException {
    final String pgId = getRequiredArg(properties, CommandOption.PG_ID);
    final VersionsClient versionsClient = client.getVersionsClient();
    final VersionControlInformationEntity existingVersionControlInfo = versionsClient.getVersionControlInfo(pgId);
    final VersionControlInformationDTO existingVersionControlDTO = existingVersionControlInfo.getVersionControlInformation();
    if (existingVersionControlDTO == null) {
        throw new NiFiClientException("Process group is not under version control");
    }
    final String registryId = existingVersionControlDTO.getRegistryId();
    final String bucketId = existingVersionControlDTO.getBucketId();
    final String flowId = existingVersionControlDTO.getFlowId();
    final FlowClient flowClient = client.getFlowClient();
    final VersionedFlowSnapshotMetadataSetEntity versions = flowClient.getVersions(registryId, bucketId, flowId);
    if (versions.getVersionedFlowSnapshotMetadataSet() == null || versions.getVersionedFlowSnapshotMetadataSet().isEmpty()) {
        throw new NiFiClientException("No versions available");
    }
    return new VersionedFlowSnapshotMetadataSetResult(getResultType(properties), versions);
}
Also used : NiFiClientException(org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException) VersionControlInformationEntity(org.apache.nifi.web.api.entity.VersionControlInformationEntity) VersionedFlowSnapshotMetadataSetResult(org.apache.nifi.toolkit.cli.impl.result.VersionedFlowSnapshotMetadataSetResult) VersionsClient(org.apache.nifi.toolkit.cli.impl.client.nifi.VersionsClient) FlowClient(org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient) VersionedFlowSnapshotMetadataSetEntity(org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity) VersionControlInformationDTO(org.apache.nifi.web.api.dto.VersionControlInformationDTO)

Aggregations

FlowClient (org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient)1 NiFiClientException (org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException)1 VersionsClient (org.apache.nifi.toolkit.cli.impl.client.nifi.VersionsClient)1 VersionedFlowSnapshotMetadataSetResult (org.apache.nifi.toolkit.cli.impl.result.VersionedFlowSnapshotMetadataSetResult)1 VersionControlInformationDTO (org.apache.nifi.web.api.dto.VersionControlInformationDTO)1 VersionControlInformationEntity (org.apache.nifi.web.api.entity.VersionControlInformationEntity)1 VersionedFlowSnapshotMetadataSetEntity (org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity)1