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

com.pulumi.gcp.storage.kotlin.BucketObject.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: 8.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.storage.kotlin

import com.pulumi.asset.AssetOrArchive
import com.pulumi.core.Output
import com.pulumi.gcp.storage.kotlin.outputs.BucketObjectCustomerEncryption
import com.pulumi.gcp.storage.kotlin.outputs.BucketObjectRetention
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
import kotlin.collections.Map
import com.pulumi.gcp.storage.kotlin.outputs.BucketObjectCustomerEncryption.Companion.toKotlin as bucketObjectCustomerEncryptionToKotlin
import com.pulumi.gcp.storage.kotlin.outputs.BucketObjectRetention.Companion.toKotlin as bucketObjectRetentionToKotlin

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

    public var args: BucketObjectArgs = BucketObjectArgs()

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

/**
 * Creates a new object inside an existing bucket in Google cloud storage service (GCS).
 * [ACLs](https://cloud.google.com/storage/docs/access-control/lists) can be applied using the `gcp.storage.ObjectACL` resource.
 *  For more information see
 * [the official documentation](https://cloud.google.com/storage/docs/key-terms#objects)
 * and
 * [API](https://cloud.google.com/storage/docs/json_api/v1/objects).
 * ## Example Usage
 * Example creating a public object in an existing `image-store` bucket.
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const picture = new gcp.storage.BucketObject("picture", {
 *     name: "butterfly01",
 *     source: new pulumi.asset.FileAsset("/images/nature/garden-tiger-moth.jpg"),
 *     bucket: "image-store",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * picture = gcp.storage.BucketObject("picture",
 *     name="butterfly01",
 *     source=pulumi.FileAsset("/images/nature/garden-tiger-moth.jpg"),
 *     bucket="image-store")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var picture = new Gcp.Storage.BucketObject("picture", new()
 *     {
 *         Name = "butterfly01",
 *         Source = new FileAsset("/images/nature/garden-tiger-moth.jpg"),
 *         Bucket = "image-store",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/storage"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := storage.NewBucketObject(ctx, "picture", &storage.BucketObjectArgs{
 * 			Name:   pulumi.String("butterfly01"),
 * 			Source: pulumi.NewFileAsset("/images/nature/garden-tiger-moth.jpg"),
 * 			Bucket: pulumi.String("image-store"),
 * 		})
 * 		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.gcp.storage.BucketObject;
 * import com.pulumi.gcp.storage.BucketObjectArgs;
 * import com.pulumi.asset.FileAsset;
 * 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 picture = new BucketObject("picture", BucketObjectArgs.builder()
 *             .name("butterfly01")
 *             .source(new FileAsset("/images/nature/garden-tiger-moth.jpg"))
 *             .bucket("image-store")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   picture:
 *     type: gcp:storage:BucketObject
 *     properties:
 *       name: butterfly01
 *       source:
 *         fn::FileAsset: /images/nature/garden-tiger-moth.jpg
 *       bucket: image-store
 * ```
 * 
 * Example creating an empty folder in an existing `image-store` bucket.
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const emptyFolder = new gcp.storage.BucketObject("empty_folder", {
 *     name: "empty_folder/",
 *     content: " ",
 *     bucket: "image-store",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * empty_folder = gcp.storage.BucketObject("empty_folder",
 *     name="empty_folder/",
 *     content=" ",
 *     bucket="image-store")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var emptyFolder = new Gcp.Storage.BucketObject("empty_folder", new()
 *     {
 *         Name = "empty_folder/",
 *         Content = " ",
 *         Bucket = "image-store",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/storage"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := storage.NewBucketObject(ctx, "empty_folder", &storage.BucketObjectArgs{
 * 			Name:    pulumi.String("empty_folder/"),
 * 			Content: pulumi.String(" "),
 * 			Bucket:  pulumi.String("image-store"),
 * 		})
 * 		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.gcp.storage.BucketObject;
 * import com.pulumi.gcp.storage.BucketObjectArgs;
 * 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 emptyFolder = new BucketObject("emptyFolder", BucketObjectArgs.builder()
 *             .name("empty_folder/")
 *             .content(" ")
 *             .bucket("image-store")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   emptyFolder:
 *     type: gcp:storage:BucketObject
 *     name: empty_folder
 *     properties:
 *       name: empty_folder/
 *       content: ' '
 *       bucket: image-store
 * ```
 * 
 * ## Import
 * This resource does not support import.
 */
