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

com.pulumi.random.kotlin.RandomShuffle.kt Maven / Gradle / Ivy

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

package com.pulumi.random.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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map

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

    public var args: RandomShuffleArgs = RandomShuffleArgs()

    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 RandomShuffleArgsBuilder.() -> Unit) {
        val builder = RandomShuffleArgsBuilder()
        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.opts(block)
    }

    internal fun build(): RandomShuffle {
        val builtJavaResource = com.pulumi.random.RandomShuffle(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return RandomShuffle(builtJavaResource)
    }
}

/**
 * The resource `random.RandomShuffle` generates a random permutation of a list of strings given as an argument.
 * ## Example Usage
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.random.RandomShuffle;
 * import com.pulumi.random.RandomShuffleArgs;
 * import com.pulumi.aws.elb.LoadBalancer;
 * import com.pulumi.aws.elb.LoadBalancerArgs;
 * 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 az = new RandomShuffle("az", RandomShuffleArgs.builder()
 *             .inputs(
 *                 "us-west-1a",
 *                 "us-west-1c",
 *                 "us-west-1d",
 *                 "us-west-1e")
 *             .resultCount(2)
 *             .build());
 *         var example = new LoadBalancer("example", LoadBalancerArgs.builder()
 *             .availabilityZones(az.results())
 *             .build());
 *     }
 * }
 * ```
 */
public class RandomShuffle internal constructor(
    override val javaResource: com.pulumi.random.RandomShuffle,
) : KotlinCustomResource(javaResource, RandomShuffleMapper) {
    /**
     * The list of strings to shuffle.
     */
    public val inputs: Output>
        get() = javaResource.inputs().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
     */
    public val keepers: Output>?
        get() = javaResource.keepers().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * The number of results to return. Defaults to the number of items in the `input` list. If fewer items are requested, some elements will be excluded from the result. If more items are requested, items will be repeated in the result but not more frequently than the number of items in the input list.
     */
    public val resultCount: Output?
        get() = javaResource.resultCount().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Random permutation of the list of strings given in `input`.
     */
    public val results: Output>
        get() = javaResource.results().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
     */
    public val seed: Output?
        get() = javaResource.seed().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}

public object RandomShuffleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.random.RandomShuffle::class == javaResource::class

    override fun map(javaResource: Resource): RandomShuffle = RandomShuffle(
        javaResource as
            com.pulumi.random.RandomShuffle,
    )
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy