-
Notifications
You must be signed in to change notification settings - Fork 4
/
TppLogSourceConfig.java
74 lines (56 loc) · 3.62 KB
/
TppLogSourceConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.opencredo.connect.venafi.tpp.log;
import org.apache.kafka.common.config.AbstractConfig;
import org.apache.kafka.common.config.ConfigDef;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
public class TppLogSourceConfig extends AbstractConfig {
private static final Logger log = LoggerFactory.getLogger(TppLogSourceConfig.class);
public static final String BASE_URL_CONFIG = "venafi.base.url";
private static final String BASE_URL_DOC = "URL to VENAFI VEDSDK API";
public static final String USERNAME_CONFIG = "venafi.username";
private static final String USERNAME_DOC = "The username to use with the API.";
public static final String PASSWORD_CONFIG = "venafi.password";
private static final String PASSWORD_DOC = "The password to use with the API.";
public static final String SCOPE_CONFIG = "venafi.scope";
private static final String SCOPE_DOC = "The scope to use with the API.";
public static final String CLIENT_ID_CONFIG = "venafi.client_id";
private static final String CLIENT_ID_DOC = "The Application ID to use with the API.";
public static final String TOPIC_CONFIG = "venafi.topic";
private static final String TOPIC_DEFAULT = "VENAFI-LOGS";
private static final String TOPIC_DOC = "Topic to publish VENAFI log data to.";
public static final String BATCH_SIZE = "venafi.batch.size";
private static final int BATCH_SIZE_DEFAULT = 100;
private static final String BATCH_SIZE_DOC = "Window of data to pull from log API.";
public static final String POLL_INTERVAL = "venafi.poll.interval";
private static final int POLL_INTERVAL_DEFAULT = 1000;
private static final String POLL_INTERVAL_DOC = "Poll interval in milliseconds.";
public static final int MAX_BATCH_SIZE = 10_000;
public static final int MIN_BATCH_SIZE = 2;
public static final ConfigDef CONFIG_DEF = new ConfigDef()
.define(BASE_URL_CONFIG, ConfigDef.Type.STRING, ConfigDef.NO_DEFAULT_VALUE, new NonEmptyStringWithoutControlChars(), ConfigDef.Importance.HIGH, BASE_URL_DOC)
.define(TOPIC_CONFIG, ConfigDef.Type.STRING, TOPIC_DEFAULT, new NonEmptyStringWithoutControlChars(), ConfigDef.Importance.HIGH, TOPIC_DOC)
.define(BATCH_SIZE, ConfigDef.Type.INT, BATCH_SIZE_DEFAULT, ConfigDef.Range.between(MIN_BATCH_SIZE, MAX_BATCH_SIZE), ConfigDef.Importance.LOW, BATCH_SIZE_DOC)
.define(POLL_INTERVAL, ConfigDef.Type.INT, POLL_INTERVAL_DEFAULT, ConfigDef.Importance.LOW, POLL_INTERVAL_DOC)
.define(USERNAME_CONFIG, ConfigDef.Type.STRING, ConfigDef.Importance.HIGH, USERNAME_DOC)
.define(PASSWORD_CONFIG, ConfigDef.Type.STRING, ConfigDef.Importance.HIGH, PASSWORD_DOC)
.define(SCOPE_CONFIG, ConfigDef.Type.STRING, ConfigDef.Importance.MEDIUM, SCOPE_DOC)
.define(CLIENT_ID_CONFIG, ConfigDef.Type.STRING, ConfigDef.Importance.HIGH, CLIENT_ID_DOC);
public TppLogSourceConfig(Map<String, ?> props) {
super(CONFIG_DEF, props);
}
Map<String, String> returnPropertiesWithDefaultsValuesIfMissing() {
Map<String, ?> uncastProperties = this.values();
Map<String, String> config = new HashMap<>(uncastProperties.size());
uncastProperties.forEach((key, valueToBeCast) -> config.put(key, valueToBeCast.toString()));
return config;
}
}
final class NonEmptyStringWithoutControlChars extends ConfigDef.NonEmptyStringWithoutControlChars {
//Only here to create nice human readable for exporting to documentation.
@Override
public String toString() {
return "non-empty string and no ISO control characters";
}
}