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

com.pulumi.azure.servicebus.kotlin.Subscription.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.servicebus.kotlin

import com.pulumi.azure.servicebus.kotlin.outputs.SubscriptionClientScopedSubscription
import com.pulumi.azure.servicebus.kotlin.outputs.SubscriptionClientScopedSubscription.Companion.toKotlin
import com.pulumi.core.Output
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.Deprecated
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.azure.servicebus.Subscription(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Subscription(builtJavaResource)
    }
}

/**
 * Manages a ServiceBus Subscription.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "tfex-servicebus-subscription",
 *     location: "West Europe",
 * });
 * const exampleNamespace = new azure.servicebus.Namespace("example", {
 *     name: "tfex-servicebus-namespace",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     sku: "Standard",
 *     tags: {
 *         source: "example",
 *     },
 * });
 * const exampleTopic = new azure.servicebus.Topic("example", {
 *     name: "tfex_servicebus_topic",
 *     namespaceId: exampleNamespace.id,
 *     enablePartitioning: true,
 * });
 * const exampleSubscription = new azure.servicebus.Subscription("example", {
 *     name: "tfex_servicebus_subscription",
 *     topicId: exampleTopic.id,
 *     maxDeliveryCount: 1,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="tfex-servicebus-subscription",
 *     location="West Europe")
 * example_namespace = azure.servicebus.Namespace("example",
 *     name="tfex-servicebus-namespace",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     sku="Standard",
 *     tags={
 *         "source": "example",
 *     })
 * example_topic = azure.servicebus.Topic("example",
 *     name="tfex_servicebus_topic",
 *     namespace_id=example_namespace.id,
 *     enable_partitioning=True)
 * example_subscription = azure.servicebus.Subscription("example",
 *     name="tfex_servicebus_subscription",
 *     topic_id=example_topic.id,
 *     max_delivery_count=1)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "tfex-servicebus-subscription",
 *         Location = "West Europe",
 *     });
 *     var exampleNamespace = new Azure.ServiceBus.Namespace("example", new()
 *     {
 *         Name = "tfex-servicebus-namespace",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         Sku = "Standard",
 *         Tags =
 *         {
 *             { "source", "example" },
 *         },
 *     });
 *     var exampleTopic = new Azure.ServiceBus.Topic("example", new()
 *     {
 *         Name = "tfex_servicebus_topic",
 *         NamespaceId = exampleNamespace.Id,
 *         EnablePartitioning = true,
 *     });
 *     var exampleSubscription = new Azure.ServiceBus.Subscription("example", new()
 *     {
 *         Name = "tfex_servicebus_subscription",
 *         TopicId = exampleTopic.Id,
 *         MaxDeliveryCount = 1,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/servicebus"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("tfex-servicebus-subscription"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleNamespace, err := servicebus.NewNamespace(ctx, "example", &servicebus.NamespaceArgs{
 * 			Name:              pulumi.String("tfex-servicebus-namespace"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			Sku:               pulumi.String("Standard"),
 * 			Tags: pulumi.StringMap{
 * 				"source": pulumi.String("example"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleTopic, err := servicebus.NewTopic(ctx, "example", &servicebus.TopicArgs{
 * 			Name:               pulumi.String("tfex_servicebus_topic"),
 * 			NamespaceId:        exampleNamespace.ID(),
 * 			EnablePartitioning: pulumi.Bool(true),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = servicebus.NewSubscription(ctx, "example", &servicebus.SubscriptionArgs{
 * 			Name:             pulumi.String("tfex_servicebus_subscription"),
 * 			TopicId:          exampleTopic.ID(),
 * 			MaxDeliveryCount: pulumi.Int(1),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.servicebus.Namespace;
 * import com.pulumi.azure.servicebus.NamespaceArgs;
 * import com.pulumi.azure.servicebus.Topic;
 * import com.pulumi.azure.servicebus.TopicArgs;
 * import com.pulumi.azure.servicebus.Subscription;
 * import com.pulumi.azure.servicebus.SubscriptionArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("tfex-servicebus-subscription")
 *             .location("West Europe")
 *             .build());
 *         var exampleNamespace = new Namespace("exampleNamespace", NamespaceArgs.builder()
 *             .name("tfex-servicebus-namespace")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .sku("Standard")
 *             .tags(Map.of("source", "example"))
 *             .build());
 *         var exampleTopic = new Topic("exampleTopic", TopicArgs.builder()
 *             .name("tfex_servicebus_topic")
 *             .namespaceId(exampleNamespace.id())
 *             .enablePartitioning(true)
 *             .build());
 *         var exampleSubscription = new Subscription("exampleSubscription", SubscriptionArgs.builder()
 *             .name("tfex_servicebus_subscription")
 *             .topicId(exampleTopic.id())
 *             .maxDeliveryCount(1)
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: tfex-servicebus-subscription
 *       location: West Europe
 *   exampleNamespace:
 *     type: azure:servicebus:Namespace
 *     name: example
 *     properties:
 *       name: tfex-servicebus-namespace
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       sku: Standard
 *       tags:
 *         source: example
 *   exampleTopic:
 *     type: azure:servicebus:Topic
 *     name: example
 *     properties:
 *       name: tfex_servicebus_topic
 *       namespaceId: ${exampleNamespace.id}
 *       enablePartitioning: true
 *   exampleSubscription:
 *     type: azure:servicebus:Subscription
 *     name: example
 *     properties:
 *       name: tfex_servicebus_subscription
 *       topicId: ${exampleTopic.id}
 *       maxDeliveryCount: 1
 * ```
 * 
 * ## Import
 * Service Bus Subscriptions can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:servicebus/subscription:Subscription example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.ServiceBus/namespaces/sbns1/topics/sntopic1/subscriptions/sbsub1
 * ```
 */
