java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.codestarnotifications.NotificationRule
All Implemented Interfaces:
IConstruct, IDependable, IResource, INotificationRule, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:29:55.921Z") @Stability(Stable) public class NotificationRule extends Resource implements INotificationRule
A new notification rule.

Example:

 import software.amazon.awscdk.services.codestarnotifications.*;
 import software.amazon.awscdk.services.codebuild.*;
 import software.amazon.awscdk.services.sns.*;
 import software.amazon.awscdk.services.chatbot.*;
 PipelineProject project = new PipelineProject(this, "MyProject");
 Topic topic = new Topic(this, "MyTopic1");
 SlackChannelConfiguration slack = SlackChannelConfiguration.Builder.create(this, "MySlackChannel")
         .slackChannelConfigurationName("YOUR_CHANNEL_NAME")
         .slackWorkspaceId("YOUR_SLACK_WORKSPACE_ID")
         .slackChannelId("YOUR_SLACK_CHANNEL_ID")
         .build();
 NotificationRule rule = NotificationRule.Builder.create(this, "NotificationRule")
         .source(project)
         .events(List.of("codebuild-project-build-state-succeeded", "codebuild-project-build-state-failed"))
         .targets(List.of(topic))
         .build();
 rule.addTarget(slack);
 
  • Constructor Details

    • NotificationRule

      protected NotificationRule(software.amazon.jsii.JsiiObjectRef objRef)
    • NotificationRule

      protected NotificationRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • NotificationRule

      @Stability(Stable) public NotificationRule(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull NotificationRuleProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromNotificationRuleArn

      @Stability(Stable) @NotNull public static INotificationRule fromNotificationRuleArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String notificationRuleArn)
      Import an existing notification rule provided an ARN.

      Parameters:
      scope - The parent creating construct. This parameter is required.
      id - The construct's name. This parameter is required.
      notificationRuleArn - Notification rule ARN (i.e. arn:aws:codestar-notifications:::notificationrule/01234abcde). This parameter is required.
    • addTarget

      @Stability(Stable) @NotNull public Boolean addTarget(@NotNull INotificationRuleTarget target)
      Adds target to notification rule.

      Specified by:
      addTarget in interface INotificationRule
      Parameters:
      target - The SNS topic or AWS Chatbot Slack target. This parameter is required.
      Returns:
      boolean - return true if it had any effect
    • getNotificationRuleArn

      @Stability(Stable) @NotNull public String getNotificationRuleArn()
      The ARN of the notification rule (i.e. arn:aws:codestar-notifications:::notificationrule/01234abcde).
      Specified by:
      getNotificationRuleArn in interface INotificationRule