com.pulumi.cloudflare.kotlin.EmailRoutingRule.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-cloudflare-kotlin Show documentation
Show all versions of pulumi-cloudflare-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.cloudflare.kotlin
import com.pulumi.cloudflare.kotlin.outputs.EmailRoutingRuleAction
import com.pulumi.cloudflare.kotlin.outputs.EmailRoutingRuleMatcher
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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.cloudflare.kotlin.outputs.EmailRoutingRuleAction.Companion.toKotlin as emailRoutingRuleActionToKotlin
import com.pulumi.cloudflare.kotlin.outputs.EmailRoutingRuleMatcher.Companion.toKotlin as emailRoutingRuleMatcherToKotlin
/**
* Builder for [EmailRoutingRule].
*/
@PulumiTagMarker
public class EmailRoutingRuleResourceBuilder internal constructor() {
public var name: String? = null
public var args: EmailRoutingRuleArgs = EmailRoutingRuleArgs()
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 EmailRoutingRuleArgsBuilder.() -> Unit) {
val builder = EmailRoutingRuleArgsBuilder()
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(): EmailRoutingRule {
val builtJavaResource = com.pulumi.cloudflare.EmailRoutingRule(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return EmailRoutingRule(builtJavaResource)
}
}
/**
* The [Email Routing Rule](https://developers.cloudflare.com/email-routing/setup/email-routing-addresses/#email-rule-actions) resource allows you to create and manage email routing rules for a zone.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as cloudflare from "@pulumi/cloudflare";
* const main = new cloudflare.EmailRoutingRule("main", {
* zoneId: "0da42c8d2132a9ddaf714f9e7c920711",
* name: "terraform rule",
* enabled: true,
* matchers: [{
* type: "literal",
* field: "to",
* value: "[email protected]",
* }],
* actions: [{
* type: "forward",
* values: ["destinationaddress@example.net"],
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_cloudflare as cloudflare
* main = cloudflare.EmailRoutingRule("main",
* zone_id="0da42c8d2132a9ddaf714f9e7c920711",
* name="terraform rule",
* enabled=True,
* matchers=[{
* "type": "literal",
* "field": "to",
* "value": "[email protected]",
* }],
* actions=[{
* "type": "forward",
* "values": ["destinationaddress@example.net"],
* }])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Cloudflare = Pulumi.Cloudflare;
* return await Deployment.RunAsync(() =>
* {
* var main = new Cloudflare.EmailRoutingRule("main", new()
* {
* ZoneId = "0da42c8d2132a9ddaf714f9e7c920711",
* Name = "terraform rule",
* Enabled = true,
* Matchers = new[]
* {
* new Cloudflare.Inputs.EmailRoutingRuleMatcherArgs
* {
* Type = "literal",
* Field = "to",
* Value = "[email protected]",
* },
* },
* Actions = new[]
* {
* new Cloudflare.Inputs.EmailRoutingRuleActionArgs
* {
* Type = "forward",
* Values = new[]
* {
* "[email protected]",
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := cloudflare.NewEmailRoutingRule(ctx, "main", &cloudflare.EmailRoutingRuleArgs{
* ZoneId: pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
* Name: pulumi.String("terraform rule"),
* Enabled: pulumi.Bool(true),
* Matchers: cloudflare.EmailRoutingRuleMatcherArray{
* &cloudflare.EmailRoutingRuleMatcherArgs{
* Type: pulumi.String("literal"),
* Field: pulumi.String("to"),
* Value: pulumi.String("[email protected]"),
* },
* },
* Actions: cloudflare.EmailRoutingRuleActionArray{
* &cloudflare.EmailRoutingRuleActionArgs{
* Type: pulumi.String("forward"),
* Values: pulumi.StringArray{
* pulumi.String("[email protected]"),
* },
* },
* },
* })
* 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.cloudflare.EmailRoutingRule;
* import com.pulumi.cloudflare.EmailRoutingRuleArgs;
* import com.pulumi.cloudflare.inputs.EmailRoutingRuleMatcherArgs;
* import com.pulumi.cloudflare.inputs.EmailRoutingRuleActionArgs;
* 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 main = new EmailRoutingRule("main", EmailRoutingRuleArgs.builder()
* .zoneId("0da42c8d2132a9ddaf714f9e7c920711")
* .name("terraform rule")
* .enabled(true)
* .matchers(EmailRoutingRuleMatcherArgs.builder()
* .type("literal")
* .field("to")
* .value("[email protected]")
* .build())
* .actions(EmailRoutingRuleActionArgs.builder()
* .type("forward")
* .values("[email protected]")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* main:
* type: cloudflare:EmailRoutingRule
* properties:
* zoneId: 0da42c8d2132a9ddaf714f9e7c920711
* name: terraform rule
* enabled: true
* matchers:
* - type: literal
* field: to
* value: [email protected]
* actions:
* - type: forward
* values:
* - [email protected]
* ```
*
* ## Import
* ```sh
* $ pulumi import cloudflare:index/emailRoutingRule:EmailRoutingRule example /
* ```
*/
public class EmailRoutingRule internal constructor(
override val javaResource: com.pulumi.cloudflare.EmailRoutingRule,
) : KotlinCustomResource(javaResource, EmailRoutingRuleMapper) {
/**
* Actions to take when a match is found.
*/
public val actions: Output>?
get() = javaResource.actions().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> emailRoutingRuleActionToKotlin(args0) })
})
}).orElse(null)
})
/**
* Whether the email routing rule is enabled.
*/
public val enabled: Output?
get() = javaResource.enabled().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* Matching patterns to forward to your actions.
*/
public val matchers: Output>?
get() = javaResource.matchers().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> emailRoutingRuleMatcherToKotlin(args0) })
})
}).orElse(null)
})
/**
* Routing rule name.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The priority of the email routing rule.
*/
public val priority: Output
get() = javaResource.priority().applyValue({ args0 -> args0 })
/**
* The tag of the email routing rule.
*/
public val tag: Output
get() = javaResource.tag().applyValue({ args0 -> args0 })
/**
* The zone identifier to target for the resource.
*/
public val zoneId: Output
get() = javaResource.zoneId().applyValue({ args0 -> args0 })
}
public object EmailRoutingRuleMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.cloudflare.EmailRoutingRule::class == javaResource::class
override fun map(javaResource: Resource): EmailRoutingRule = EmailRoutingRule(
javaResource as
com.pulumi.cloudflare.EmailRoutingRule,
)
}
/**
* @see [EmailRoutingRule].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [EmailRoutingRule].
*/
public suspend fun emailRoutingRule(
name: String,
block: suspend EmailRoutingRuleResourceBuilder.() -> Unit,
): EmailRoutingRule {
val builder = EmailRoutingRuleResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [EmailRoutingRule].
* @param name The _unique_ name of the resulting resource.
*/
public fun emailRoutingRule(name: String): EmailRoutingRule {
val builder = EmailRoutingRuleResourceBuilder()
builder.name(name)
return builder.build()
}