Skip to content

Commit 840ab55

Browse files
committed
backend work - WIP
1 parent 5b42a24 commit 840ab55

File tree

11 files changed

+153
-1
lines changed

11 files changed

+153
-1
lines changed

c2/c2-protocol/c2-protocol-component-api/src/main/java/org/apache/nifi/c2/protocol/component/api/ComponentManifest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class ComponentManifest implements Serializable {
3232
private List<ReportingTaskDefinition> reportingTasks;
3333
private List<ParameterProviderDefinition> parameterProviders;
3434
private List<FlowAnalysisRuleDefinition> flowAnalysisRules;
35+
private List<FlowRegistryClientDefinition> flowRegistryClients;
3536

3637
@Schema(description = "Public interfaces defined in this bundle")
3738
public List<DefinedType> getApis() {
@@ -87,4 +88,12 @@ public void setFlowAnalysisRules(List<FlowAnalysisRuleDefinition> flowAnalysisRu
8788
this.flowAnalysisRules = flowAnalysisRules;
8889
}
8990

91+
@Schema(description = "Flow Analysis Rules provided in this bundle")
92+
public List<FlowRegistryClientDefinition> getFlowRegistryClients() {
93+
return (flowRegistryClients != null ? Collections.unmodifiableList(flowRegistryClients) : null);
94+
}
95+
96+
public void setFlowRegistryClients(List<FlowRegistryClientDefinition> flowRegistryClients) {
97+
this.flowRegistryClients = flowRegistryClients;
98+
}
9099
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.nifi.c2.protocol.component.api;
19+
20+
public class FlowRegistryClientDefinition extends ConfigurableExtensionDefinition {
21+
private static final long serialVersionUID = 1L;
22+
23+
}

nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.nifi.bundle.BundleCoordinate;
2424
import org.apache.nifi.c2.protocol.component.api.ControllerServiceDefinition;
2525
import org.apache.nifi.c2.protocol.component.api.FlowAnalysisRuleDefinition;
26+
import org.apache.nifi.c2.protocol.component.api.FlowRegistryClientDefinition;
2627
import org.apache.nifi.c2.protocol.component.api.ParameterProviderDefinition;
2728
import org.apache.nifi.c2.protocol.component.api.ProcessorDefinition;
2829
import org.apache.nifi.c2.protocol.component.api.ReportingTaskDefinition;
@@ -557,6 +558,17 @@ Set<DocumentedTypeDTO> getControllerServiceTypes(final String serviceType, final
557558
*/
558559
FlowAnalysisRuleDefinition getFlowAnalysisRuleDefinition(String group, String artifact, String version, String type);
559560

561+
/**
562+
* Return the FlowRegistryClientDefinition the specified Flow Registry Client.
563+
*
564+
* @param group The bundle group
565+
* @param artifact The bundle artifact
566+
* @param version The bundle version
567+
* @param type The Flow Registry Client type
568+
* @return The FlowRegistryClientDefinition
569+
*/
570+
FlowRegistryClientDefinition getFlowRegistryClientDefinition(String group, String artifact, String version, String type);
571+
560572
/**
561573
* Return the additionalDetails for the specified component.
562574
*

nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.apache.nifi.bundle.BundleCoordinate;
5555
import org.apache.nifi.c2.protocol.component.api.ControllerServiceDefinition;
5656
import org.apache.nifi.c2.protocol.component.api.FlowAnalysisRuleDefinition;
57+
import org.apache.nifi.c2.protocol.component.api.FlowRegistryClientDefinition;
5758
import org.apache.nifi.c2.protocol.component.api.ParameterProviderDefinition;
5859
import org.apache.nifi.c2.protocol.component.api.ProcessorDefinition;
5960
import org.apache.nifi.c2.protocol.component.api.ReportingTaskDefinition;
@@ -3901,6 +3902,15 @@ public Set<DocumentedTypeDTO> getFlowRegistryTypes() {
39013902
return controllerFacade.getFlowRegistryTypes();
39023903
}
39033904

3905+
@Override
3906+
public FlowRegistryClientDefinition getFlowRegistryClientDefinition(String group, String artifact, String version, String type) {
3907+
final FlowRegistryClientDefinition flowRegistryClientDefinition = controllerFacade.getFlowRegistryClientDefinition(group, artifact, version, type);
3908+
if (flowRegistryClientDefinition == null) {
3909+
throw new ResourceNotFoundException("Unable to find definition for [%s:%s:%s:%s]".formatted(group, artifact, version, type));
3910+
}
3911+
return flowRegistryClientDefinition;
3912+
}
3913+
39043914
@Override
39053915
public RuntimeManifest getRuntimeManifest() {
39063916
return controllerFacade.getRuntimeManifest();

nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.apache.nifi.bundle.BundleDetails;
5555
import org.apache.nifi.c2.protocol.component.api.ControllerServiceDefinition;
5656
import org.apache.nifi.c2.protocol.component.api.FlowAnalysisRuleDefinition;
57+
import org.apache.nifi.c2.protocol.component.api.FlowRegistryClientDefinition;
5758
import org.apache.nifi.c2.protocol.component.api.ParameterProviderDefinition;
5859
import org.apache.nifi.c2.protocol.component.api.ProcessorDefinition;
5960
import org.apache.nifi.c2.protocol.component.api.ReportingTaskDefinition;
@@ -2225,6 +2226,62 @@ public Response getRegistryClients() {
22252226
return generateOkResponse(populateRemainingRegistryClientEntityContent(registryClientEntities)).build();
22262227
}
22272228

2229+
@GET
2230+
@Consumes(MediaType.WILDCARD)
2231+
@Produces(MediaType.APPLICATION_JSON)
2232+
@Path("flow-registry-client-definition/{group}/{artifact}/{version}/{type}")
2233+
@Operation(
2234+
summary = "Retrieves the Flow Registry Client Definition for the specified component type.",
2235+
description = NON_GUARANTEED_ENDPOINT,
2236+
responses = @ApiResponse(content = @Content(schema = @Schema(implementation = FlowAnalysisRuleDefinition.class))),
2237+
security = {
2238+
@SecurityRequirement(name = "Read - /flow")
2239+
}
2240+
)
2241+
@ApiResponses(
2242+
value = {
2243+
@ApiResponse(responseCode = "400", description = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
2244+
@ApiResponse(responseCode = "401", description = "Client could not be authenticated."),
2245+
@ApiResponse(responseCode = "403", description = "Client is not authorized to make this request."),
2246+
@ApiResponse(responseCode = "404", description = "The flow registry client definition for the coordinates could not be located.")
2247+
}
2248+
)
2249+
public Response getFlowRegistryClientDefinition(
2250+
@Parameter(
2251+
description = "The bundle group",
2252+
required = true
2253+
)
2254+
@PathParam("group") String group,
2255+
@Parameter(
2256+
description = "The bundle artifact",
2257+
required = true
2258+
)
2259+
@PathParam("artifact") String artifact,
2260+
@Parameter(
2261+
description = "The bundle version",
2262+
required = true
2263+
)
2264+
@PathParam("version") String version,
2265+
@Parameter(
2266+
description = "The flow registry client type",
2267+
required = true
2268+
)
2269+
@PathParam("type") String type
2270+
) throws InterruptedException {
2271+
2272+
authorizeFlow();
2273+
2274+
if (isReplicateRequest()) {
2275+
return replicate(HttpMethod.GET);
2276+
}
2277+
2278+
// create response entity
2279+
final FlowRegistryClientDefinition entity = serviceFacade.getFlowRegistryClientDefinition(group, artifact, version, type);
2280+
2281+
// generate the response
2282+
return generateOkResponse(entity).build();
2283+
}
2284+
22282285
/**
22292286
* Populate the uri's for the specified flow registry client and also extend the result to make it backward compatible.
22302287
*

nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.nifi.c2.protocol.component.api.ComponentManifest;
3636
import org.apache.nifi.c2.protocol.component.api.ControllerServiceDefinition;
3737
import org.apache.nifi.c2.protocol.component.api.FlowAnalysisRuleDefinition;
38+
import org.apache.nifi.c2.protocol.component.api.FlowRegistryClientDefinition;
3839
import org.apache.nifi.c2.protocol.component.api.ParameterProviderDefinition;
3940
import org.apache.nifi.c2.protocol.component.api.ProcessorDefinition;
4041
import org.apache.nifi.c2.protocol.component.api.ReportingTaskDefinition;
@@ -648,6 +649,11 @@ public FlowAnalysisRuleDefinition getFlowAnalysisRuleDefinition(String group, St
648649
return componentManifest.getFlowAnalysisRules().stream().filter(flowAnalysisRuleDefinition -> type.equals(flowAnalysisRuleDefinition.getType())).findFirst().orElse(null);
649650
}
650651

652+
public FlowRegistryClientDefinition getFlowRegistryClientDefinition(String group, String artifact, String version, String type) {
653+
final ComponentManifest componentManifest = getComponentManifest(group, artifact, version);
654+
return componentManifest.getFlowRegistryClients().stream().filter(flowRegistryClientDefinition -> type.equals(flowRegistryClientDefinition.getType())).findFirst().orElse(null);
655+
}
656+
651657
public String getAdditionalDetails(String group, String artifact, String version, String type) {
652658
final Map<String, File> additionalDetailsMap = runtimeManifestService.discoverAdditionalDetails(group, artifact, version);
653659
final File additionalDetailsFile = additionalDetailsMap.get(type);

nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/documentation/feature/documentation.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { DocumentationEffects } from '../state/documentation/documentation.effec
3535
import { ReportingTaskDefinitionEffects } from '../state/reporting-task-definition/reporting-task-definition.effects';
3636
import { ParameterProviderDefinitionEffects } from '../state/parameter-provider-definition/parameter-provider-definition.effects';
3737
import { FlowAnalysisRuleDefinitionEffects } from '../state/flow-analysis-rule-definition/flow-analysis-rule-definition.effects';
38+
import { FlowRegistryClientDefinitionEffects } from '../state/flow-registry-client-definition/flow-registry-client-definition.effects';
3839

3940
@NgModule({
4041
declarations: [Documentation],
@@ -49,6 +50,7 @@ import { FlowAnalysisRuleDefinitionEffects } from '../state/flow-analysis-rule-d
4950
ReportingTaskDefinitionEffects,
5051
ParameterProviderDefinitionEffects,
5152
FlowAnalysisRuleDefinitionEffects,
53+
FlowRegistryClientDefinitionEffects,
5254
AdditionalDetailsEffects,
5355
DocumentationEffects
5456
),

nifi-manifest/nifi-extension-manifest-model/src/main/java/org/apache/nifi/extension/manifest/ExtensionType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public enum ExtensionType {
2929

3030
FLOW_ANALYSIS_RULE,
3131

32-
PARAMETER_PROVIDER;
32+
PARAMETER_PROVIDER,
3333

34+
FLOW_REGISTRY_CLIENT;
3435
}

nifi-manifest/nifi-runtime-manifest-core/src/main/java/org/apache/nifi/runtime/manifest/ComponentManifestBuilder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.nifi.c2.protocol.component.api.ComponentManifest;
2020
import org.apache.nifi.c2.protocol.component.api.ControllerServiceDefinition;
2121
import org.apache.nifi.c2.protocol.component.api.FlowAnalysisRuleDefinition;
22+
import org.apache.nifi.c2.protocol.component.api.FlowRegistryClientDefinition;
2223
import org.apache.nifi.c2.protocol.component.api.ParameterProviderDefinition;
2324
import org.apache.nifi.c2.protocol.component.api.ProcessorDefinition;
2425
import org.apache.nifi.c2.protocol.component.api.ReportingTaskDefinition;
@@ -58,6 +59,12 @@ public interface ComponentManifestBuilder {
5859
*/
5960
ComponentManifestBuilder addFlowAnalysisRule(FlowAnalysisRuleDefinition flowAnalysisRuleDefinition);
6061

62+
/**
63+
* @param flowRegistryClientDefinition a flow analysis rule definition to add
64+
* @return the builder
65+
*/
66+
ComponentManifestBuilder addFlowRegistryClient(FlowRegistryClientDefinition flowRegistryClientDefinition);
67+
6168
/**
6269
* @return a component manifest containing all the added definitions
6370
*/

nifi-manifest/nifi-runtime-manifest-core/src/main/java/org/apache/nifi/runtime/manifest/impl/StandardComponentManifestBuilder.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.nifi.c2.protocol.component.api.ComponentManifest;
2020
import org.apache.nifi.c2.protocol.component.api.ControllerServiceDefinition;
2121
import org.apache.nifi.c2.protocol.component.api.FlowAnalysisRuleDefinition;
22+
import org.apache.nifi.c2.protocol.component.api.FlowRegistryClientDefinition;
2223
import org.apache.nifi.c2.protocol.component.api.ParameterProviderDefinition;
2324
import org.apache.nifi.c2.protocol.component.api.ProcessorDefinition;
2425
import org.apache.nifi.c2.protocol.component.api.ReportingTaskDefinition;
@@ -37,6 +38,7 @@ public class StandardComponentManifestBuilder implements ComponentManifestBuilde
3738
private final List<ReportingTaskDefinition> reportingTasks = new ArrayList<>();
3839
private final List<ParameterProviderDefinition> parameterProviders = new ArrayList<>();
3940
private final List<FlowAnalysisRuleDefinition> flowAnalysisRules = new ArrayList<>();
41+
private final List<FlowRegistryClientDefinition> flowRegistryClients = new ArrayList<>();
4042

4143
@Override
4244
public ComponentManifestBuilder addProcessor(final ProcessorDefinition processorDefinition) {
@@ -83,6 +85,15 @@ public ComponentManifestBuilder addFlowAnalysisRule(FlowAnalysisRuleDefinition f
8385
return this;
8486
}
8587

88+
@Override
89+
public ComponentManifestBuilder addFlowRegistryClient(FlowRegistryClientDefinition flowRegistryClientDefinition) {
90+
if (flowRegistryClientDefinition == null) {
91+
throw new IllegalArgumentException("Flow Registry Client definition cannot be null");
92+
}
93+
flowRegistryClients.add(flowRegistryClientDefinition);
94+
return this;
95+
}
96+
8697
@Override
8798
public ComponentManifest build() {
8899
final ComponentManifest componentManifest = new ComponentManifest();
@@ -91,6 +102,7 @@ public ComponentManifest build() {
91102
componentManifest.setReportingTasks(new ArrayList<>(reportingTasks));
92103
componentManifest.setParameterProviders(new ArrayList<>(parameterProviders));
93104
componentManifest.setFlowAnalysisRules(new ArrayList<>(flowAnalysisRules));
105+
componentManifest.setFlowRegistryClients(new ArrayList<>(flowRegistryClients));
94106
return componentManifest;
95107
}
96108

0 commit comments

Comments
 (0)