Search in sources :

Example 1 with VersionedFlowSnapshotMetadataEntity

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;
}
Also used : VersionedFlowSnapshotMetadataEntity(org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity)

Example 2 with VersionedFlowSnapshotMetadataEntity

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;
}
Also used : NiFiClientException(org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException) VersionedFlowSnapshotMetadataEntity(org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity) FlowClient(org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient) VersionedFlowSnapshotMetadataSetEntity(org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity)

Example 3 with VersionedFlowSnapshotMetadataEntity

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();
}
Also used : VersionedFlowSnapshotMetadataEntity(org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity) VersionedFlowSnapshotMetadataSetEntity(org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

VersionedFlowSnapshotMetadataEntity (org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity)3 VersionedFlowSnapshotMetadataSetEntity (org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 FlowClient (org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient)1 NiFiClientException (org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException)1