adamdebreceni commented on code in PR #2268: URL: https://github.com/apache/nifi-minifi-cpp/pull/2268#discussion_r4610241431
########## extensions/opc/include/FetchOPCEvents.h: ########## @@ -0,0 +1,175 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +#pragma once + +#include <memory> +#include <mutex> +#include <optional> +#include <vector> + +#include "BaseOPCProcessor.h" +#include "OPCCommon.h" +#include "core/ProcessSession.h" +#include "core/PropertyDefinitionBuilder.h" +#include "core/logging/LoggerFactory.h" +#include "minifi-cpp/controllers/RecordSetWriter.h" +#include "minifi-cpp/core/Property.h" +#include "minifi-cpp/core/PropertyValidator.h" +#include "minifi-cpp/core/RelationshipDefinition.h" +#include "utils/ArrayUtils.h" +#include "utils/StoppableThread.h" + +using namespace std::literals::chrono_literals; + +namespace org::apache::nifi::minifi::processors { + +class FetchOPCEvents final : public BaseOPCProcessor { + public: + using BaseOPCProcessor::BaseOPCProcessor; + + EXTENSIONAPI static constexpr const char* Description = + "Subscribes to OPC-UA events from the specified node. " + "The processor will continuously listen for events and write them to flow file records when the processor is triggered. " + "The events can be filtered using the filtering criteria specified in the processor properties."; + + EXTENSIONAPI static constexpr auto NodeIDType = + core::PropertyDefinitionBuilder<magic_enum::enum_count<opc::OPCNodeIDType>()>::createProperty("Node ID type") + .withDescription("Specifies the type of the provided node ID") + .isRequired(true) + .withAllowedValues(magic_enum::enum_names<opc::OPCNodeIDType>()) + .build(); + EXTENSIONAPI static constexpr auto NodeID = + core::PropertyDefinitionBuilder<>::createProperty("Node ID") + .withDescription( + "Specifies the node ID of the target OPC-UA node to subscribe to. In case of a Path Node ID Type, the path should be provided in the " + "format of 'path/to/node'.") + .isRequired(true) + .build(); + EXTENSIONAPI static constexpr auto NameSpaceIndex = + core::PropertyDefinitionBuilder<>::createProperty("Namespace index") + .withDescription("Specifies the index of the namespace for the target OPC-UA node.") + .withValidator(core::StandardPropertyValidators::UNSIGNED_INTEGER_VALIDATOR) + .withDefaultValue("0") + .isRequired(true) + .build(); + EXTENSIONAPI static constexpr auto EventTypeNodeId = + core::PropertyDefinitionBuilder<>::createProperty("Event type node ID") + .withDescription( + "Adds event type to the event filter. Only events of this type or its subtypes are reported. " + "i=2041 (BaseEventType) is inherited by every event type, so it applies no type filtering.") + .withDefaultValue("i=2041") + .isRequired(true) + .build(); + EXTENSIONAPI static constexpr auto SelectFields = + core::PropertyDefinitionBuilder<>::createProperty("Select fields") + .withDescription( + "Comma separated browse paths of the event fields to return, e.g. 'EventId,Time,Message,Severity,SourceName'. " + "Nested paths use '/', e.g. 'Tool/Diameter', and a browse name outside namespace 0 is prefixed with its namespace " + "index, e.g. '1:Diameter'. A path can be prefixed with the node ID of an event type to restrict the field to the " + "instances of that type, e.g. 'i=2052/ActionTimeStamp', but the server rejects the whole subscription unless it " + "knows that event type and the field belongs to it. Each field is named after its path in the record.") + .withDefaultValue("EventId,EventType,SourceName,Time,Message,Severity") + .isRequired(true) + .build(); + EXTENSIONAPI static constexpr auto MinimumSeverity = + core::PropertyDefinitionBuilder<>::createProperty("Minimum severity") + .withDescription("Specifies the minimum severity of events to fetch. 0 disables the severity filter.") + .withValidator(core::StandardPropertyValidators::UNSIGNED_INTEGER_VALIDATOR) + .withDefaultValue("0") + .isRequired(true) Review Comment: why not have it an optional property without default, instead of 0 meaning optional? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
