Search in sources :

Example 1 with Entry

use of io.hops.hopsworks.api.alert.Entry in project hopsworks by logicalclocks.

the class ReceiverBuilder method toEmailConfig.

private EmailConfig toEmailConfig(PostableEmailConfig postableEmailConfigs, Boolean defaultTemplate) {
    EmailConfig emailConfig = new EmailConfig(postableEmailConfigs.getTo()).withFrom(postableEmailConfigs.getFrom()).withSmarthost(postableEmailConfigs.getSmarthost()).withHello(postableEmailConfigs.getHello()).withAuthIdentity(postableEmailConfigs.getAuthIdentity()).withAuthPassword(postableEmailConfigs.getAuthPassword()).withAuthSecret(postableEmailConfigs.getAuthSecret()).withAuthUsername(postableEmailConfigs.getAuthUsername()).withHtml(postableEmailConfigs.getHtml()).withText(postableEmailConfigs.getText()).withRequireTls(postableEmailConfigs.getRequireTls()).withTlsConfig(postableEmailConfigs.getTlsConfig()).withSendResolved(postableEmailConfigs.getSendResolved());
    if (postableEmailConfigs.getHeaders() != null && !postableEmailConfigs.getHeaders().isEmpty()) {
        Map<String, String> headers;
        headers = postableEmailConfigs.getHeaders().stream().filter(entry -> entry != null && entry.getKey() != null && entry.getValue() != null).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
        emailConfig.setHeaders(headers);
    }
    if (defaultTemplate && Strings.isNullOrEmpty(emailConfig.getHtml())) {
        emailConfig.setHtml(Constants.DEFAULT_EMAIL_HTML);
    }
    return emailConfig;
}
Also used : Entry(io.hops.hopsworks.api.alert.Entry) EmailConfig(io.hops.hopsworks.alerting.config.dto.EmailConfig)

Example 2 with Entry

use of io.hops.hopsworks.api.alert.Entry in project hopsworks by logicalclocks.

the class ManagementResource method toInhibitRule.

private InhibitRule toInhibitRule(PostableInhibitRulesDTO p) {
    InhibitRule inhibitRule = new InhibitRule();
    inhibitRule.setEqual(p.getEqual());
    if (p.getSourceMatch() != null && !p.getSourceMatch().isEmpty()) {
        inhibitRule.setSourceMatch(p.getSourceMatch().stream().filter(entry -> entry != null && entry.getKey() != null && entry.getValue() != null).collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
    }
    if (p.getSourceMatchRe() != null && !p.getSourceMatchRe().isEmpty()) {
        inhibitRule.setSourceMatchRe(p.getSourceMatchRe().stream().filter(entry -> entry != null && entry.getKey() != null && entry.getValue() != null).collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
    }
    if (p.getTargetMatch() != null && !p.getTargetMatch().isEmpty()) {
        inhibitRule.setTargetMatch(p.getTargetMatch().stream().filter(entry -> entry != null && entry.getKey() != null && entry.getValue() != null).collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
    }
    if (p.getTargetMatchRe() != null && !p.getTargetMatchRe().isEmpty()) {
        inhibitRule.setTargetMatchRe(p.getTargetMatchRe().stream().filter(entry -> entry != null && entry.getKey() != null && entry.getValue() != null).collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
    }
    return inhibitRule;
}
Also used : Entry(io.hops.hopsworks.api.alert.Entry) InhibitRule(io.hops.hopsworks.alerting.config.dto.InhibitRule)

Aggregations

Entry (io.hops.hopsworks.api.alert.Entry)2 EmailConfig (io.hops.hopsworks.alerting.config.dto.EmailConfig)1 InhibitRule (io.hops.hopsworks.alerting.config.dto.InhibitRule)1