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

com.pulumi.digitalocean.kotlin.VolumeSnapshot.kt Maven / Gradle / Ivy

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

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

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

    public var args: VolumeSnapshotArgs = VolumeSnapshotArgs()

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

/**
 * Provides a DigitalOcean Volume Snapshot which can be used to create a snapshot from an existing volume.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as digitalocean from "@pulumi/digitalocean";
 * const foobar = new digitalocean.Volume("foobar", {
 *     region: digitalocean.Region.NYC1,
 *     name: "baz",
 *     size: 100,
 *     description: "an example volume",
 * });
 * const foobarVolumeSnapshot = new digitalocean.VolumeSnapshot("foobar", {
 *     name: "foo",
 *     volumeId: foobar.id,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_digitalocean as digitalocean
 * foobar = digitalocean.Volume("foobar",
 *     region=digitalocean.Region.NYC1,
 *     name="baz",
 *     size=100,
 *     description="an example volume")
 * foobar_volume_snapshot = digitalocean.VolumeSnapshot("foobar",
 *     name="foo",
 *     volume_id=foobar.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using DigitalOcean = Pulumi.DigitalOcean;
 * return await Deployment.RunAsync(() =>
 * {
 *     var foobar = new DigitalOcean.Volume("foobar", new()
 *     {
 *         Region = DigitalOcean.Region.NYC1,
 *         Name = "baz",
 *         Size = 100,
 *         Description = "an example volume",
 *     });
 *     var foobarVolumeSnapshot = new DigitalOcean.VolumeSnapshot("foobar", new()
 *     {
 *         Name = "foo",
 *         VolumeId = foobar.Id,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		foobar, err := digitalocean.NewVolume(ctx, "foobar", &digitalocean.VolumeArgs{
 * 			Region:      pulumi.String(digitalocean.RegionNYC1),
 * 			Name:        pulumi.String("baz"),
 * 			Size:        pulumi.Int(100),
 * 			Description: pulumi.String("an example volume"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = digitalocean.NewVolumeSnapshot(ctx, "foobar", &digitalocean.VolumeSnapshotArgs{
 * 			Name:     pulumi.String("foo"),
 * 			VolumeId: foobar.ID(),
 * 		})
 * 		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.digitalocean.Volume;
 * import com.pulumi.digitalocean.VolumeArgs;
 * import com.pulumi.digitalocean.VolumeSnapshot;
 * import com.pulumi.digitalocean.VolumeSnapshotArgs;
 * 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 foobar = new Volume("foobar", VolumeArgs.builder()
 *             .region("nyc1")
 *             .name("baz")
 *             .size(100)
 *             .description("an example volume")
 *             .build());
 *         var foobarVolumeSnapshot = new VolumeSnapshot("foobarVolumeSnapshot", VolumeSnapshotArgs.builder()
 *             .name("foo")
 *             .volumeId(foobar.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   foobar:
 *     type: digitalocean:Volume
 *     properties:
 *       region: nyc1
 *       name: baz
 *       size: 100
 *       description: an example volume
 *   foobarVolumeSnapshot:
 *     type: digitalocean:VolumeSnapshot
 *     name: foobar
 *     properties:
 *       name: foo
 *       volumeId: ${foobar.id}
 * ```
 * 
 * ## Import
 * Volume Snapshots can be imported using the `snapshot id`, e.g.
 * ```sh
 * $ pulumi import digitalocean:index/volumeSnapshot:VolumeSnapshot snapshot 506f78a4-e098-11e5-ad9f-000f53306ae1
 * ```
 */
public class VolumeSnapshot internal constructor(
    override val javaResource: com.pulumi.digitalocean.VolumeSnapshot,
) : KotlinCustomResource(javaResource, VolumeSnapshotMapper) {
    /**
     * The date and time the volume snapshot was created.
     */
    public val createdAt: Output
        get() = javaResource.createdAt().applyValue({ args0 -> args0 })

    /**
     * The minimum size in gigabytes required for a volume to be created based on this volume snapshot.
     */
    public val minDiskSize: Output
        get() = javaResource.minDiskSize().applyValue({ args0 -> args0 })

    /**
     * A name for the volume snapshot.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * A list of DigitalOcean region "slugs" indicating where the volume snapshot is available.
     */
    public val regions: Output>
        get() = javaResource.regions().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * The billable size of the volume snapshot in gigabytes.
     */
    public val size: Output
        get() = javaResource.size().applyValue({ args0 -> args0 })

    /**
     * A list of the tags to be applied to this volume snapshot.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0
                })
            }).orElse(null)
        })

    /**
     * The ID of the volume from which the volume snapshot originated.
     */
    public val volumeId: Output
        get() = javaResource.volumeId().applyValue({ args0 -> args0 })
}

public object VolumeSnapshotMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.digitalocean.VolumeSnapshot::class == javaResource::class

    override fun map(javaResource: Resource): VolumeSnapshot = VolumeSnapshot(
        javaResource as
            com.pulumi.digitalocean.VolumeSnapshot,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy