software.amazon.awscdk.services.iot.actions.alpha.SnsTopicAction Maven / Gradle / Ivy
Show all versions of iot-actions-alpha Show documentation
package software.amazon.awscdk.services.iot.actions.alpha;
/**
* (experimental) The action to write the data from an MQTT message to an Amazon SNS topic.
*
* Example:
*
*
* import software.amazon.awscdk.services.sns.*;
* Topic topic = new Topic(this, "MyTopic");
* TopicRule topicRule = TopicRule.Builder.create(this, "TopicRule")
* .sql(IotSql.fromStringAsVer20160323("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'"))
* .actions(List.of(
* SnsTopicAction.Builder.create(topic)
* .messageFormat(SnsActionMessageFormat.JSON)
* .build()))
* .build();
*
*
* @see https://docs.aws.amazon.com/iot/latest/developerguide/sns-rule-action.html
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.102.0 (build e354887)", date = "2024-09-06T01:36:38.343Z")
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.iot.actions.alpha.$Module.class, fqn = "@aws-cdk/aws-iot-actions-alpha.SnsTopicAction")
public class SnsTopicAction extends software.amazon.jsii.JsiiObject implements software.amazon.awscdk.services.iot.alpha.IAction {
protected SnsTopicAction(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
}
protected SnsTopicAction(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) {
super(initializationMode);
}
/**
* @param topic The Amazon SNS topic to publish data on. This parameter is required.
* @param props Properties to configure the action.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public SnsTopicAction(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.sns.ITopic topic, final @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.iot.actions.alpha.SnsTopicActionProps 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 The Amazon SNS topic to publish data on. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public SnsTopicAction(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") });
}
/**
* (experimental) A fluent builder for {@link software.amazon.awscdk.services.iot.actions.alpha.SnsTopicAction}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
/**
* @return a new instance of {@link Builder}.
* @param topic The Amazon SNS topic to publish data on. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
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.iot.actions.alpha.SnsTopicActionProps.Builder props;
private Builder(final software.amazon.awscdk.services.sns.ITopic topic) {
this.topic = topic;
}
/**
* (experimental) The IAM role that allows access to AWS service.
*
* Default: a new role will be created
*
* @return {@code this}
* @param role The IAM role that allows access to AWS service. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder role(final software.amazon.awscdk.services.iam.IRole role) {
this.props().role(role);
return this;
}
/**
* (experimental) The message format of the message to publish.
*
* SNS uses this setting to determine if the payload should be parsed and relevant platform-specific bits of the payload should be extracted.
*
* Default: SnsActionMessageFormat.RAW
*
* @return {@code this}
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-message-and-json-formats.html
* @param messageFormat The message format of the message to publish. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder messageFormat(final software.amazon.awscdk.services.iot.actions.alpha.SnsActionMessageFormat messageFormat) {
this.props().messageFormat(messageFormat);
return this;
}
/**
* @return a newly built instance of {@link software.amazon.awscdk.services.iot.actions.alpha.SnsTopicAction}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public software.amazon.awscdk.services.iot.actions.alpha.SnsTopicAction build() {
return new software.amazon.awscdk.services.iot.actions.alpha.SnsTopicAction(
this.topic,
this.props != null ? this.props.build() : null
);
}
private software.amazon.awscdk.services.iot.actions.alpha.SnsTopicActionProps.Builder props() {
if (this.props == null) {
this.props = new software.amazon.awscdk.services.iot.actions.alpha.SnsTopicActionProps.Builder();
}
return this.props;
}
}
}