public static Supplier<Notification> getNotification(String deploymentName, String notificationName, boolean validate) { return () -> { Object notification = ResponseUnwrapper.get(getService().getNotification(deploymentName, notificationName, validate)); return getObjectMapper().convertValue(notification, Notifications.translateNotificationType(notificationName)); }; }
public Notifications getNotifications(String deploymentName) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); Notifications notifications = deploymentConfiguration.getNotifications(); if (notifications == null) { notifications = new Notifications(); deploymentConfiguration.setNotifications(notifications); } return notifications; }
public void setNotification(String deploymentName, Notification notification) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); Notifications notifications = deploymentConfiguration.getNotifications(); switch (notification.getNotificationType()) { case SLACK: notifications.setSlack((SlackNotification) notification); break; case TWILIO: notifications.setTwilio((TwilioNotification) notification); break; default: throw new IllegalArgumentException("Unknown notification type " + notification.getNotificationType()); } }
bindings.put("notifications.enabled", notifications.isEnabled() + ""); SlackNotification slackNotification = notifications.getSlack(); bindings.put("notifications.slack.enabled", slackNotification.isEnabled() + ""); bindings.put("notifications.slack.botName", slackNotification.getBotName()); TwilioNotification twilioNotification = notifications.getTwilio(); bindings.put("notifications.twilio.enabled", twilioNotification.isEnabled() + "");
public void setNotification(String deploymentName, Notification notification) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); Notifications notifications = deploymentConfiguration.getNotifications(); switch (notification.getNotificationType()) { case SLACK: notifications.setSlack((SlackNotification) notification); break; default: throw new IllegalArgumentException("Unknown notification type " + notification.getNotificationType()); } }
public static Supplier<Notification> getNotification(String deploymentName, String notificationName, boolean validate) { return () -> { Object notification = ResponseUnwrapper.get(getService().getNotification(deploymentName, notificationName, validate)); return getObjectMapper().convertValue(notification, Notifications.translateNotificationType(notificationName)); }; }
public Notifications getNotifications(String deploymentName) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); Notifications notifications = deploymentConfiguration.getNotifications(); if (notifications == null) { notifications = new Notifications(); deploymentConfiguration.setNotifications(notifications); } return notifications; }
@RequestMapping(value = "/{notificationName:.+}", method = RequestMethod.PUT) DaemonTask<Halconfig, Void> setNotification(@PathVariable String deploymentName, @PathVariable String notificationName, @ModelAttribute ValidationSettings validationSettings, @RequestBody Object rawNotification) { Notification notification = objectMapper.convertValue( rawNotification, Notifications.translateNotificationType(notificationName) ); return GenericUpdateRequest.<Notification>builder(halconfigParser) .stagePath(halconfigDirectoryStructure.getStagingPath(deploymentName)) .updater(n -> notificationService.setNotification(deploymentName, n)) .validator(() -> notificationService.validateNotification(deploymentName, notificationName)) .description("Edit the " + notificationName + " notification") .build() .execute(validationSettings, notification); } }