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

com.pulumi.aws.rbin.kotlin.Rule.kt Maven / Gradle / Ivy

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

package com.pulumi.aws.rbin.kotlin

import com.pulumi.aws.rbin.kotlin.outputs.RuleLockConfiguration
import com.pulumi.aws.rbin.kotlin.outputs.RuleResourceTag
import com.pulumi.aws.rbin.kotlin.outputs.RuleRetentionPeriod
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.Deprecated
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.aws.rbin.kotlin.outputs.RuleLockConfiguration.Companion.toKotlin as ruleLockConfigurationToKotlin
import com.pulumi.aws.rbin.kotlin.outputs.RuleResourceTag.Companion.toKotlin as ruleResourceTagToKotlin
import com.pulumi.aws.rbin.kotlin.outputs.RuleRetentionPeriod.Companion.toKotlin as ruleRetentionPeriodToKotlin

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

    public var args: RuleArgs = RuleArgs()

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

/**
 * Resource for managing an AWS RBin Rule.
 * ## Example Usage
 * ### Basic Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const example = new aws.rbin.Rule("example", {
 *     description: "example_rule",
 *     resourceType: "EBS_SNAPSHOT",
 *     resourceTags: [{
 *         resourceTagKey: "tag_key",
 *         resourceTagValue: "tag_value",
 *     }],
 *     retentionPeriod: {
 *         retentionPeriodValue: 10,
 *         retentionPeriodUnit: "DAYS",
 *     },
 *     tags: {
 *         test_tag_key: "test_tag_value",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * example = aws.rbin.Rule("example",
 *     description="example_rule",
 *     resource_type="EBS_SNAPSHOT",
 *     resource_tags=[{
 *         "resource_tag_key": "tag_key",
 *         "resource_tag_value": "tag_value",
 *     }],
 *     retention_period={
 *         "retention_period_value": 10,
 *         "retention_period_unit": "DAYS",
 *     },
 *     tags={
 *         "test_tag_key": "test_tag_value",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Aws.Rbin.Rule("example", new()
 *     {
 *         Description = "example_rule",
 *         ResourceType = "EBS_SNAPSHOT",
 *         ResourceTags = new[]
 *         {
 *             new Aws.Rbin.Inputs.RuleResourceTagArgs
 *             {
 *                 ResourceTagKey = "tag_key",
 *                 ResourceTagValue = "tag_value",
 *             },
 *         },
 *         RetentionPeriod = new Aws.Rbin.Inputs.RuleRetentionPeriodArgs
 *         {
 *             RetentionPeriodValue = 10,
 *             RetentionPeriodUnit = "DAYS",
 *         },
 *         Tags =
 *         {
 *             { "test_tag_key", "test_tag_value" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rbin"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := rbin.NewRule(ctx, "example", &rbin.RuleArgs{
 * 			Description:  pulumi.String("example_rule"),
 * 			ResourceType: pulumi.String("EBS_SNAPSHOT"),
 * 			ResourceTags: rbin.RuleResourceTagArray{
 * 				&rbin.RuleResourceTagArgs{
 * 					ResourceTagKey:   pulumi.String("tag_key"),
 * 					ResourceTagValue: pulumi.String("tag_value"),
 * 				},
 * 			},
 * 			RetentionPeriod: &rbin.RuleRetentionPeriodArgs{
 * 				RetentionPeriodValue: pulumi.Int(10),
 * 				RetentionPeriodUnit:  pulumi.String("DAYS"),
 * 			},
 * 			Tags: pulumi.StringMap{
 * 				"test_tag_key": pulumi.String("test_tag_value"),
 * 			},
 * 		})
 * 		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.aws.rbin.Rule;
 * import com.pulumi.aws.rbin.RuleArgs;
 * import com.pulumi.aws.rbin.inputs.RuleResourceTagArgs;
 * import com.pulumi.aws.rbin.inputs.RuleRetentionPeriodArgs;
 * 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 example = new Rule("example", RuleArgs.builder()
 *             .description("example_rule")
 *             .resourceType("EBS_SNAPSHOT")
 *             .resourceTags(RuleResourceTagArgs.builder()
 *                 .resourceTagKey("tag_key")
 *                 .resourceTagValue("tag_value")
 *                 .build())
 *             .retentionPeriod(RuleRetentionPeriodArgs.builder()
 *                 .retentionPeriodValue(10)
 *                 .retentionPeriodUnit("DAYS")
 *                 .build())
 *             .tags(Map.of("test_tag_key", "test_tag_value"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: aws:rbin:Rule
 *     properties:
 *       description: example_rule
 *       resourceType: EBS_SNAPSHOT
 *       resourceTags:
 *         - resourceTagKey: tag_key
 *           resourceTagValue: tag_value
 *       retentionPeriod:
 *         retentionPeriodValue: 10
 *         retentionPeriodUnit: DAYS
 *       tags:
 *         test_tag_key: test_tag_value
 * ```
 * 
 * ## Import
 * Using `pulumi import`, import RBin Rule using the `id`. For example:
 * ```sh
 * $ pulumi import aws:rbin/rule:Rule example examplerule
 * ```
 */
public class Rule internal constructor(
    override val javaResource: com.pulumi.aws.rbin.Rule,
) : KotlinCustomResource(javaResource, RuleMapper) {
    public val arn: Output
        get() = javaResource.arn().applyValue({ args0 -> args0 })

    /**
     * The retention rule description.
     */
    public val description: Output
        get() = javaResource.description().applyValue({ args0 -> args0 })

    /**
     * Information about the retention rule lock configuration. See `lock_configuration` below.
     */
    public val lockConfiguration: Output?
        get() = javaResource.lockConfiguration().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> ruleLockConfigurationToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * (Timestamp) The date and time at which the unlock delay is set to expire. Only returned for retention rules that have been unlocked and that are still within the unlock delay period.
     */
    public val lockEndTime: Output
        get() = javaResource.lockEndTime().applyValue({ args0 -> args0 })

    /**
     * (Optional) The lock state of the retention rules to list. Only retention rules with the specified lock state are returned. Valid values are `locked`, `pending_unlock`, `unlocked`.
     */
    public val lockState: Output
        get() = javaResource.lockState().applyValue({ args0 -> args0 })

    /**
     * Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. See `resource_tags` below.
     */
    public val resourceTags: Output>
        get() = javaResource.resourceTags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    ruleResourceTagToKotlin(args0)
                })
            })
        })

    /**
     * The resource type to be retained by the retention rule. Valid values are `EBS_SNAPSHOT` and `EC2_IMAGE`.
     */
    public val resourceType: Output
        get() = javaResource.resourceType().applyValue({ args0 -> args0 })

    /**
     * Information about the retention period for which the retention rule is to retain resources. See `retention_period` below.
     * The following arguments are optional:
     */
    public val retentionPeriod: Output
        get() = javaResource.retentionPeriod().applyValue({ args0 ->
            args0.let({ args0 ->
                ruleRetentionPeriodToKotlin(args0)
            })
        })

    /**
     * (String) The state of the retention rule. Only retention rules that are in the `available` state retain resources. Valid values include `pending` and `available`.
     */
    public val status: Output
        get() = javaResource.status().applyValue({ args0 -> args0 })

    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    @Deprecated(
        message = """
  Please use `tags` instead.
  """,
    )
    public val tagsAll: Output>
        get() = javaResource.tagsAll().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })
}

public object RuleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.aws.rbin.Rule::class == javaResource::class

    override fun map(javaResource: Resource): Rule = Rule(javaResource as com.pulumi.aws.rbin.Rule)
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy