use of de.codecentric.boot.admin.notify.filter.NotificationFilter in project spring-boot-admin by codecentric.
the class NotificationFilterController method addFilter.
@RequestMapping(method = { RequestMethod.POST }, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseEntity<?> addFilter(@RequestParam(name = "id", required = false) String id, @RequestParam(name = "name", required = false) String name, @RequestParam(name = "ttl", required = false, defaultValue = "-1") long ttl) {
if (hasText(id) || hasText(name)) {
NotificationFilter filter = createFilter(id, name, ttl);
String filterId = filteringNotifier.addFilter(filter);
return ResponseEntity.ok(Collections.singletonMap(filterId, filter));
} else {
return ResponseEntity.badRequest().body("Either 'id' or 'name' must be set");
}
}
use of de.codecentric.boot.admin.notify.filter.NotificationFilter in project spring-boot-admin by codecentric.
the class NotificationFilterController method createFilter.
private NotificationFilter createFilter(String id, String name, long ttl) {
long expiry = ttl > 0L ? System.currentTimeMillis() + ttl : ttl;
NotificationFilter filter = hasText(id) ? new ApplicationIdNotificationFilter(id, expiry) : new ApplicationNameNotificationFilter(name, expiry);
return filter;
}
Aggregations