use of org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity in project nifi by apache.
the class PGChangeVersion method getLatestVersion.
private int getLatestVersion(final NiFiClient client, final VersionControlInformationDTO existingVersionControlDTO) throws NiFiClientException, IOException {
final FlowClient flowClient = client.getFlowClient();
final String registryId = existingVersionControlDTO.getRegistryId();
final String bucketId = existingVersionControlDTO.getBucketId();
final String flowId = existingVersionControlDTO.getFlowId();
final VersionedFlowSnapshotMetadataSetEntity versions = flowClient.getVersions(registryId, bucketId, flowId);
if (versions.getVersionedFlowSnapshotMetadataSet() == null || versions.getVersionedFlowSnapshotMetadataSet().isEmpty()) {
throw new NiFiClientException("No versions available");
}
int latestVersion = 1;
for (VersionedFlowSnapshotMetadataEntity version : versions.getVersionedFlowSnapshotMetadataSet()) {
if (version.getVersionedFlowSnapshotMetadata().getVersion() > latestVersion) {
latestVersion = version.getVersionedFlowSnapshotMetadata().getVersion();
}
}
return latestVersion;
}
use of org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity 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);
}
use of org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity in project nifi by apache.
the class FlowResource method getVersions.
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("registries/{registry-id}/buckets/{bucket-id}/flows/{flow-id}/versions")
@ApiOperation(value = "Gets the flow versions from the specified registry and bucket for the specified flow for the current user", response = VersionedFlowSnapshotMetadataSetEntity.class, authorizations = { @Authorization(value = "Read - /flow") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getVersions(@ApiParam(value = "The registry id.", required = true) @PathParam("registry-id") String registryId, @ApiParam(value = "The bucket id.", required = true) @PathParam("bucket-id") String bucketId, @ApiParam(value = "The flow id.", required = true) @PathParam("flow-id") String flowId) {
authorizeFlow();
final Set<VersionedFlowSnapshotMetadataEntity> versionedFlowSnapshotMetadataSet = serviceFacade.getFlowVersionsForUser(registryId, bucketId, flowId, NiFiUserUtils.getNiFiUser());
final VersionedFlowSnapshotMetadataSetEntity versionedFlowSnapshotMetadataSetEntity = new VersionedFlowSnapshotMetadataSetEntity();
versionedFlowSnapshotMetadataSetEntity.setVersionedFlowSnapshotMetadataSet(versionedFlowSnapshotMetadataSet);
return generateOkResponse(versionedFlowSnapshotMetadataSetEntity).build();
}
Aggregations