software.amazon.awscdk.services.events.targets.SnsTopic Maven / Gradle / Ivy
Show all versions of events-targets Show documentation
package software.amazon.awscdk.services.events.targets;
/**
* Use an SNS topic as a target for Amazon EventBridge rules.
*
* Example:
*
*
* // publish to an SNS topic every time code is committed
* // to a CodeCommit repository
* repository.onCommit("onCommit", OnCommitOptions.builder().target(new SnsTopic(topic)).build());
*
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.63.2 (build a8a8833)", date = "2022-08-17T17:31:21.309Z")
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.events.targets.$Module.class, fqn = "@aws-cdk/aws-events-targets.SnsTopic")
public class SnsTopic extends software.amazon.jsii.JsiiObject implements software.amazon.awscdk.services.events.IRuleTarget {
protected SnsTopic(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
}
protected SnsTopic(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) {
super(initializationMode);
}
/**
* @param topic This parameter is required.
* @param props
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public SnsTopic(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.sns.ITopic topic, final @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.events.targets.SnsTopicProps props) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(topic, "topic is required"), props });
}
/**
* @param topic This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public SnsTopic(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.sns.ITopic topic) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(topic, "topic is required") });
}
/**
* Returns a RuleTarget that can be used to trigger this SNS topic as a result from an EventBridge event.
*
* @see https://docs.aws.amazon.com/eventbridge/latest/userguide/resource-based-policies-eventbridge.html#sns-permissions
* @param _rule This parameter is required.
* @param _id
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@Override
public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.events.RuleTargetConfig bind(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.events.IRule _rule, final @org.jetbrains.annotations.Nullable java.lang.String _id) {
return software.amazon.jsii.Kernel.call(this, "bind", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.events.RuleTargetConfig.class), new Object[] { java.util.Objects.requireNonNull(_rule, "_rule is required"), _id });
}
/**
* Returns a RuleTarget that can be used to trigger this SNS topic as a result from an EventBridge event.
*
* @see https://docs.aws.amazon.com/eventbridge/latest/userguide/resource-based-policies-eventbridge.html#sns-permissions
* @param _rule This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@Override
public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.events.RuleTargetConfig bind(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.events.IRule _rule) {
return software.amazon.jsii.Kernel.call(this, "bind", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.events.RuleTargetConfig.class), new Object[] { java.util.Objects.requireNonNull(_rule, "_rule is required") });
}
/**
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.sns.ITopic getTopic() {
return software.amazon.jsii.Kernel.get(this, "topic", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.sns.ITopic.class));
}
/**
* A fluent builder for {@link software.amazon.awscdk.services.events.targets.SnsTopic}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static final class Builder implements software.amazon.jsii.Builder {
/**
* @return a new instance of {@link Builder}.
* @param topic This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static Builder create(final software.amazon.awscdk.services.sns.ITopic topic) {
return new Builder(topic);
}
private final software.amazon.awscdk.services.sns.ITopic topic;
private software.amazon.awscdk.services.events.targets.SnsTopicProps.Builder props;
private Builder(final software.amazon.awscdk.services.sns.ITopic topic) {
this.topic = topic;
}
/**
* The message to send to the topic.
*
* Default: the entire EventBridge event
*
* @return {@code this}
* @param message The message to send to the topic. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder message(final software.amazon.awscdk.services.events.RuleTargetInput message) {
this.props().message(message);
return this;
}
/**
* @returns a newly built instance of {@link software.amazon.awscdk.services.events.targets.SnsTopic}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@Override
public software.amazon.awscdk.services.events.targets.SnsTopic build() {
return new software.amazon.awscdk.services.events.targets.SnsTopic(
this.topic,
this.props != null ? this.props.build() : null
);
}
private software.amazon.awscdk.services.events.targets.SnsTopicProps.Builder props() {
if (this.props == null) {
this.props = new software.amazon.awscdk.services.events.targets.SnsTopicProps.Builder();
}
return this.props;
}
}
}