use of org.graylog2.plugin.configuration.fields.TextField in project graylog2-server by Graylog2.
the class AvailableAlarmCallbackSummaryResponse method extractRequestedConfiguration.
public List<RequestedConfigurationField> extractRequestedConfiguration(Map<String, Map<String, Object>> config) {
List<RequestedConfigurationField> result = Lists.newArrayList();
List<RequestedConfigurationField> booleanFields = Lists.newArrayList();
for (Map.Entry<String, Map<String, Object>> entry : config.entrySet()) {
try {
String fieldType = (String) entry.getValue().get("type");
switch(fieldType) {
case "text":
result.add(new TextField(entry));
continue;
case "number":
result.add(new NumberField(entry));
continue;
case "boolean":
booleanFields.add(new BooleanField(entry));
continue;
case "dropdown":
result.add(new DropdownField(entry));
continue;
default:
LOG.info("Unknown field type [{}].", fieldType);
}
} catch (Exception e) {
LOG.error("Skipping invalid configuration field [" + entry.getKey() + "]", e);
}
}
result.addAll(booleanFields);
return result;
}
use of org.graylog2.plugin.configuration.fields.TextField in project graylog2-server by Graylog2.
the class ConfigurationRequestTest method addFieldAppendsFieldAtTheEnd.
@Test
public void addFieldAppendsFieldAtTheEnd() throws Exception {
int numberOfFields = 5;
for (int i = 0; i < numberOfFields; i++) {
configurationRequest.addField(new TextField("field" + i, "humanName", "defaultValue", "description"));
}
assertThat(configurationRequest.getFields().keySet()).containsSequence("field0", "field1", "field2", "field3", "field4");
}
use of org.graylog2.plugin.configuration.fields.TextField in project graylog2-server by Graylog2.
the class ConfigurationRequestTest method putAllRetainsOrder.
@Test
public void putAllRetainsOrder() throws Exception {
final ImmutableMap<String, ConfigurationField> fields = ImmutableMap.<String, ConfigurationField>of("field1", new TextField("field1", "humanName", "defaultValue", "description"), "field2", new TextField("field2", "humanName", "defaultValue", "description"), "field3", new TextField("field3", "humanName", "defaultValue", "description"));
configurationRequest.putAll(fields);
assertThat(configurationRequest.getFields().keySet()).containsSequence("field1", "field2", "field3");
}
use of org.graylog2.plugin.configuration.fields.TextField in project graylog2-server by Graylog2.
the class EmailAlarmCallback method getConfigurationRequest.
// I am truly sorry about this, but leaking the user list is not okay...
private ConfigurationRequest getConfigurationRequest(Map<String, String> userNames) {
ConfigurationRequest configurationRequest = new ConfigurationRequest();
configurationRequest.addField(new TextField("sender", "Sender", "graylog@example.org", "The sender of sent out mail alerts", ConfigurationField.Optional.OPTIONAL));
configurationRequest.addField(new TextField("subject", "E-Mail Subject", "Graylog alert for stream: ${stream.title}: ${check_result.resultDescription}", "The subject of sent out mail alerts", ConfigurationField.Optional.NOT_OPTIONAL));
configurationRequest.addField(new TextField("body", "E-Mail Body", FormattedEmailAlertSender.bodyTemplate, "The template to generate the body from", ConfigurationField.Optional.OPTIONAL, TextField.Attribute.TEXTAREA));
configurationRequest.addField(new ListField(CK_USER_RECEIVERS, "User Receivers", Collections.emptyList(), userNames, "Graylog usernames that should receive this alert", ConfigurationField.Optional.OPTIONAL));
configurationRequest.addField(new ListField(CK_EMAIL_RECEIVERS, "E-Mail Receivers", Collections.emptyList(), Collections.emptyMap(), "E-Mail addresses that should receive this alert", ConfigurationField.Optional.OPTIONAL, ListField.Attribute.ALLOW_CREATE));
return configurationRequest;
}
use of org.graylog2.plugin.configuration.fields.TextField in project graylog2-server by Graylog2.
the class HTTPAlarmCallback method getRequestedConfiguration.
@Override
public ConfigurationRequest getRequestedConfiguration() {
final ConfigurationRequest configurationRequest = new ConfigurationRequest();
configurationRequest.addField(new TextField(CK_URL, "URL", "https://example.org/alerts", "The URL to POST to when an alert is triggered", ConfigurationField.Optional.NOT_OPTIONAL));
return configurationRequest;
}
Aggregations