public class BucketObject internal constructor(
    override val javaResource: com.pulumi.gcp.storage.BucketObject,
) : KotlinCustomResource(javaResource, BucketObjectMapper) {
    /**
     * The name of the containing bucket.
     */
    public val bucket: Output
        get() = javaResource.bucket().applyValue({ args0 -> args0 })

    /**
     * [Cache-Control](https://tools.ietf.org/html/rfc7234#section-5.2)
     * directive to specify caching behavior of object data. If omitted and object is accessible to all anonymous users, the default will be public, max-age=3600
     */
    public val cacheControl: Output?
        get() = javaResource.cacheControl().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Data as `string` to be uploaded. Must be defined if `source` is not. **Note**: The `content` field is marked as sensitive.
     */
    public val content: Output
        get() = javaResource.content().applyValue({ args0 -> args0 })

    /**
     * [Content-Disposition](https://tools.ietf.org/html/rfc6266) of the object data.
     */
    public val contentDisposition: Output?
        get() = javaResource.contentDisposition().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * [Content-Encoding](https://tools.ietf.org/html/rfc7231#section-3.1.2.2) of the object data.
     */
    public val contentEncoding: Output?
        get() = javaResource.contentEncoding().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * [Content-Language](https://tools.ietf.org/html/rfc7231#section-3.1.3.2) of the object data.
     */
    public val contentLanguage: Output?
        get() = javaResource.contentLanguage().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * [Content-Type](https://tools.ietf.org/html/rfc7231#section-3.1.1.5) of the object data. Defaults to "application/octet-stream" or "text/plain; charset=utf-8".
     */
    public val contentType: Output
        get() = javaResource.contentType().applyValue({ args0 -> args0 })

    /**
     * (Computed) Base 64 CRC32 hash of the uploaded data.
     */
    public val crc32c: Output
        get() = javaResource.crc32c().applyValue({ args0 -> args0 })

    /**
     * Enables object encryption with Customer-Supplied Encryption Key (CSEK). Google [documentation about CSEK.](https://cloud.google.com/storage/docs/encryption/customer-supplied-keys)
     * Structure is documented below.
     */
    public val customerEncryption: Output?
        get() = javaResource.customerEncryption().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> bucketObjectCustomerEncryptionToKotlin(args0) })
            }).orElse(null)
        })

    public val detectMd5hash: Output?
        get() = javaResource.detectMd5hash().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Whether an object is under [event-based hold](https://cloud.google.com/storage/docs/object-holds#hold-types). Event-based hold is a way to retain objects until an event occurs, which is signified by the hold's release (i.e. this value is set to false). After being released (set to false), such objects will be subject to bucket-level retention (if any).
     */
    public val eventBasedHold: Output?
        get() = javaResource.eventBasedHold().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The resource name of the Cloud KMS key that will be used to [encrypt](https://cloud.google.com/storage/docs/encryption/using-customer-managed-keys) the object.
     */
    public val kmsKeyName: Output
        get() = javaResource.kmsKeyName().applyValue({ args0 -> args0 })

    /**
     * (Computed) Base 64 MD5 hash of the uploaded data.
     */
    public val md5hash: Output
        get() = javaResource.md5hash().applyValue({ args0 -> args0 })

    /**
     * (Computed) A url reference to download this object.
     */
    public val mediaLink: Output
        get() = javaResource.mediaLink().applyValue({ args0 -> args0 })

    /**
     * User-provided metadata, in key/value pairs.
     * One of the following is required:
     */
    public val metadata: Output>?
        get() = javaResource.metadata().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * The name of the object. If you're interpolating the name of this object, see `output_name` instead.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * (Computed) The name of the object. Use this field in interpolations with `gcp.storage.ObjectACL` to recreate
     * `gcp.storage.ObjectACL` resources when your `gcp.storage.BucketObject` is recreated.
     */
    public val outputName: Output
        get() = javaResource.outputName().applyValue({ args0 -> args0 })

    /**
     * The [object retention](http://cloud.google.com/storage/docs/object-lock) settings for the object. The retention settings allow an object to be retained until a provided date. Structure is documented below.
     */
    public val retention: Output?
        get() = javaResource.retention().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    bucketObjectRetentionToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * (Computed) A url reference to this object.
     */
    public val selfLink: Output
        get() = javaResource.selfLink().applyValue({ args0 -> args0 })

    /**
     * A path to the data you want to upload. Must be defined
     * if `content` is not.
     * - - -
     */
    public val source: Output?
        get() = javaResource.source().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The [StorageClass](https://cloud.google.com/storage/docs/storage-classes) of the new bucket object.
     * Supported values include: `MULTI_REGIONAL`, `REGIONAL`, `NEARLINE`, `COLDLINE`, `ARCHIVE`. If not provided, this defaults to the bucket's default
     * storage class or to a [standard](https://cloud.google.com/storage/docs/storage-classes#standard) class.
     */
    public val storageClass: Output
        get() = javaResource.storageClass().applyValue({ args0 -> args0 })

    /**
     * Whether an object is under [temporary hold](https://cloud.google.com/storage/docs/object-holds#hold-types). While this flag is set to true, the object is protected against deletion and overwrites.
     */
    public val temporaryHold: Output?
        get() = javaResource.temporaryHold().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object BucketObjectMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.storage.BucketObject::class == javaResource::class

    override fun map(javaResource: Resource): BucketObject = BucketObject(
        javaResource as
            com.pulumi.gcp.storage.BucketObject,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy