All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.googlenative.pubsub.v1beta1a.kotlin.Subscription.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.googlenative.pubsub.v1beta1a.kotlin

import com.pulumi.core.Output
import com.pulumi.googlenative.pubsub.v1beta1a.kotlin.outputs.PushConfigResponse
import com.pulumi.googlenative.pubsub.v1beta1a.kotlin.outputs.PushConfigResponse.Companion.toKotlin
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit

/**
 * Builder for [Subscription].
 */
@PulumiTagMarker
public class SubscriptionResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: SubscriptionArgs = SubscriptionArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend SubscriptionArgsBuilder.() -> Unit) {
        val builder = SubscriptionArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): Subscription {
        val builtJavaResource =
            com.pulumi.googlenative.pubsub.v1beta1a.Subscription(
                this.name,
                this.args.toJava(),
                this.opts.toJava(),
            )
        return Subscription(builtJavaResource)
    }
}

/**
 * Creates a subscription on a given topic for a given subscriber. If the subscription already exists, returns ALREADY_EXISTS. If the corresponding topic doesn't exist, returns NOT_FOUND. If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic.
 */
public class Subscription internal constructor(
    override val javaResource: com.pulumi.googlenative.pubsub.v1beta1a.Subscription,
) : KotlinCustomResource(javaResource, SubscriptionMapper) {
    /**
     * For either push or pull delivery, the value is the maximum time after a subscriber receives a message before the subscriber should acknowledge or Nack the message. If the Ack deadline for a message passes without an Ack or a Nack, the Pub/Sub system will eventually redeliver the message. If a subscriber acknowledges after the deadline, the Pub/Sub system may accept the Ack, but it is possible that the message has been already delivered again. Multiple Acks to the message are allowed and will succeed. For push delivery, this value is used to set the request timeout for the call to the push endpoint. For pull delivery, this value is used as the initial value for the Ack deadline. It may be overridden for each message using its corresponding ack_id with ModifyAckDeadline. While a message is outstanding (i.e. it has been delivered to a pull subscriber and the subscriber has not yet Acked or Nacked), the Pub/Sub system will not deliver that message to another pull subscriber (on a best-effort basis).
     */
    public val ackDeadlineSeconds: Output
        get() = javaResource.ackDeadlineSeconds().applyValue({ args0 -> args0 })

    /**
     * Name of the subscription.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * If push delivery is used with this subscription, this field is used to configure it.
     */
    public val pushConfig: Output
        get() = javaResource.pushConfig().applyValue({ args0 -> args0.let({ args0 -> toKotlin(args0) }) })

    /**
     * The name of the topic from which this subscription is receiving messages.
     */
    public val topic: Output
        get() = javaResource.topic().applyValue({ args0 -> args0 })
}

public object SubscriptionMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.googlenative.pubsub.v1beta1a.Subscription::class == javaResource::class

    override fun map(javaResource: Resource): Subscription = Subscription(
        javaResource as
            com.pulumi.googlenative.pubsub.v1beta1a.Subscription,
    )
}

/**
 * @see [Subscription].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Subscription].
 */
public suspend fun subscription(
    name: String,
    block: suspend SubscriptionResourceBuilder.() -> Unit,
): Subscription {
    val builder = SubscriptionResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Subscription].
 * @param name The _unique_ name of the resulting resource.
 */
public fun subscription(name: String): Subscription {
    val builder = SubscriptionResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy