Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.azure.cosmosdb.kotlin.SqlTrigger.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.azure.cosmosdb.kotlin
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.String
import kotlin.Suppress
import kotlin.Unit
/**
* Builder for [SqlTrigger].
*/
@PulumiTagMarker
public class SqlTriggerResourceBuilder internal constructor() {
public var name: String? = null
public var args: SqlTriggerArgs = SqlTriggerArgs()
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 SqlTriggerArgsBuilder.() -> Unit) {
val builder = SqlTriggerArgsBuilder()
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(): SqlTrigger {
val builtJavaResource = com.pulumi.azure.cosmosdb.SqlTrigger(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return SqlTrigger(builtJavaResource)
}
}
/**
* Manages an SQL Trigger.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azure from "@pulumi/azure";
* const example = azure.cosmosdb.getAccount({
* name: "tfex-cosmosdb-account",
* resourceGroupName: "tfex-cosmosdb-account-rg",
* });
* const exampleSqlDatabase = new azure.cosmosdb.SqlDatabase("example", {
* name: "tfex-cosmos-db",
* resourceGroupName: example.then(example => example.resourceGroupName),
* accountName: example.then(example => example.name),
* throughput: 400,
* });
* const exampleSqlContainer = new azure.cosmosdb.SqlContainer("example", {
* name: "example-container",
* resourceGroupName: example.then(example => example.resourceGroupName),
* accountName: example.then(example => example.name),
* databaseName: exampleSqlDatabase.name,
* partitionKeyPath: "/id",
* });
* const exampleSqlTrigger = new azure.cosmosdb.SqlTrigger("example", {
* name: "test-trigger",
* containerId: exampleSqlContainer.id,
* body: "function trigger(){}",
* operation: "Delete",
* type: "Post",
* });
* ```
* ```python
* import pulumi
* import pulumi_azure as azure
* example = azure.cosmosdb.get_account(name="tfex-cosmosdb-account",
* resource_group_name="tfex-cosmosdb-account-rg")
* example_sql_database = azure.cosmosdb.SqlDatabase("example",
* name="tfex-cosmos-db",
* resource_group_name=example.resource_group_name,
* account_name=example.name,
* throughput=400)
* example_sql_container = azure.cosmosdb.SqlContainer("example",
* name="example-container",
* resource_group_name=example.resource_group_name,
* account_name=example.name,
* database_name=example_sql_database.name,
* partition_key_path="/id")
* example_sql_trigger = azure.cosmosdb.SqlTrigger("example",
* name="test-trigger",
* container_id=example_sql_container.id,
* body="function trigger(){}",
* operation="Delete",
* type="Post")
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Azure = Pulumi.Azure;
* return await Deployment.RunAsync(() =>
* {
* var example = Azure.CosmosDB.GetAccount.Invoke(new()
* {
* Name = "tfex-cosmosdb-account",
* ResourceGroupName = "tfex-cosmosdb-account-rg",
* });
* var exampleSqlDatabase = new Azure.CosmosDB.SqlDatabase("example", new()
* {
* Name = "tfex-cosmos-db",
* ResourceGroupName = example.Apply(getAccountResult => getAccountResult.ResourceGroupName),
* AccountName = example.Apply(getAccountResult => getAccountResult.Name),
* Throughput = 400,
* });
* var exampleSqlContainer = new Azure.CosmosDB.SqlContainer("example", new()
* {
* Name = "example-container",
* ResourceGroupName = example.Apply(getAccountResult => getAccountResult.ResourceGroupName),
* AccountName = example.Apply(getAccountResult => getAccountResult.Name),
* DatabaseName = exampleSqlDatabase.Name,
* PartitionKeyPath = "/id",
* });
* var exampleSqlTrigger = new Azure.CosmosDB.SqlTrigger("example", new()
* {
* Name = "test-trigger",
* ContainerId = exampleSqlContainer.Id,
* Body = "function trigger(){}",
* Operation = "Delete",
* Type = "Post",
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/cosmosdb"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* example, err := cosmosdb.LookupAccount(ctx, &cosmosdb.LookupAccountArgs{
* Name: "tfex-cosmosdb-account",
* ResourceGroupName: "tfex-cosmosdb-account-rg",
* }, nil)
* if err != nil {
* return err
* }
* exampleSqlDatabase, err := cosmosdb.NewSqlDatabase(ctx, "example", &cosmosdb.SqlDatabaseArgs{
* Name: pulumi.String("tfex-cosmos-db"),
* ResourceGroupName: pulumi.String(example.ResourceGroupName),
* AccountName: pulumi.String(example.Name),
* Throughput: pulumi.Int(400),
* })
* if err != nil {
* return err
* }
* exampleSqlContainer, err := cosmosdb.NewSqlContainer(ctx, "example", &cosmosdb.SqlContainerArgs{
* Name: pulumi.String("example-container"),
* ResourceGroupName: pulumi.String(example.ResourceGroupName),
* AccountName: pulumi.String(example.Name),
* DatabaseName: exampleSqlDatabase.Name,
* PartitionKeyPath: pulumi.String("/id"),
* })
* if err != nil {
* return err
* }
* _, err = cosmosdb.NewSqlTrigger(ctx, "example", &cosmosdb.SqlTriggerArgs{
* Name: pulumi.String("test-trigger"),
* ContainerId: exampleSqlContainer.ID(),
* Body: pulumi.String("function trigger(){}"),
* Operation: pulumi.String("Delete"),
* Type: pulumi.String("Post"),
* })
* 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.cosmosdb.CosmosdbFunctions;
* import com.pulumi.azure.cosmosdb.inputs.GetAccountArgs;
* import com.pulumi.azure.cosmosdb.SqlDatabase;
* import com.pulumi.azure.cosmosdb.SqlDatabaseArgs;
* import com.pulumi.azure.cosmosdb.SqlContainer;
* import com.pulumi.azure.cosmosdb.SqlContainerArgs;
* import com.pulumi.azure.cosmosdb.SqlTrigger;
* import com.pulumi.azure.cosmosdb.SqlTriggerArgs;
* 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 example = CosmosdbFunctions.getAccount(GetAccountArgs.builder()
* .name("tfex-cosmosdb-account")
* .resourceGroupName("tfex-cosmosdb-account-rg")
* .build());
* var exampleSqlDatabase = new SqlDatabase("exampleSqlDatabase", SqlDatabaseArgs.builder()
* .name("tfex-cosmos-db")
* .resourceGroupName(example.applyValue(getAccountResult -> getAccountResult.resourceGroupName()))
* .accountName(example.applyValue(getAccountResult -> getAccountResult.name()))
* .throughput(400)
* .build());
* var exampleSqlContainer = new SqlContainer("exampleSqlContainer", SqlContainerArgs.builder()
* .name("example-container")
* .resourceGroupName(example.applyValue(getAccountResult -> getAccountResult.resourceGroupName()))
* .accountName(example.applyValue(getAccountResult -> getAccountResult.name()))
* .databaseName(exampleSqlDatabase.name())
* .partitionKeyPath("/id")
* .build());
* var exampleSqlTrigger = new SqlTrigger("exampleSqlTrigger", SqlTriggerArgs.builder()
* .name("test-trigger")
* .containerId(exampleSqlContainer.id())
* .body("function trigger(){}")
* .operation("Delete")
* .type("Post")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* exampleSqlDatabase:
* type: azure:cosmosdb:SqlDatabase
* name: example
* properties:
* name: tfex-cosmos-db
* resourceGroupName: ${example.resourceGroupName}
* accountName: ${example.name}
* throughput: 400
* exampleSqlContainer:
* type: azure:cosmosdb:SqlContainer
* name: example
* properties:
* name: example-container
* resourceGroupName: ${example.resourceGroupName}
* accountName: ${example.name}
* databaseName: ${exampleSqlDatabase.name}
* partitionKeyPath: /id
* exampleSqlTrigger:
* type: azure:cosmosdb:SqlTrigger
* name: example
* properties:
* name: test-trigger
* containerId: ${exampleSqlContainer.id}
* body: function trigger(){}
* operation: Delete
* type: Post
* variables:
* example:
* fn::invoke:
* Function: azure:cosmosdb:getAccount
* Arguments:
* name: tfex-cosmosdb-account
* resourceGroupName: tfex-cosmosdb-account-rg
* ```
*
* ## Import
* SQL Triggers can be imported using the `resource id`, e.g.
* ```sh
* $ pulumi import azure:cosmosdb/sqlTrigger:SqlTrigger example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/triggers/trigger1
* ```
*/
public class SqlTrigger internal constructor(
override val javaResource: com.pulumi.azure.cosmosdb.SqlTrigger,
) : KotlinCustomResource(javaResource, SqlTriggerMapper) {
/**
* Body of the Trigger.
*/
public val body: Output
get() = javaResource.body().applyValue({ args0 -> args0 })
/**
* The id of the Cosmos DB SQL Container to create the SQL Trigger within. Changing this forces a new SQL Trigger to be created.
*/
public val containerId: Output
get() = javaResource.containerId().applyValue({ args0 -> args0 })
/**
* The name which should be used for this SQL Trigger. Changing this forces a new SQL Trigger to be created.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The operation the trigger is associated with. Possible values are `All`, `Create`, `Update`, `Delete` and `Replace`.
*/
public val operation: Output
get() = javaResource.operation().applyValue({ args0 -> args0 })
/**
* Type of the Trigger. Possible values are `Pre` and `Post`.
*/
public val type: Output
get() = javaResource.type().applyValue({ args0 -> args0 })
}
public object SqlTriggerMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.azure.cosmosdb.SqlTrigger::class == javaResource::class
override fun map(javaResource: Resource): SqlTrigger = SqlTrigger(
javaResource as
com.pulumi.azure.cosmosdb.SqlTrigger,
)
}
/**
* @see [SqlTrigger].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [SqlTrigger].
*/
public suspend fun sqlTrigger(name: String, block: suspend SqlTriggerResourceBuilder.() -> Unit): SqlTrigger {
val builder = SqlTriggerResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [SqlTrigger].
* @param name The _unique_ name of the resulting resource.
*/
public fun sqlTrigger(name: String): SqlTrigger {
val builder = SqlTriggerResourceBuilder()
builder.name(name)
return builder.build()
}