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

com.pulumi.nomad.kotlin.Variable.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.

There is a newer version: 2.4.2.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.nomad.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.Any
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map

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

    public var args: VariableArgs = VariableArgs()

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

/**
 * ## Example Usage
 * Creating a variable in the default namespace:
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as nomad from "@pulumi/nomad";
 * const example = new nomad.Variable("example", {
 *     path: "some/path/of/your/choosing",
 *     items: {
 *         example_key: "example_value",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_nomad as nomad
 * example = nomad.Variable("example",
 *     path="some/path/of/your/choosing",
 *     items={
 *         "example_key": "example_value",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Nomad = Pulumi.Nomad;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Nomad.Variable("example", new()
 *     {
 *         Path = "some/path/of/your/choosing",
 *         Items =
 *         {
 *             { "example_key", "example_value" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-nomad/sdk/v2/go/nomad"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := nomad.NewVariable(ctx, "example", &nomad.VariableArgs{
 * 			Path: pulumi.String("some/path/of/your/choosing"),
 * 			Items: pulumi.Map{
 * 				"example_key": pulumi.Any("example_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.nomad.Variable;
 * import com.pulumi.nomad.VariableArgs;
 * 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 Variable("example", VariableArgs.builder()
 *             .path("some/path/of/your/choosing")
 *             .items(Map.of("example_key", "example_value"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: nomad:Variable
 *     properties:
 *       path: some/path/of/your/choosing
 *       items:
 *         example_key: example_value
 * ```
 * 
 * Creating a variable in a custom namespace:
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as nomad from "@pulumi/nomad";
 * const example = new nomad.Namespace("example", {
 *     name: "example",
 *     description: "Example namespace.",
 * });
 * const exampleVariable = new nomad.Variable("example", {
 *     path: "some/path/of/your/choosing",
 *     namespace: example.name,
 *     items: {
 *         example_key: "example_value",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_nomad as nomad
 * example = nomad.Namespace("example",
 *     name="example",
 *     description="Example namespace.")
 * example_variable = nomad.Variable("example",
 *     path="some/path/of/your/choosing",
 *     namespace=example.name,
 *     items={
 *         "example_key": "example_value",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Nomad = Pulumi.Nomad;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Nomad.Namespace("example", new()
 *     {
 *         Name = "example",
 *         Description = "Example namespace.",
 *     });
 *     var exampleVariable = new Nomad.Variable("example", new()
 *     {
 *         Path = "some/path/of/your/choosing",
 *         Namespace = example.Name,
 *         Items =
 *         {
 *             { "example_key", "example_value" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-nomad/sdk/v2/go/nomad"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := nomad.NewNamespace(ctx, "example", &nomad.NamespaceArgs{
 * 			Name:        pulumi.String("example"),
 * 			Description: pulumi.String("Example namespace."),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = nomad.NewVariable(ctx, "example", &nomad.VariableArgs{
 * 			Path:      pulumi.String("some/path/of/your/choosing"),
 * 			Namespace: example.Name,
 * 			Items: pulumi.Map{
 * 				"example_key": pulumi.Any("example_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.nomad.Namespace;
 * import com.pulumi.nomad.NamespaceArgs;
 * import com.pulumi.nomad.Variable;
 * import com.pulumi.nomad.VariableArgs;
 * 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 Namespace("example", NamespaceArgs.builder()
 *             .name("example")
 *             .description("Example namespace.")
 *             .build());
 *         var exampleVariable = new Variable("exampleVariable", VariableArgs.builder()
 *             .path("some/path/of/your/choosing")
 *             .namespace(example.name())
 *             .items(Map.of("example_key", "example_value"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: nomad:Namespace
 *     properties:
 *       name: example
 *       description: Example namespace.
 *   exampleVariable:
 *     type: nomad:Variable
 *     name: example
 *     properties:
 *       path: some/path/of/your/choosing
 *       namespace: ${example.name}
 *       items:
 *         example_key: example_value
 * ```
 * 
 */
public class Variable internal constructor(
    override val javaResource: com.pulumi.nomad.Variable,
) : KotlinCustomResource(javaResource, VariableMapper) {
    /**
     * `(map[string]string: )` - An arbitrary map of items to create in the variable.
     */
    public val items: Output>
        get() = javaResource.items().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * `(string: "default")` - The namepsace to create the variable in.
     */
    public val namespace: Output?
        get() = javaResource.namespace().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * `(string: )` - A unique path to create the variable at.
     */
    public val path: Output
        get() = javaResource.path().applyValue({ args0 -> args0 })
}

public object VariableMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.nomad.Variable::class == javaResource::class

    override fun map(javaResource: Resource): Variable = Variable(
        javaResource as
            com.pulumi.nomad.Variable,
    )
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy