com.pulumi.cloudflare.kotlin.PageRule.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.
The newest version!
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.cloudflare.kotlin
import com.pulumi.cloudflare.kotlin.outputs.PageRuleActions
import com.pulumi.cloudflare.kotlin.outputs.PageRuleActions.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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
/**
* Builder for [PageRule].
*/
@PulumiTagMarker
public class PageRuleResourceBuilder internal constructor() {
public var name: String? = null
public var args: PageRuleArgs = PageRuleArgs()
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 PageRuleArgsBuilder.() -> Unit) {
val builder = PageRuleArgsBuilder()
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(): PageRule {
val builtJavaResource = com.pulumi.cloudflare.PageRule(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return PageRule(builtJavaResource)
}
}
/**
* Provides a Cloudflare page rule resource.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as cloudflare from "@pulumi/cloudflare";
* // Add a page rule to the domain
* const foobar = new cloudflare.PageRule("foobar", {
* zoneId: cloudflareZoneId,
* target: `sub.${cloudflareZone}/page`,
* priority: 1,
* actions: {
* ssl: "flexible",
* emailObfuscation: "on",
* minifies: [{
* html: "off",
* css: "on",
* js: "on",
* }],
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_cloudflare as cloudflare
* # Add a page rule to the domain
* foobar = cloudflare.PageRule("foobar",
* zone_id=cloudflare_zone_id,
* target=f"sub.{cloudflare_zone}/page",
* priority=1,
* actions={
* "ssl": "flexible",
* "email_obfuscation": "on",
* "minifies": [{
* "html": "off",
* "css": "on",
* "js": "on",
* }],
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Cloudflare = Pulumi.Cloudflare;
* return await Deployment.RunAsync(() =>
* {
* // Add a page rule to the domain
* var foobar = new Cloudflare.PageRule("foobar", new()
* {
* ZoneId = cloudflareZoneId,
* Target = $"sub.{cloudflareZone}/page",
* Priority = 1,
* Actions = new Cloudflare.Inputs.PageRuleActionsArgs
* {
* Ssl = "flexible",
* EmailObfuscation = "on",
* Minifies = new[]
* {
* new Cloudflare.Inputs.PageRuleActionsMinifyArgs
* {
* Html = "off",
* Css = "on",
* Js = "on",
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "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 {
* // Add a page rule to the domain
* _, err := cloudflare.NewPageRule(ctx, "foobar", &cloudflare.PageRuleArgs{
* ZoneId: pulumi.Any(cloudflareZoneId),
* Target: pulumi.Sprintf("sub.%v/page", cloudflareZone),
* Priority: pulumi.Int(1),
* Actions: &cloudflare.PageRuleActionsArgs{
* Ssl: pulumi.String("flexible"),
* EmailObfuscation: pulumi.String("on"),
* Minifies: cloudflare.PageRuleActionsMinifyArray{
* &cloudflare.PageRuleActionsMinifyArgs{
* Html: pulumi.String("off"),
* Css: pulumi.String("on"),
* Js: pulumi.String("on"),
* },
* },
* },
* })
* 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.PageRule;
* import com.pulumi.cloudflare.PageRuleArgs;
* import com.pulumi.cloudflare.inputs.PageRuleActionsArgs;
* 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) {
* // Add a page rule to the domain
* var foobar = new PageRule("foobar", PageRuleArgs.builder()
* .zoneId(cloudflareZoneId)
* .target(String.format("sub.%s/page", cloudflareZone))
* .priority(1)
* .actions(PageRuleActionsArgs.builder()
* .ssl("flexible")
* .emailObfuscation("on")
* .minifies(PageRuleActionsMinifyArgs.builder()
* .html("off")
* .css("on")
* .js("on")
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* # Add a page rule to the domain
* foobar:
* type: cloudflare:PageRule
* properties:
* zoneId: ${cloudflareZoneId}
* target: sub.${cloudflareZone}/page
* priority: 1
* actions:
* ssl: flexible
* emailObfuscation: on
* minifies:
* - html: off
* css: on
* js: on
* ```
*
* ## Import
* Page rules can be imported using a composite ID formed of zone ID and page rule ID, e.g.
* ```sh
* $ pulumi import cloudflare:index/pageRule:PageRule default d41d8cd98f00b204e9800998ecf8427e/ch8374ftwdghsif43
* ```
*/
public class PageRule internal constructor(
override val javaResource: com.pulumi.cloudflare.PageRule,
) : KotlinCustomResource(javaResource, PageRuleMapper) {
/**
* The actions taken by the page rule, options given below.
*/
public val actions: Output
get() = javaResource.actions().applyValue({ args0 -> args0.let({ args0 -> toKotlin(args0) }) })
/**
* The priority of the page rule among others for this target, the higher the number the higher the priority as per [API documentation](https://api.cloudflare.com/#page-rules-for-a-zone-create-page-rule).
*/
public val priority: Output?
get() = javaResource.priority().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* Whether the page rule is active or disabled.
*/
public val status: Output?
get() = javaResource.status().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* The URL pattern to target with the page rule.
*/
public val target: Output
get() = javaResource.target().applyValue({ args0 -> args0 })
/**
* The DNS zone ID to which the page rule should be added.
*/
public val zoneId: Output
get() = javaResource.zoneId().applyValue({ args0 -> args0 })
}
public object PageRuleMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.cloudflare.PageRule::class == javaResource::class
override fun map(javaResource: Resource): PageRule = PageRule(
javaResource as
com.pulumi.cloudflare.PageRule,
)
}
/**
* @see [PageRule].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [PageRule].
*/
public suspend fun pageRule(name: String, block: suspend PageRuleResourceBuilder.() -> Unit): PageRule {
val builder = PageRuleResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [PageRule].
* @param name The _unique_ name of the resulting resource.
*/
public fun pageRule(name: String): PageRule {
val builder = PageRuleResourceBuilder()
builder.name(name)
return builder.build()
}