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

com.pulumi.cloudflare.kotlin.Ruleset.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

The newest version!
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.cloudflare.kotlin

import com.pulumi.cloudflare.kotlin.outputs.RulesetRule
import com.pulumi.cloudflare.kotlin.outputs.RulesetRule.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.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List

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

    public var args: RulesetArgs = RulesetArgs()

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

/**
 * The [Cloudflare Ruleset Engine](https://developers.cloudflare.com/firewall/cf-rulesets)
 * allows you to create and deploy rules and rulesets.
 * The engine syntax, inspired by the Wireshark Display Filter language, is the
 * same syntax used in custom Firewall Rules. Cloudflare uses the Ruleset Engine
 * in different products, allowing you to configure several products using the same
 * basic syntax.
 * ## Import
 * Import an account scoped Ruleset configuration.
 * ```sh
 * $ pulumi import cloudflare:index/ruleset:Ruleset example account//
 * ```
 * Import a zone scoped Ruleset configuration.
 * ```sh
 * $ pulumi import cloudflare:index/ruleset:Ruleset example zone//
 * ```
 */
public class Ruleset internal constructor(
    override val javaResource: com.pulumi.cloudflare.Ruleset,
) : KotlinCustomResource(javaResource, RulesetMapper) {
    /**
     * The account identifier to target for the resource.
     */
    public val accountId: Output?
        get() = javaResource.accountId().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Brief summary of the ruleset and its intended use.
     */
    public val description: Output
        get() = javaResource.description().applyValue({ args0 -> args0 })

    /**
     * Type of Ruleset to create. Available values: `custom`, `managed`, `root`, `zone`.
     */
    public val kind: Output
        get() = javaResource.kind().applyValue({ args0 -> args0 })

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

    /**
     * Point in the request/response lifecycle where the ruleset will be created. Available values: `ddos_l4`, `ddos_l7`, `http_config_settings`, `http_custom_errors`, `http_log_custom_fields`, `http_ratelimit`, `http_request_cache_settings`, `http_request_dynamic_redirect`, `http_request_firewall_custom`, `http_request_firewall_managed`, `http_request_late_transform`, `http_request_origin`, `http_request_redirect`, `http_request_sanitize`, `http_request_sbfm`, `http_request_transform`, `http_response_compression`, `http_response_firewall_managed`, `http_response_headers_transform`, `magic_transit`.
     */
    public val phase: Output
        get() = javaResource.phase().applyValue({ args0 -> args0 })

    /**
     * List of rules to apply to the ruleset.
     */
    public val rules: Output>?
        get() = javaResource.rules().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 -> toKotlin(args0) })
                })
            }).orElse(null)
        })

    /**
     * The zone identifier to target for the resource.
     */
    public val zoneId: Output?
        get() = javaResource.zoneId().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}

public object RulesetMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.cloudflare.Ruleset::class == javaResource::class

    override fun map(javaResource: Resource): Ruleset = Ruleset(
        javaResource as
            com.pulumi.cloudflare.Ruleset,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy