io.cloudshiftdev.awscdk.services.sns.subscriptions.SmsSubscription.kt Maven / Gradle / Ivy
The newest version!
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")
package io.cloudshiftdev.awscdk.services.sns.subscriptions
import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.common.CdkObject
import io.cloudshiftdev.awscdk.services.sns.FilterOrPolicy
import io.cloudshiftdev.awscdk.services.sns.ITopic
import io.cloudshiftdev.awscdk.services.sns.ITopicSubscription
import io.cloudshiftdev.awscdk.services.sns.SubscriptionFilter
import io.cloudshiftdev.awscdk.services.sns.TopicSubscriptionConfig
import io.cloudshiftdev.awscdk.services.sqs.IQueue
import kotlin.String
import kotlin.Unit
import kotlin.collections.Map
/**
* Use an sms address as a subscription target.
*
* Example:
*
* ```
* Topic myTopic = new Topic(this, "Topic");
* myTopic.addSubscription(new SmsSubscription("+15551231234"));
* ```
*/
public open class SmsSubscription(
cdkObject: software.amazon.awscdk.services.sns.subscriptions.SmsSubscription,
) : CdkObject(cdkObject),
ITopicSubscription {
public constructor(phoneNumber: String) :
this(software.amazon.awscdk.services.sns.subscriptions.SmsSubscription(phoneNumber)
)
public constructor(phoneNumber: String, props: SmsSubscriptionProps) :
this(software.amazon.awscdk.services.sns.subscriptions.SmsSubscription(phoneNumber,
props.let(SmsSubscriptionProps.Companion::unwrap))
)
public constructor(phoneNumber: String, props: SmsSubscriptionProps.Builder.() -> Unit) :
this(phoneNumber, SmsSubscriptionProps(props)
)
/**
* Returns a configuration used to subscribe to an SNS topic.
*
* @param _topic
*/
public override fun bind(topic: ITopic): TopicSubscriptionConfig =
unwrap(this).bind(topic.let(ITopic.Companion::unwrap)).let(TopicSubscriptionConfig::wrap)
/**
* A fluent builder for [io.cloudshiftdev.awscdk.services.sns.subscriptions.SmsSubscription].
*/
@CdkDslMarker
public interface Builder {
/**
* Queue to be used as dead letter queue.
*
* If not passed no dead letter queue is enabled.
*
* Default: - No dead letter queue enabled.
*
* @param deadLetterQueue Queue to be used as dead letter queue.
*/
public fun deadLetterQueue(deadLetterQueue: IQueue)
/**
* The filter policy.
*
* Default: - all messages are delivered
*
* @param filterPolicy The filter policy.
*/
public fun filterPolicy(filterPolicy: Map)
/**
* The filter policy that is applied on the message body.
*
* To apply a filter policy to the message attributes, use `filterPolicy`. A maximum of one of
* `filterPolicyWithMessageBody` and `filterPolicy` may be used.
*
* Default: - all messages are delivered
*
* @param filterPolicyWithMessageBody The filter policy that is applied on the message body.
*/
public fun filterPolicyWithMessageBody(filterPolicyWithMessageBody: Map)
}
private class BuilderImpl(
phoneNumber: String,
) : Builder {
private val cdkBuilder:
software.amazon.awscdk.services.sns.subscriptions.SmsSubscription.Builder =
software.amazon.awscdk.services.sns.subscriptions.SmsSubscription.Builder.create(phoneNumber)
/**
* Queue to be used as dead letter queue.
*
* If not passed no dead letter queue is enabled.
*
* Default: - No dead letter queue enabled.
*
* @param deadLetterQueue Queue to be used as dead letter queue.
*/
override fun deadLetterQueue(deadLetterQueue: IQueue) {
cdkBuilder.deadLetterQueue(deadLetterQueue.let(IQueue.Companion::unwrap))
}
/**
* The filter policy.
*
* Default: - all messages are delivered
*
* @param filterPolicy The filter policy.
*/
override fun filterPolicy(filterPolicy: Map) {
cdkBuilder.filterPolicy(filterPolicy.mapValues{SubscriptionFilter.unwrap(it.value)})
}
/**
* The filter policy that is applied on the message body.
*
* To apply a filter policy to the message attributes, use `filterPolicy`. A maximum of one of
* `filterPolicyWithMessageBody` and `filterPolicy` may be used.
*
* Default: - all messages are delivered
*
* @param filterPolicyWithMessageBody The filter policy that is applied on the message body.
*/
override
fun filterPolicyWithMessageBody(filterPolicyWithMessageBody: Map) {
cdkBuilder.filterPolicyWithMessageBody(filterPolicyWithMessageBody.mapValues{FilterOrPolicy.unwrap(it.value)})
}
public fun build(): software.amazon.awscdk.services.sns.subscriptions.SmsSubscription =
cdkBuilder.build()
}
public companion object {
public operator fun invoke(phoneNumber: String, block: Builder.() -> Unit = {}):
SmsSubscription {
val builderImpl = BuilderImpl(phoneNumber)
return SmsSubscription(builderImpl.apply(block).build())
}
internal fun wrap(cdkObject: software.amazon.awscdk.services.sns.subscriptions.SmsSubscription):
SmsSubscription = SmsSubscription(cdkObject)
internal fun unwrap(wrapped: SmsSubscription):
software.amazon.awscdk.services.sns.subscriptions.SmsSubscription = wrapped.cdkObject as
software.amazon.awscdk.services.sns.subscriptions.SmsSubscription
}
}