mirror of https://github.com/apache/nifi.git
NIFI-13536 Added branch parameter to REST methods for listing buckets and flows
This closes #9071 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
e205f27f89
commit
16c9ea4f7c
|
@ -2438,31 +2438,34 @@ public interface NiFiServiceFacade {
|
|||
* Gets the flows for the current user for the specified registry and bucket.
|
||||
*
|
||||
* @param registryClientId registry client id
|
||||
* @param branch the branch
|
||||
* @param bucketId bucket id
|
||||
* @return the flows
|
||||
*/
|
||||
Set<VersionedFlowEntity> getFlowsForUser(String registryClientId, String bucketId);
|
||||
Set<VersionedFlowEntity> getFlowsForUser(String registryClientId, String branch, String bucketId);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the details of a versioned flow from a given bucket of a given registry.
|
||||
*
|
||||
* @param registryClientId registry client id
|
||||
* @param branch the branch
|
||||
* @param bucketId bucket id
|
||||
* @param flowId flow id
|
||||
* @return the flow details
|
||||
*/
|
||||
VersionedFlowEntity getFlowForUser(String registryClientId, String bucketId, String flowId);
|
||||
VersionedFlowEntity getFlowForUser(String registryClientId, String branch, String bucketId, String flowId);
|
||||
|
||||
/**
|
||||
* Gets the versions of the specified registry, bucket, and flow for the current user.
|
||||
*
|
||||
* @param registryClientId registry client id
|
||||
* @param branch the branch
|
||||
* @param bucketId bucket id
|
||||
* @param flowId flow id
|
||||
* @return the versions of the flow
|
||||
*/
|
||||
Set<VersionedFlowSnapshotMetadataEntity> getFlowVersionsForUser(String registryClientId, String bucketId, String flowId);
|
||||
Set<VersionedFlowSnapshotMetadataEntity> getFlowVersionsForUser(String registryClientId, String branch, String bucketId, String flowId);
|
||||
|
||||
/**
|
||||
* Updates the specified registry using the specified revision.
|
||||
|
|
|
@ -3272,27 +3272,24 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<VersionedFlowEntity> getFlowsForUser(final String registryClientId, final String bucketId) {
|
||||
public Set<VersionedFlowEntity> getFlowsForUser(final String registryClientId, final String branch, final String bucketId) {
|
||||
final FlowRegistryClientUserContext clientUserContext = FlowRegistryClientContextFactory.getContextForUser(NiFiUserUtils.getNiFiUser());
|
||||
final FlowRegistryBranch defaultBranch = flowRegistryDAO.getDefaultBranchForUser(clientUserContext, registryClientId);
|
||||
return flowRegistryDAO.getFlowsForUser(clientUserContext, registryClientId, defaultBranch.getName(), bucketId).stream()
|
||||
return flowRegistryDAO.getFlowsForUser(clientUserContext, registryClientId, branch, bucketId).stream()
|
||||
.map(rf -> createVersionedFlowEntity(registryClientId, rf))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionedFlowEntity getFlowForUser(final String registryClientId, final String bucketId, final String flowId) {
|
||||
public VersionedFlowEntity getFlowForUser(final String registryClientId, final String branch, final String bucketId, final String flowId) {
|
||||
final FlowRegistryClientUserContext clientUserContext = FlowRegistryClientContextFactory.getContextForUser(NiFiUserUtils.getNiFiUser());
|
||||
final FlowRegistryBranch defaultBranch = flowRegistryDAO.getDefaultBranchForUser(clientUserContext, registryClientId);
|
||||
final RegisteredFlow flow = flowRegistryDAO.getFlowForUser(clientUserContext, registryClientId, defaultBranch.getName(), bucketId, flowId);
|
||||
final RegisteredFlow flow = flowRegistryDAO.getFlowForUser(clientUserContext, registryClientId, branch, bucketId, flowId);
|
||||
return createVersionedFlowEntity(registryClientId, flow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<VersionedFlowSnapshotMetadataEntity> getFlowVersionsForUser(final String registryClientId, final String bucketId, final String flowId) {
|
||||
public Set<VersionedFlowSnapshotMetadataEntity> getFlowVersionsForUser(final String registryClientId, final String branch, final String bucketId, final String flowId) {
|
||||
final FlowRegistryClientUserContext clientUserContext = FlowRegistryClientContextFactory.getContextForUser(NiFiUserUtils.getNiFiUser());
|
||||
final FlowRegistryBranch defaultBranch = flowRegistryDAO.getDefaultBranchForUser(clientUserContext, registryClientId);
|
||||
return flowRegistryDAO.getFlowVersionsForUser(clientUserContext, registryClientId, defaultBranch.getName(), bucketId, flowId).stream()
|
||||
return flowRegistryDAO.getFlowVersionsForUser(clientUserContext, registryClientId, branch, bucketId, flowId).stream()
|
||||
.map(md -> createVersionedFlowSnapshotMetadataEntity(registryClientId, md))
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
|
|
@ -1940,7 +1940,7 @@ public class FlowResource extends ApplicationResource {
|
|||
@Parameter(
|
||||
description = "The name of a branch to get the buckets from. If not specified the default branch of the registry client will be used."
|
||||
)
|
||||
@QueryParam("branch") String branch) throws NiFiRegistryException {
|
||||
@QueryParam("branch") String branch) {
|
||||
|
||||
authorizeFlow();
|
||||
|
||||
|
@ -1995,11 +1995,16 @@ public class FlowResource extends ApplicationResource {
|
|||
description = "The bucket id.",
|
||||
required = true
|
||||
)
|
||||
@PathParam("bucket-id") String bucketId) {
|
||||
@PathParam("bucket-id") String bucketId,
|
||||
@Parameter(
|
||||
description = "The name of a branch to get the flows from. If not specified the default branch of the registry client will be used."
|
||||
)
|
||||
@QueryParam("branch") String branch) {
|
||||
|
||||
authorizeFlow();
|
||||
|
||||
final Set<VersionedFlowEntity> registeredFlows = serviceFacade.getFlowsForUser(registryId, bucketId);
|
||||
final String selectedBranch = branch == null ? serviceFacade.getDefaultBranch(registryId).getBranch().getName() : branch;
|
||||
final Set<VersionedFlowEntity> registeredFlows = serviceFacade.getFlowsForUser(registryId, selectedBranch, bucketId);
|
||||
final SortedSet<VersionedFlowEntity> sortedFlows = sortFlows(registeredFlows);
|
||||
|
||||
final VersionedFlowsEntity versionedFlowsEntity = new VersionedFlowsEntity();
|
||||
|
@ -2054,11 +2059,16 @@ public class FlowResource extends ApplicationResource {
|
|||
description = "The flow id.",
|
||||
required = true
|
||||
)
|
||||
@PathParam("flow-id") String flowId) {
|
||||
@PathParam("flow-id") String flowId,
|
||||
@Parameter(
|
||||
description = "The name of a branch to get the flow from. If not specified the default branch of the registry client will be used."
|
||||
)
|
||||
@QueryParam("branch") String branch) {
|
||||
|
||||
authorizeFlow();
|
||||
|
||||
final VersionedFlowEntity flowDetails = serviceFacade.getFlowForUser(registryId, bucketId, flowId);
|
||||
final String selectedBranch = branch == null ? serviceFacade.getDefaultBranch(registryId).getBranch().getName() : branch;
|
||||
final VersionedFlowEntity flowDetails = serviceFacade.getFlowForUser(registryId, selectedBranch, bucketId, flowId);
|
||||
return generateOkResponse(flowDetails).build();
|
||||
}
|
||||
|
||||
|
@ -2191,11 +2201,16 @@ public class FlowResource extends ApplicationResource {
|
|||
description = "The flow id.",
|
||||
required = true
|
||||
)
|
||||
@PathParam("flow-id") String flowId) {
|
||||
@PathParam("flow-id") String flowId,
|
||||
@Parameter(
|
||||
description = "The name of a branch to get the flow versions from. If not specified the default branch of the registry client will be used."
|
||||
)
|
||||
@QueryParam("branch") String branch) {
|
||||
|
||||
authorizeFlow();
|
||||
|
||||
final Set<VersionedFlowSnapshotMetadataEntity> registeredFlowSnapshotMetadataSet = serviceFacade.getFlowVersionsForUser(registryId, bucketId, flowId);
|
||||
final String selectedBranch = branch == null ? serviceFacade.getDefaultBranch(registryId).getBranch().getName() : branch;
|
||||
final Set<VersionedFlowSnapshotMetadataEntity> registeredFlowSnapshotMetadataSet = serviceFacade.getFlowVersionsForUser(registryId, selectedBranch, bucketId, flowId);
|
||||
|
||||
final VersionedFlowSnapshotMetadataSetEntity versionedFlowSnapshotMetadataSetEntity = new VersionedFlowSnapshotMetadataSetEntity();
|
||||
versionedFlowSnapshotMetadataSetEntity.setVersionedFlowSnapshotMetadataSet(registeredFlowSnapshotMetadataSet);
|
||||
|
|
Loading…
Reference in New Issue