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

com.pulumi.cloudflare.kotlin.WorkersKv.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: 5.40.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.cloudflare.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.String
import kotlin.Suppress
import kotlin.Unit

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

    public var args: WorkersKvArgs = WorkersKvArgs()

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

/**
 * Provides a resource to manage a Cloudflare Workers KV Pair.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as cloudflare from "@pulumi/cloudflare";
 * const exampleNs = new cloudflare.WorkersKvNamespace("example_ns", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     title: "test-namespace",
 * });
 * const example = new cloudflare.WorkersKv("example", {
 *     accountId: "f037e56e89293a057740de681ac9abbe",
 *     namespaceId: exampleNs.id,
 *     key: "test-key",
 *     value: "test value",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_cloudflare as cloudflare
 * example_ns = cloudflare.WorkersKvNamespace("example_ns",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     title="test-namespace")
 * example = cloudflare.WorkersKv("example",
 *     account_id="f037e56e89293a057740de681ac9abbe",
 *     namespace_id=example_ns.id,
 *     key="test-key",
 *     value="test value")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Cloudflare = Pulumi.Cloudflare;
 * return await Deployment.RunAsync(() =>
 * {
 *     var exampleNs = new Cloudflare.WorkersKvNamespace("example_ns", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         Title = "test-namespace",
 *     });
 *     var example = new Cloudflare.WorkersKv("example", new()
 *     {
 *         AccountId = "f037e56e89293a057740de681ac9abbe",
 *         NamespaceId = exampleNs.Id,
 *         Key = "test-key",
 *         Value = "test value",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"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 {
 * 		exampleNs, err := cloudflare.NewWorkersKvNamespace(ctx, "example_ns", &cloudflare.WorkersKvNamespaceArgs{
 * 			AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			Title:     pulumi.String("test-namespace"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = cloudflare.NewWorkersKv(ctx, "example", &cloudflare.WorkersKvArgs{
 * 			AccountId:   pulumi.String("f037e56e89293a057740de681ac9abbe"),
 * 			NamespaceId: exampleNs.ID(),
 * 			Key:         pulumi.String("test-key"),
 * 			Value:       pulumi.String("test 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.cloudflare.WorkersKvNamespace;
 * import com.pulumi.cloudflare.WorkersKvNamespaceArgs;
 * import com.pulumi.cloudflare.WorkersKv;
 * import com.pulumi.cloudflare.WorkersKvArgs;
 * 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 exampleNs = new WorkersKvNamespace("exampleNs", WorkersKvNamespaceArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .title("test-namespace")
 *             .build());
 *         var example = new WorkersKv("example", WorkersKvArgs.builder()
 *             .accountId("f037e56e89293a057740de681ac9abbe")
 *             .namespaceId(exampleNs.id())
 *             .key("test-key")
 *             .value("test value")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   exampleNs:
 *     type: cloudflare:WorkersKvNamespace
 *     name: example_ns
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       title: test-namespace
 *   example:
 *     type: cloudflare:WorkersKv
 *     properties:
 *       accountId: f037e56e89293a057740de681ac9abbe
 *       namespaceId: ${exampleNs.id}
 *       key: test-key
 *       value: test value
 * ```
 * 
 * ## Import
 * ```sh
 * $ pulumi import cloudflare:index/workersKv:WorkersKv example //
 * ```
 */
public class WorkersKv internal constructor(
    override val javaResource: com.pulumi.cloudflare.WorkersKv,
) : KotlinCustomResource(javaResource, WorkersKvMapper) {
    /**
     * The account identifier to target for the resource.
     */
    public val accountId: Output
        get() = javaResource.accountId().applyValue({ args0 -> args0 })

    /**
     * Name of the KV pair. **Modifying this attribute will force creation of a new resource.**
     */
    public val key: Output
        get() = javaResource.key().applyValue({ args0 -> args0 })

    /**
     * The ID of the Workers KV namespace in which you want to create the KV pair. **Modifying this attribute will force creation of a new resource.**
     */
    public val namespaceId: Output
        get() = javaResource.namespaceId().applyValue({ args0 -> args0 })

    /**
     * Value of the KV pair.
     */
    public val `value`: Output
        get() = javaResource.`value`().applyValue({ args0 -> args0 })
}

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy