use of org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity in project nifi by apache.
the class StandardNiFiServiceFacade method createVersionedFlowSnapshotMetadataEntity.
private VersionedFlowSnapshotMetadataEntity createVersionedFlowSnapshotMetadataEntity(final String registryId, final VersionedFlowSnapshotMetadata metadata) {
if (metadata == null) {
return null;
}
final VersionedFlowSnapshotMetadataEntity entity = new VersionedFlowSnapshotMetadataEntity();
entity.setRegistryId(registryId);
entity.setVersionedFlowMetadata(metadata);
return entity;
}
use of org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity 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.VersionedFlowSnapshotMetadataEntity 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