Search in sources :

Example 1 with VersionedFlowSnapshotMetadataSetEntity

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;
}
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 2 with VersionedFlowSnapshotMetadataSetEntity

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);
}
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)

Example 3 with VersionedFlowSnapshotMetadataSetEntity

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();
}
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

VersionedFlowSnapshotMetadataSetEntity (org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity)3 FlowClient (org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient)2 NiFiClientException (org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException)2 VersionedFlowSnapshotMetadataEntity (org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity)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 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