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

com.pulumi.gcp.pubsub.kotlin.LiteSubscription.kt Maven / Gradle / Ivy

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

package com.pulumi.gcp.pubsub.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.pubsub.kotlin.outputs.LiteSubscriptionDeliveryConfig
import com.pulumi.gcp.pubsub.kotlin.outputs.LiteSubscriptionDeliveryConfig.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.String
import kotlin.Suppress
import kotlin.Unit

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

    public var args: LiteSubscriptionArgs = LiteSubscriptionArgs()

    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 LiteSubscriptionArgsBuilder.() -> Unit) {
        val builder = LiteSubscriptionArgsBuilder()
        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(): LiteSubscription {
        val builtJavaResource = com.pulumi.gcp.pubsub.LiteSubscription(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return LiteSubscription(builtJavaResource)
    }
}

/**
 * A named resource representing the stream of messages from a single,
 * specific topic, to be delivered to the subscribing application.
 * To get more information about Subscription, see:
 * * [API documentation](https://cloud.google.com/pubsub/lite/docs/reference/rest/v1/admin.projects.locations.subscriptions)
 * * How-to Guides
 *     * [Managing Subscriptions](https://cloud.google.com/pubsub/lite/docs/subscriptions)
 * ## Example Usage
 * ### Pubsub Lite Subscription Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const project = gcp.organizations.getProject({});
 * const example = new gcp.pubsub.LiteTopic("example", {
 *     name: "example-topic",
 *     project: project.then(project => project.number),
 *     partitionConfig: {
 *         count: 1,
 *         capacity: {
 *             publishMibPerSec: 4,
 *             subscribeMibPerSec: 8,
 *         },
 *     },
 *     retentionConfig: {
 *         perPartitionBytes: "32212254720",
 *     },
 * });
 * const exampleLiteSubscription = new gcp.pubsub.LiteSubscription("example", {
 *     name: "example-subscription",
 *     topic: example.name,
 *     deliveryConfig: {
 *         deliveryRequirement: "DELIVER_AFTER_STORED",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * project = gcp.organizations.get_project()
 * example = gcp.pubsub.LiteTopic("example",
 *     name="example-topic",
 *     project=project.number,
 *     partition_config={
 *         "count": 1,
 *         "capacity": {
 *             "publish_mib_per_sec": 4,
 *             "subscribe_mib_per_sec": 8,
 *         },
 *     },
 *     retention_config={
 *         "per_partition_bytes": "32212254720",
 *     })
 * example_lite_subscription = gcp.pubsub.LiteSubscription("example",
 *     name="example-subscription",
 *     topic=example.name,
 *     delivery_config={
 *         "delivery_requirement": "DELIVER_AFTER_STORED",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var project = Gcp.Organizations.GetProject.Invoke();
 *     var example = new Gcp.PubSub.LiteTopic("example", new()
 *     {
 *         Name = "example-topic",
 *         Project = project.Apply(getProjectResult => getProjectResult.Number),
 *         PartitionConfig = new Gcp.PubSub.Inputs.LiteTopicPartitionConfigArgs
 *         {
 *             Count = 1,
 *             Capacity = new Gcp.PubSub.Inputs.LiteTopicPartitionConfigCapacityArgs
 *             {
 *                 PublishMibPerSec = 4,
 *                 SubscribeMibPerSec = 8,
 *             },
 *         },
 *         RetentionConfig = new Gcp.PubSub.Inputs.LiteTopicRetentionConfigArgs
 *         {
 *             PerPartitionBytes = "32212254720",
 *         },
 *     });
 *     var exampleLiteSubscription = new Gcp.PubSub.LiteSubscription("example", new()
 *     {
 *         Name = "example-subscription",
 *         Topic = example.Name,
 *         DeliveryConfig = new Gcp.PubSub.Inputs.LiteSubscriptionDeliveryConfigArgs
 *         {
 *             DeliveryRequirement = "DELIVER_AFTER_STORED",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/pubsub"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		project, err := organizations.LookupProject(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		example, err := pubsub.NewLiteTopic(ctx, "example", &pubsub.LiteTopicArgs{
 * 			Name:    pulumi.String("example-topic"),
 * 			Project: pulumi.String(project.Number),
 * 			PartitionConfig: &pubsub.LiteTopicPartitionConfigArgs{
 * 				Count: pulumi.Int(1),
 * 				Capacity: &pubsub.LiteTopicPartitionConfigCapacityArgs{
 * 					PublishMibPerSec:   pulumi.Int(4),
 * 					SubscribeMibPerSec: pulumi.Int(8),
 * 				},
 * 			},
 * 			RetentionConfig: &pubsub.LiteTopicRetentionConfigArgs{
 * 				PerPartitionBytes: pulumi.String("32212254720"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = pubsub.NewLiteSubscription(ctx, "example", &pubsub.LiteSubscriptionArgs{
 * 			Name:  pulumi.String("example-subscription"),
 * 			Topic: example.Name,
 * 			DeliveryConfig: &pubsub.LiteSubscriptionDeliveryConfigArgs{
 * 				DeliveryRequirement: pulumi.String("DELIVER_AFTER_STORED"),
 * 			},
 * 		})
 * 		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.gcp.organizations.OrganizationsFunctions;
 * import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
 * import com.pulumi.gcp.pubsub.LiteTopic;
 * import com.pulumi.gcp.pubsub.LiteTopicArgs;
 * import com.pulumi.gcp.pubsub.inputs.LiteTopicPartitionConfigArgs;
 * import com.pulumi.gcp.pubsub.inputs.LiteTopicPartitionConfigCapacityArgs;
 * import com.pulumi.gcp.pubsub.inputs.LiteTopicRetentionConfigArgs;
 * import com.pulumi.gcp.pubsub.LiteSubscription;
 * import com.pulumi.gcp.pubsub.LiteSubscriptionArgs;
 * import com.pulumi.gcp.pubsub.inputs.LiteSubscriptionDeliveryConfigArgs;
 * 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) {
 *         final var project = OrganizationsFunctions.getProject();
 *         var example = new LiteTopic("example", LiteTopicArgs.builder()
 *             .name("example-topic")
 *             .project(project.applyValue(getProjectResult -> getProjectResult.number()))
 *             .partitionConfig(LiteTopicPartitionConfigArgs.builder()
 *                 .count(1)
 *                 .capacity(LiteTopicPartitionConfigCapacityArgs.builder()
 *                     .publishMibPerSec(4)
 *                     .subscribeMibPerSec(8)
 *                     .build())
 *                 .build())
 *             .retentionConfig(LiteTopicRetentionConfigArgs.builder()
 *                 .perPartitionBytes(32212254720)
 *                 .build())
 *             .build());
 *         var exampleLiteSubscription = new LiteSubscription("exampleLiteSubscription", LiteSubscriptionArgs.builder()
 *             .name("example-subscription")
 *             .topic(example.name())
 *             .deliveryConfig(LiteSubscriptionDeliveryConfigArgs.builder()
 *                 .deliveryRequirement("DELIVER_AFTER_STORED")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:pubsub:LiteTopic
 *     properties:
 *       name: example-topic
 *       project: ${project.number}
 *       partitionConfig:
 *         count: 1
 *         capacity:
 *           publishMibPerSec: 4
 *           subscribeMibPerSec: 8
 *       retentionConfig:
 *         perPartitionBytes: 3.221225472e+10
 *   exampleLiteSubscription:
 *     type: gcp:pubsub:LiteSubscription
 *     name: example
 *     properties:
 *       name: example-subscription
 *       topic: ${example.name}
 *       deliveryConfig:
 *         deliveryRequirement: DELIVER_AFTER_STORED
 * variables:
 *   project:
 *     fn::invoke:
 *       Function: gcp:organizations:getProject
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * Subscription can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{zone}}/subscriptions/{{name}}`
 * * `{{project}}/{{zone}}/{{name}}`
 * * `{{zone}}/{{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, Subscription can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:pubsub/liteSubscription:LiteSubscription default projects/{{project}}/locations/{{zone}}/subscriptions/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:pubsub/liteSubscription:LiteSubscription default {{project}}/{{zone}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:pubsub/liteSubscription:LiteSubscription default {{zone}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:pubsub/liteSubscription:LiteSubscription default {{name}}
 * ```
 */
public class LiteSubscription internal constructor(
    override val javaResource: com.pulumi.gcp.pubsub.LiteSubscription,
) : KotlinCustomResource(javaResource, LiteSubscriptionMapper) {
    /**
     * The settings for this subscription's message delivery.
     * Structure is documented below.
     */
    public val deliveryConfig: Output?
        get() = javaResource.deliveryConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> toKotlin(args0) })
            }).orElse(null)
        })

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

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The region of the pubsub lite topic.
     */
    public val region: Output?
        get() = javaResource.region().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * A reference to a Topic resource.
     */
    public val topic: Output
        get() = javaResource.topic().applyValue({ args0 -> args0 })

    /**
     * The zone of the pubsub lite topic.
     */
    public val zone: Output?
        get() = javaResource.zone().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}

public object LiteSubscriptionMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.pubsub.LiteSubscription::class == javaResource::class

    override fun map(javaResource: Resource): LiteSubscription = LiteSubscription(
        javaResource as
            com.pulumi.gcp.pubsub.LiteSubscription,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy