Skip to content

Commit

Permalink
chore: NiFi Ldes Client Processor properties are less overwhelming (#722
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jobulcke authored Nov 27, 2024
1 parent 1d27232 commit 7975226
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/_ldi-nifi/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The processors can be imported into a NiFi docker instance via volume binding:
````yaml
services:
nifi:
image: apache/nifi:2.0.0-M2
image: apache/nifi:2.0.0
environment:
SINGLE_USER_CREDENTIALS_USERNAME: admin
SINGLE_USER_CREDENTIALS_PASSWORD: ctsBtRBKHRAx69EqUghvvgEvjnaLjFEB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private PersistenceProperties() {
.description("Postgres database url formatted as \"jdbc:postgresql://localhost:5432/postgres\"")
.required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.dependsOn(STATE_PERSISTENCE_STRATEGY, StatePersistenceStrategy.POSTGRES.name())
.build();

public static final PropertyDescriptor POSTGRES_USERNAME = new PropertyDescriptor.Builder()
Expand All @@ -39,6 +40,7 @@ private PersistenceProperties() {
.description("Username used to connect to the postgres database")
.required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.dependsOn(STATE_PERSISTENCE_STRATEGY, StatePersistenceStrategy.POSTGRES.name())
.build();

public static final PropertyDescriptor POSTGRES_PASSWORD = new PropertyDescriptor.Builder()
Expand All @@ -47,6 +49,8 @@ private PersistenceProperties() {
.description("Password used to connect to the postgres database")
.required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.sensitive(true)
.dependsOn(STATE_PERSISTENCE_STRATEGY, StatePersistenceStrategy.POSTGRES.name())
.build();

public static final PropertyDescriptor SQLITE_DIRECTORY = new PropertyDescriptor.Builder()
Expand All @@ -55,12 +59,15 @@ private PersistenceProperties() {
.description("Sqlite database directory where the '.db' file can be stored")
.required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.dependsOn(STATE_PERSISTENCE_STRATEGY, StatePersistenceStrategy.SQLITE.name())
.build();

public static final PropertyDescriptor KEEP_STATE = new PropertyDescriptor.Builder()
.name("KEEP_STATE")
.displayName("Keep state when the processor is removed from the flow")
.displayName("Keep state")
.description("Keep state when the processor is removed from the flow")
.required(false)
.allowableValues(TRUE.toString(), FALSE.toString())
.addValidator(StandardValidators.BOOLEAN_VALIDATOR)
.defaultValue(FALSE.toString())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,24 @@ public class RequestExecutorProperties {
private RequestExecutorProperties() {
}

public static final PropertyDescriptor AUTHORIZATION_STRATEGY = new PropertyDescriptor.Builder()
.name("AUTHORIZATION_STRATEGY")
.displayName("Authorization strategy")
.description("Authorization strategy for the internal http client.")
.required(true)
.defaultValue(AuthStrategy.NO_AUTH.name())
.allowableValues(Arrays.stream(AuthStrategy.values()).map(Enum::name).collect(Collectors.toSet()))
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.build();

public static final PropertyDescriptor API_KEY_HEADER_PROPERTY = new PropertyDescriptor.Builder()
.name("API_KEY_HEADER_PROPERTY")
.displayName("API-KEY header property")
.description("API header that should be used for the API key")
.required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.defaultValue("X-API-KEY")
.dependsOn(AUTHORIZATION_STRATEGY, AuthStrategy.API_KEY.name())
.build();

public static final PropertyDescriptor API_KEY_PROPERTY = new PropertyDescriptor.Builder()
Expand All @@ -33,6 +44,7 @@ private RequestExecutorProperties() {
.description("API key that should be used to access the API.")
.required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.dependsOn(AUTHORIZATION_STRATEGY, AuthStrategy.API_KEY.name())
.build();

public static final PropertyDescriptor OAUTH_CLIENT_ID = new PropertyDescriptor.Builder()
Expand All @@ -41,6 +53,7 @@ private RequestExecutorProperties() {
.description("Client id used for Oauth2 client credentials flow")
.required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.dependsOn(AUTHORIZATION_STRATEGY, AuthStrategy.OAUTH2_CLIENT_CREDENTIALS.name())
.build();

public static final PropertyDescriptor OAUTH_CLIENT_SECRET = new PropertyDescriptor.Builder()
Expand All @@ -50,6 +63,7 @@ private RequestExecutorProperties() {
.sensitive(true)
.required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.dependsOn(AUTHORIZATION_STRATEGY, AuthStrategy.OAUTH2_CLIENT_CREDENTIALS.name())
.build();

public static final PropertyDescriptor OAUTH_TOKEN_ENDPOINT = new PropertyDescriptor.Builder()
Expand All @@ -58,6 +72,7 @@ private RequestExecutorProperties() {
.description("Token endpoint used for Oauth2 client credentials flow.")
.required(false)
.addValidator(StandardValidators.URL_VALIDATOR)
.dependsOn(AUTHORIZATION_STRATEGY, AuthStrategy.OAUTH2_CLIENT_CREDENTIALS.name())
.build();

public static final PropertyDescriptor OAUTH_SCOPE = new PropertyDescriptor.Builder()
Expand All @@ -66,16 +81,7 @@ private RequestExecutorProperties() {
.description("Scope used for Oauth2 client credentials flow.")
.required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.build();

public static final PropertyDescriptor AUTHORIZATION_STRATEGY = new PropertyDescriptor.Builder()
.name("AUTHORIZATION_STRATEGY")
.displayName("Authorization strategy")
.description("Authorization strategy for the internal http client.")
.required(true)
.defaultValue(AuthStrategy.NO_AUTH.name())
.allowableValues(Arrays.stream(AuthStrategy.values()).map(Enum::name).collect(Collectors.toSet()))
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.dependsOn(AUTHORIZATION_STRATEGY, AuthStrategy.OAUTH2_CLIENT_CREDENTIALS.name())
.build();

public static final PropertyDescriptor RETRIES_ENABLED = new PropertyDescriptor.Builder()
Expand All @@ -95,6 +101,7 @@ private RequestExecutorProperties() {
.required(false)
.defaultValue(String.valueOf(5))
.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR)
.dependsOn(RETRIES_ENABLED, TRUE.toString())
.build();

public static final PropertyDescriptor STATUSES_TO_RETRY = new PropertyDescriptor.Builder()
Expand All @@ -103,6 +110,7 @@ private RequestExecutorProperties() {
.description("Custom comma seperated list of http status codes that can trigger a retry in the http client.")
.required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.dependsOn(RETRIES_ENABLED, TRUE.toString())
.build();

public static String getApiKeyHeader(final ProcessContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ private LdesProcessorProperties() {
public static final PropertyDescriptor USE_LATEST_STATE_FILTER = new PropertyDescriptor.Builder()
.name("USE_LATEST_STATE_FILTER")
.displayName("Use latest state filter")
.description("Use filter to only process the latest state and so all older versions are ignored, only when 'Use version materialisation' is set to true")
.description("Use filter to only process the latest state and so all older versions are ignored")
.required(false)
.addValidator(StandardValidators.BOOLEAN_VALIDATOR)
.defaultValue(TRUE.toString())
.dependsOn(USE_VERSION_MATERIALISATION, TRUE.toString())
.build();

public static List<String> getDataSourceUrl(final ProcessContext context) {
Expand Down

0 comments on commit 7975226

Please sign in to comment.