streampipes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zehn...@apache.org
Subject [incubator-streampipes] 11/25: Add example on how to create secret static properties
Date Tue, 17 Dec 2019 09:48:12 GMT
This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git

commit 1ec0d39756d9287c2aded7fe7ce8942cc4a4ee66
Author: Dominik Riemer <riemer@fzi.de>
AuthorDate: Sat Aug 3 14:08:04 2019 +0200

    Add example on how to create secret static properties
---
 .../streampipes/pe/examples/jvm/ExamplesInit.java  |  2 +
 .../SecretStaticPropertyExampleController.java     | 66 ++++++++++++++++++++++
 2 files changed, 68 insertions(+)

diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java
b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java
index ec91503..131d6aa 100644
--- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java
+++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java
@@ -33,6 +33,7 @@ import org.streampipes.pe.examples.jvm.staticproperty.NaryMappingPropertyExample
 import org.streampipes.pe.examples.jvm.staticproperty.NumberParameterExampleController;
 import org.streampipes.pe.examples.jvm.staticproperty.NumberParameterWithRangeExampleController;
 import org.streampipes.pe.examples.jvm.staticproperty.RuntimeResolvableSingleValue;
+import org.streampipes.pe.examples.jvm.staticproperty.SecretStaticPropertyExampleController;
 import org.streampipes.pe.examples.jvm.staticproperty.SingleValueSelectionExampleController;
 import org.streampipes.pe.examples.jvm.staticproperty.StaticPropertyAlternativesController;
 import org.streampipes.pe.examples.jvm.staticproperty.TextParameterExampleController;
@@ -53,6 +54,7 @@ public class ExamplesInit extends StandaloneModelSubmitter {
             .add(new CollectionExampleController())
             .add(new RuntimeResolvableSingleValue())
             .add(new StaticPropertyAlternativesController())
+            .add(new SecretStaticPropertyExampleController())
 
             .add(new AppendOutputController())
             .add(new CustomOutputController())
diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/SecretStaticPropertyExampleController.java
b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/SecretStaticPropertyExampleController.java
new file mode 100644
index 0000000..ed3d835
--- /dev/null
+++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/SecretStaticPropertyExampleController.java
@@ -0,0 +1,66 @@
+/*
+Copyright 2019 FZI Forschungszentrum Informatik
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package org.streampipes.pe.examples.jvm.staticproperty;
+
+import org.streampipes.model.graph.DataProcessorDescription;
+import org.streampipes.model.graph.DataProcessorInvocation;
+import org.streampipes.pe.examples.jvm.base.DummyEngine;
+import org.streampipes.pe.examples.jvm.base.DummyParameters;
+import org.streampipes.sdk.builder.ProcessingElementBuilder;
+import org.streampipes.sdk.builder.StreamRequirementsBuilder;
+import org.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
+import org.streampipes.sdk.helpers.EpRequirements;
+import org.streampipes.sdk.helpers.Labels;
+import org.streampipes.sdk.helpers.OutputStrategies;
+import org.streampipes.sdk.helpers.SupportedFormats;
+import org.streampipes.sdk.helpers.SupportedProtocols;
+import org.streampipes.wrapper.standalone.ConfiguredEventProcessor;
+import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
+
+public class SecretStaticPropertyExampleController extends StandaloneEventProcessingDeclarer<DummyParameters>
{
+
+  private static final String SP_KEY = "my-secret-key";
+
+  @Override
+  public DataProcessorDescription declareModel() {
+    return ProcessingElementBuilder.create("org.streampipes.examples.staticproperty" +
+            ".secret", "Secret Parameter Example", "")
+            .requiredStream(StreamRequirementsBuilder.
+                    create()
+                    .requiredProperty(EpRequirements.anyProperty())
+                    .build())
+            .outputStrategy(OutputStrategies.keep())
+            .supportedProtocols(SupportedProtocols.kafka())
+            .supportedFormats(SupportedFormats.jsonFormat())
+
+            // create a simple text parameter
+            .requiredSecret(Labels.from(SP_KEY, "Secret Password", "Secret Password Example"))
+
+            .build();
+  }
+
+  @Override
+  public ConfiguredEventProcessor<DummyParameters> onInvocation(DataProcessorInvocation
graph, ProcessingElementParameterExtractor extractor) {
+
+    // Extract the text parameter value
+    String textParameter = extractor.secretValue(SP_KEY);
+
+    // now the text parameter would be added to a parameter class (omitted for this example)
+
+    return new ConfiguredEventProcessor<>(new DummyParameters(graph), DummyEngine::new);
+  }
+}
+


Mime
View raw message