public class Subscription internal constructor(
    override val javaResource: com.pulumi.azure.servicebus.Subscription,
) : KotlinCustomResource(javaResource, SubscriptionMapper) {
    /**
     * The idle interval after which the topic is automatically deleted as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations). The minimum duration is `5` minutes or `PT5M`.
     */
    public val autoDeleteOnIdle: Output
        get() = javaResource.autoDeleteOnIdle().applyValue({ args0 -> args0 })

    public val batchedOperationsEnabled: Output
        get() = javaResource.batchedOperationsEnabled().applyValue({ args0 -> args0 })

    /**
     * A `client_scoped_subscription` block as defined below.
     */
    public val clientScopedSubscription: Output?
        get() = javaResource.clientScopedSubscription().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> toKotlin(args0) })
            }).orElse(null)
        })

    /**
     * whether the subscription is scoped to a client id. Defaults to `false`.
     * > **NOTE:** Client Scoped Subscription can only be used for JMS subscription (Java Message Service).
     */
    public val clientScopedSubscriptionEnabled: Output?
        get() = javaResource.clientScopedSubscriptionEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Boolean flag which controls whether the Subscription has dead letter support on filter evaluation exceptions. Defaults to `true`.
     */
    public val deadLetteringOnFilterEvaluationError: Output?
        get() = javaResource.deadLetteringOnFilterEvaluationError().applyValue({ args0 ->
            args0.map({ args0 -> args0 }).orElse(null)
        })

    /**
     * Boolean flag which controls whether the Subscription has dead letter support when a message expires.
     */
    public val deadLetteringOnMessageExpiration: Output?
        get() = javaResource.deadLetteringOnMessageExpiration().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The Default message timespan to live as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations). This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself.
     */
    public val defaultMessageTtl: Output
        get() = javaResource.defaultMessageTtl().applyValue({ args0 -> args0 })

    /**
     * Boolean flag which controls whether the Subscription supports batched operations.
     */
    @Deprecated(
        message = """
  `enable_batched_operations` will be removed in favour of the property `batched_operations_enabled`
      in version 4.0 of the AzureRM Provider.
  """,
    )
    public val enableBatchedOperations: Output
        get() = javaResource.enableBatchedOperations().applyValue({ args0 -> args0 })

    /**
     * The name of a Queue or Topic to automatically forward Dead Letter messages to.
     */
    public val forwardDeadLetteredMessagesTo: Output?
        get() = javaResource.forwardDeadLetteredMessagesTo().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of a Queue or Topic to automatically forward messages to.
     */
    public val forwardTo: Output?
        get() = javaResource.forwardTo().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The lock duration for the subscription as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations). The default value is `1` minute or `P0DT0H1M0S` . The maximum value is `5` minutes or `P0DT0H5M0S` .
     */
    public val lockDuration: Output
        get() = javaResource.lockDuration().applyValue({ args0 -> args0 })

    /**
     * The maximum number of deliveries.
     */
    public val maxDeliveryCount: Output
        get() = javaResource.maxDeliveryCount().applyValue({ args0 -> args0 })

    /**
     * Specifies the name of the ServiceBus Subscription resource. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Boolean flag which controls whether this Subscription supports the concept of a session. Changing this forces a new resource to be created.
     */
    public val requiresSession: Output?
        get() = javaResource.requiresSession().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The status of the Subscription. Possible values are `Active`,`ReceiveDisabled`, or `Disabled`. Defaults to `Active`.
     */
    public val status: Output?
        get() = javaResource.status().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The ID of the ServiceBus Topic to create this Subscription in. Changing this forces a new resource to be created.
     */
    public val topicId: Output
        get() = javaResource.topicId().applyValue({ args0 -> args0 })
}

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

    override fun map(javaResource: Resource): Subscription = Subscription(
        javaResource as
            com.pulumi.azure.servicebus.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 - 2024 Weber Informatics LLC | Privacy Policy