Skip to content

Commit

Permalink
MINIFICPP-2164 Use a list of types for allowed types in PropertyDefin…
Browse files Browse the repository at this point in the history
…ition

Signed-off-by: Gabor Gyimesi <[email protected]>

This closes #1626
  • Loading branch information
fgerlits authored and lordgamez committed Aug 16, 2023
1 parent 6372d67 commit fbd69e7
Show file tree
Hide file tree
Showing 18 changed files with 217 additions and 150 deletions.
9 changes: 4 additions & 5 deletions extensions/elasticsearch/PostElasticsearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ class PostElasticsearch : public core::Processor {
.withPropertyType(core::StandardPropertyTypes::UNSIGNED_LONG_TYPE)
.withDefaultValue("100")
.build();
EXTENSIONAPI static constexpr auto ElasticCredentials = core::PropertyDefinitionBuilder<0, 1>::createProperty("Elasticsearch Credentials Provider Service")
EXTENSIONAPI static constexpr auto ElasticCredentials = core::PropertyDefinitionBuilder<>::createProperty("Elasticsearch Credentials Provider Service")
.withDescription("The Controller Service used to obtain Elasticsearch credentials.")
.isRequired(true)
.withAllowedTypes({core::className<ElasticsearchCredentialsControllerService>()})
.withAllowedTypes<ElasticsearchCredentialsControllerService>()
.build();
EXTENSIONAPI static constexpr auto SSLContext = core::PropertyDefinitionBuilder<0, 1>::createProperty("SSL Context Service")
EXTENSIONAPI static constexpr auto SSLContext = core::PropertyDefinitionBuilder<>::createProperty("SSL Context Service")
.withDescription("The SSL Context Service used to provide client certificate "
"information for TLS/SSL (https) connections.")
.isRequired(false)
.withAllowedTypes({core::className<minifi::controllers::SSLContextService>()})
.withAllowedTypes<minifi::controllers::SSLContextService>()
.build();
EXTENSIONAPI static constexpr auto Hosts = core::PropertyDefinitionBuilder<>::createProperty("Hosts")
.withDescription("A comma-separated list of HTTP hosts that host Elasticsearch query nodes. Currently only supports a single host.")
Expand Down Expand Up @@ -90,7 +90,6 @@ class PostElasticsearch : public core::Processor {
Identifier
};


EXTENSIONAPI static constexpr auto Success = core::RelationshipDefinition{"success", "All flowfiles that succeed in being transferred into Elasticsearch go here."};
EXTENSIONAPI static constexpr auto Failure = core::RelationshipDefinition{"failure", "All flowfiles that fail for reasons unrelated to server availability go to this relationship."};
EXTENSIONAPI static constexpr auto Error = core::RelationshipDefinition{"error", "All flowfiles that Elasticsearch responded to with an error go to this relationship."};
Expand Down
4 changes: 2 additions & 2 deletions extensions/gcp/processors/GCSProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class GCSProcessor : public core::Processor {
logger_(std::move(logger)) {
}

EXTENSIONAPI static constexpr auto GCPCredentials = core::PropertyDefinitionBuilder<0, 1>::createProperty("GCP Credentials Provider Service")
EXTENSIONAPI static constexpr auto GCPCredentials = core::PropertyDefinitionBuilder<>::createProperty("GCP Credentials Provider Service")
.withDescription("The Controller Service used to obtain Google Cloud Platform credentials. Should be the name of a GCPCredentialsControllerService.")
.isRequired(true)
.withAllowedTypes({core::className<GCPCredentialsControllerService>()})
.withAllowedTypes<GCPCredentialsControllerService>()
.build();
EXTENSIONAPI static constexpr auto NumberOfRetries = core::PropertyDefinitionBuilder<>::createProperty("Number of retries")
.withDescription("How many retry attempts should be made before routing to the failure relationship.")
Expand Down
4 changes: 2 additions & 2 deletions extensions/http-curl/processors/InvokeHTTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ class InvokeHTTP : public core::Processor {
EXTENSIONAPI static constexpr auto AttributesToSend = core::PropertyDefinitionBuilder<>::createProperty("Attributes to Send")
.withDescription("Regular expression that defines which attributes to send as HTTP headers in the request. If not defined, no attributes are sent as headers.")
.build();
EXTENSIONAPI static constexpr auto SSLContext = core::PropertyDefinitionBuilder<0, 1, 0, 1>::createProperty("SSL Context Service")
EXTENSIONAPI static constexpr auto SSLContext = core::PropertyDefinitionBuilder<0, 0, 1>::createProperty("SSL Context Service")
.withDescription("The SSL Context Service used to provide client certificate information for TLS/SSL (https) connections.")
.isRequired(false)
.withAllowedTypes({core::className<minifi::controllers::SSLContextService>()})
.withAllowedTypes<minifi::controllers::SSLContextService>()
.withExclusiveOfProperties({{{"Remote URL", "^http:.*$"}}})
.build();
EXTENSIONAPI static constexpr auto ProxyHost = core::PropertyDefinitionBuilder<>::createProperty("Proxy Host")
Expand Down
52 changes: 26 additions & 26 deletions extensions/librdkafka/KafkaProcessorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,37 @@ enum class SASLMechanismOption {

class KafkaProcessorBase : public core::Processor {
public:
EXTENSIONAPI static constexpr auto SSLContextService = core::PropertyDefinitionBuilder<0, 1>::createProperty("SSL Context Service")
.withDescription("SSL Context Service Name")
.withAllowedTypes({core::className<minifi::controllers::SSLContextService>()})
.build();
EXTENSIONAPI static constexpr auto SSLContextService = core::PropertyDefinitionBuilder<>::createProperty("SSL Context Service")
.withDescription("SSL Context Service Name")
.withAllowedTypes<minifi::controllers::SSLContextService>()
.build();
EXTENSIONAPI static constexpr auto SecurityProtocol = core::PropertyDefinitionBuilder<magic_enum::enum_count<kafka::SecurityProtocolOption>()>::createProperty("Security Protocol")
.withDescription("Protocol used to communicate with brokers. Corresponds to Kafka's 'security.protocol' property.")
.withDefaultValue(magic_enum::enum_name(kafka::SecurityProtocolOption::plaintext))
.withAllowedValues(magic_enum::enum_names<kafka::SecurityProtocolOption>())
.isRequired(true)
.build();
.withDescription("Protocol used to communicate with brokers. Corresponds to Kafka's 'security.protocol' property.")
.withDefaultValue(magic_enum::enum_name(kafka::SecurityProtocolOption::plaintext))
.withAllowedValues(magic_enum::enum_names<kafka::SecurityProtocolOption>())
.isRequired(true)
.build();
EXTENSIONAPI static constexpr auto KerberosServiceName = core::PropertyDefinitionBuilder<>::createProperty("Kerberos Service Name")
.withDescription("Kerberos Service Name")
.build();
.withDescription("Kerberos Service Name")
.build();
EXTENSIONAPI static constexpr auto KerberosPrincipal = core::PropertyDefinitionBuilder<>::createProperty("Kerberos Principal")
.withDescription("Kerberos Principal")
.build();
.withDescription("Kerberos Principal")
.build();
EXTENSIONAPI static constexpr auto KerberosKeytabPath = core::PropertyDefinitionBuilder<>::createProperty("Kerberos Keytab Path")
.withDescription("The path to the location on the local filesystem where the kerberos keytab is located. Read permission on the file is required.")
.build();
.withDescription("The path to the location on the local filesystem where the kerberos keytab is located. Read permission on the file is required.")
.build();
EXTENSIONAPI static constexpr auto SASLMechanism = core::PropertyDefinitionBuilder<magic_enum::enum_count<kafka::SASLMechanismOption>()>::createProperty("SASL Mechanism")
.withDescription("The SASL mechanism to use for authentication. Corresponds to Kafka's 'sasl.mechanism' property.")
.withDefaultValue(magic_enum::enum_name(kafka::SASLMechanismOption::GSSAPI))
.withAllowedValues(magic_enum::enum_names<kafka::SASLMechanismOption>())
.isRequired(true)
.build();
.withDescription("The SASL mechanism to use for authentication. Corresponds to Kafka's 'sasl.mechanism' property.")
.withDefaultValue(magic_enum::enum_name(kafka::SASLMechanismOption::GSSAPI))
.withAllowedValues(magic_enum::enum_names<kafka::SASLMechanismOption>())
.isRequired(true)
.build();
EXTENSIONAPI static constexpr auto Username = core::PropertyDefinitionBuilder<>::createProperty("Username")
.withDescription("The username when the SASL Mechanism is sasl_plaintext")
.build();
.withDescription("The username when the SASL Mechanism is sasl_plaintext")
.build();
EXTENSIONAPI static constexpr auto Password = core::PropertyDefinitionBuilder<>::createProperty("Password")
.withDescription("The password for the given username when the SASL Mechanism is sasl_plaintext")
.build();
.withDescription("The password for the given username when the SASL Mechanism is sasl_plaintext")
.build();
EXTENSIONAPI static constexpr auto Properties = std::array<core::PropertyReference, 8>{
SSLContextService,
SecurityProtocol,
Expand All @@ -92,14 +92,14 @@ class KafkaProcessorBase : public core::Processor {

KafkaProcessorBase(std::string name, const utils::Identifier& uuid, std::shared_ptr<core::logging::Logger> logger)
: core::Processor(std::move(name), uuid),
logger_(logger) {
logger_(std::move(logger)) {
}

protected:
virtual std::optional<utils::net::SslData> getSslData(core::ProcessContext& context) const;
void setKafkaAuthenticationParameters(core::ProcessContext& context, gsl::not_null<rd_kafka_conf_t*> config);

kafka::SecurityProtocolOption security_protocol_;
kafka::SecurityProtocolOption security_protocol_{};
std::shared_ptr<core::logging::Logger> logger_;
};

Expand Down
40 changes: 20 additions & 20 deletions extensions/splunk/SplunkHECProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,29 @@ namespace org::apache::nifi::minifi::extensions::splunk {
class SplunkHECProcessor : public core::Processor {
public:
EXTENSIONAPI static constexpr auto Hostname = core::PropertyDefinitionBuilder<>::createProperty("Hostname")
.withDescription("The ip address or hostname of the Splunk server.")
.isRequired(true)
.build();
.withDescription("The ip address or hostname of the Splunk server.")
.isRequired(true)
.build();
EXTENSIONAPI static constexpr auto Port = core::PropertyDefinitionBuilder<>::createProperty("Port")
.withDescription("The HTTP Event Collector HTTP Port Number.")
.withPropertyType(core::StandardPropertyTypes::PORT_TYPE)
.withDefaultValue("8088")
.isRequired(true)
.build();
.withDescription("The HTTP Event Collector HTTP Port Number.")
.withPropertyType(core::StandardPropertyTypes::PORT_TYPE)
.withDefaultValue("8088")
.isRequired(true)
.build();
EXTENSIONAPI static constexpr auto Token = core::PropertyDefinitionBuilder<>::createProperty("Token")
.withDescription("HTTP Event Collector token starting with the string Splunk. For example \'Splunk 1234578-abcd-1234-abcd-1234abcd\'")
.isRequired(true)
.build();
.withDescription("HTTP Event Collector token starting with the string Splunk. For example \'Splunk 1234578-abcd-1234-abcd-1234abcd\'")
.isRequired(true)
.build();
EXTENSIONAPI static constexpr auto SplunkRequestChannel = core::PropertyDefinitionBuilder<>::createProperty("Splunk Request Channel")
.withDescription("Identifier of the used request channel.")
.isRequired(true)
.build();
EXTENSIONAPI static constexpr auto SSLContext = core::PropertyDefinitionBuilder<0, 1, 0, 1>::createProperty("SSL Context Service")
.withDescription("The SSL Context Service used to provide client certificate information for TLS/SSL (https) connections.")
.isRequired(false)
.withExclusiveOfProperties({{{"Hostname", "^http:.*$"}}})
.withAllowedTypes({core::className<minifi::controllers::SSLContextService>()})
.build();
.withDescription("Identifier of the used request channel.")
.isRequired(true)
.build();
EXTENSIONAPI static constexpr auto SSLContext = core::PropertyDefinitionBuilder<0, 0, 1>::createProperty("SSL Context Service")
.withDescription("The SSL Context Service used to provide client certificate information for TLS/SSL (https) connections.")
.isRequired(false)
.withExclusiveOfProperties({{{"Hostname", "^http:.*$"}}})
.withAllowedTypes<minifi::controllers::SSLContextService>()
.build();
EXTENSIONAPI static constexpr auto Properties = std::array<core::PropertyReference, 5>{
Hostname,
Port,
Expand Down
4 changes: 2 additions & 2 deletions extensions/standard-processors/processors/GetTCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class GetTCP : public core::Processor {
.withDescription("A comma delimited list of the endpoints to connect to. The format should be <server_address>:<port>.")
.isRequired(true)
.build();
EXTENSIONAPI static constexpr auto SSLContextService = core::PropertyDefinitionBuilder<0, 1>::createProperty("SSL Context Service")
EXTENSIONAPI static constexpr auto SSLContextService = core::PropertyDefinitionBuilder<>::createProperty("SSL Context Service")
.withDescription("SSL Context Service Name")
.withAllowedTypes({core::className<minifi::controllers::SSLContextService>()})
.withAllowedTypes<minifi::controllers::SSLContextService>()
.build();
EXTENSIONAPI static constexpr auto MessageDelimiter = core::PropertyDefinitionBuilder<>::createProperty("Message Delimiter")
.withDescription("Character that denotes the end of the message.")
Expand Down
4 changes: 2 additions & 2 deletions extensions/standard-processors/processors/ListenSyslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ class ListenSyslog : public NetworkListenerProcessor {
.withPropertyType(core::StandardPropertyTypes::UNSIGNED_LONG_TYPE)
.withDefaultValue("10000")
.build();
EXTENSIONAPI static constexpr auto SSLContextService = core::PropertyDefinitionBuilder<0, 1>::createProperty("SSL Context Service")
EXTENSIONAPI static constexpr auto SSLContextService = core::PropertyDefinitionBuilder<>::createProperty("SSL Context Service")
.withDescription("The Controller Service to use in order to obtain an SSL Context. If this property is set, messages will be received over a secure connection. "
"This Property is only considered if the <Protocol> Property has a value of \"TCP\".")
.withAllowedTypes({core::className<minifi::controllers::SSLContextService>()})
.withAllowedTypes<minifi::controllers::SSLContextService>()
.build();
EXTENSIONAPI static constexpr auto ClientAuth = core::PropertyDefinitionBuilder<magic_enum::enum_count<utils::net::ClientAuthOption>()>::createProperty("Client Auth")
.withDescription("The client authentication policy to use for the SSL Context. Only used if an SSL Context Service is provided.")
Expand Down
4 changes: 2 additions & 2 deletions extensions/standard-processors/processors/ListenTCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class ListenTCP : public NetworkListenerProcessor {
.withDefaultValue("10000")
.isRequired(true)
.build();
EXTENSIONAPI static constexpr auto SSLContextService = core::PropertyDefinitionBuilder<0, 1>::createProperty("SSL Context Service")
EXTENSIONAPI static constexpr auto SSLContextService = core::PropertyDefinitionBuilder<>::createProperty("SSL Context Service")
.withDescription("The Controller Service to use in order to obtain an SSL Context. If this property is set, messages will be received over a secure connection.")
.withAllowedTypes({core::className<minifi::controllers::SSLContextService>()})
.withAllowedTypes<minifi::controllers::SSLContextService>()
.build();
EXTENSIONAPI static constexpr auto ClientAuth = core::PropertyDefinitionBuilder<magic_enum::enum_count<utils::net::ClientAuthOption>()>::createProperty("Client Auth")
.withDescription("The client authentication policy to use for the SSL Context. Only used if an SSL Context Service is provided.")
Expand Down
2 changes: 1 addition & 1 deletion extensions/standard-processors/processors/PutFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PutFile : public core::Processor {
.withAllowedValues({CONFLICT_RESOLUTION_STRATEGY_FAIL, CONFLICT_RESOLUTION_STRATEGY_IGNORE, CONFLICT_RESOLUTION_STRATEGY_REPLACE})
.withDefaultValue(CONFLICT_RESOLUTION_STRATEGY_FAIL)
.build();
EXTENSIONAPI static constexpr auto CreateDirs = core::PropertyDefinitionBuilder<0, 0, 1>::createProperty("Create Missing Directories")
EXTENSIONAPI static constexpr auto CreateDirs = core::PropertyDefinitionBuilder<0, 1>::createProperty("Create Missing Directories")
.withDescription("If true, then missing destination directories will be created. If false, flowfiles are penalized and sent to failure.")
.withDefaultValue("true")
.isRequired(true)
Expand Down
Loading

0 comments on commit fbd69e7

Please sign in to comment.