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

com.pulumi.gcp.netapp.kotlin.Backup.kt Maven / Gradle / Ivy

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

package com.pulumi.gcp.netapp.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
import kotlin.collections.Map

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

    public var args: BackupArgs = BackupArgs()

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

/**
 * NetApp Volumes supports volume backups, which are copies of your volumes
 * stored independently from the volume. Backups are stored in backup vaults,
 * which are containers for backups. If a volume is lost or deleted, you can
 * use backups to restore your data to a new volume.
 * When you create the first backup of a volume, all of the volume's used
 * data is sent to the backup vault. Subsequent backups of the same volume
 * only include data that has changed from the previous backup. This allows
 * for fast incremental-forever backups and reduces the required capacity
 * inside the backup vault.
 * You can create manual and scheduled backups. Manual backups can be taken
 * from a volume or from an existing volume snapshot. Scheduled backups
 * require a backup policy.
 * To get more information about backup, see:
 * * [API documentation](https://cloud.google.com/netapp/volumes/docs/reference/rest/v1/projects.locations.backupVaults.backups)
 * * How-to Guides
 *     * [Documentation](https://cloud.google.com/netapp/volumes/docs/protect-data/about-volume-backups)
 * ## Example Usage
 * ### Netapp Backup
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const default = gcp.compute.getNetwork({
 *     name: "",
 * });
 * const defaultStoragePool = new gcp.netapp.StoragePool("default", {
 *     name: "backup-pool",
 *     location: "us-central1",
 *     serviceLevel: "PREMIUM",
 *     capacityGib: "2048",
 *     network: _default.then(_default => _default.id),
 * });
 * const defaultBackupVault = new gcp.netapp.BackupVault("default", {
 *     name: "backup-vault",
 *     location: defaultStoragePool.location,
 * });
 * const defaultVolume = new gcp.netapp.Volume("default", {
 *     name: "backup-volume",
 *     location: defaultStoragePool.location,
 *     capacityGib: "100",
 *     shareName: "backup-volume",
 *     storagePool: defaultStoragePool.name,
 *     protocols: ["NFSV3"],
 *     deletionPolicy: "FORCE",
 *     backupConfig: {
 *         backupVault: defaultBackupVault.id,
 *     },
 * });
 * const testBackup = new gcp.netapp.Backup("test_backup", {
 *     name: "test-backup",
 *     location: defaultBackupVault.location,
 *     vaultName: defaultBackupVault.name,
 *     sourceVolume: defaultVolume.id,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default = gcp.compute.get_network(name="")
 * default_storage_pool = gcp.netapp.StoragePool("default",
 *     name="backup-pool",
 *     location="us-central1",
 *     service_level="PREMIUM",
 *     capacity_gib="2048",
 *     network=default.id)
 * default_backup_vault = gcp.netapp.BackupVault("default",
 *     name="backup-vault",
 *     location=default_storage_pool.location)
 * default_volume = gcp.netapp.Volume("default",
 *     name="backup-volume",
 *     location=default_storage_pool.location,
 *     capacity_gib="100",
 *     share_name="backup-volume",
 *     storage_pool=default_storage_pool.name,
 *     protocols=["NFSV3"],
 *     deletion_policy="FORCE",
 *     backup_config={
 *         "backup_vault": default_backup_vault.id,
 *     })
 * test_backup = gcp.netapp.Backup("test_backup",
 *     name="test-backup",
 *     location=default_backup_vault.location,
 *     vault_name=default_backup_vault.name,
 *     source_volume=default_volume.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @default = Gcp.Compute.GetNetwork.Invoke(new()
 *     {
 *         Name = "",
 *     });
 *     var defaultStoragePool = new Gcp.Netapp.StoragePool("default", new()
 *     {
 *         Name = "backup-pool",
 *         Location = "us-central1",
 *         ServiceLevel = "PREMIUM",
 *         CapacityGib = "2048",
 *         Network = @default.Apply(@default => @default.Apply(getNetworkResult => getNetworkResult.Id)),
 *     });
 *     var defaultBackupVault = new Gcp.Netapp.BackupVault("default", new()
 *     {
 *         Name = "backup-vault",
 *         Location = defaultStoragePool.Location,
 *     });
 *     var defaultVolume = new Gcp.Netapp.Volume("default", new()
 *     {
 *         Name = "backup-volume",
 *         Location = defaultStoragePool.Location,
 *         CapacityGib = "100",
 *         ShareName = "backup-volume",
 *         StoragePool = defaultStoragePool.Name,
 *         Protocols = new[]
 *         {
 *             "NFSV3",
 *         },
 *         DeletionPolicy = "FORCE",
 *         BackupConfig = new Gcp.Netapp.Inputs.VolumeBackupConfigArgs
 *         {
 *             BackupVault = defaultBackupVault.Id,
 *         },
 *     });
 *     var testBackup = new Gcp.Netapp.Backup("test_backup", new()
 *     {
 *         Name = "test-backup",
 *         Location = defaultBackupVault.Location,
 *         VaultName = defaultBackupVault.Name,
 *         SourceVolume = defaultVolume.Id,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/netapp"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_default, err := compute.LookupNetwork(ctx, &compute.LookupNetworkArgs{
 * 			Name: "",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultStoragePool, err := netapp.NewStoragePool(ctx, "default", &netapp.StoragePoolArgs{
 * 			Name:         pulumi.String("backup-pool"),
 * 			Location:     pulumi.String("us-central1"),
 * 			ServiceLevel: pulumi.String("PREMIUM"),
 * 			CapacityGib:  pulumi.String("2048"),
 * 			Network:      pulumi.String(_default.Id),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultBackupVault, err := netapp.NewBackupVault(ctx, "default", &netapp.BackupVaultArgs{
 * 			Name:     pulumi.String("backup-vault"),
 * 			Location: defaultStoragePool.Location,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultVolume, err := netapp.NewVolume(ctx, "default", &netapp.VolumeArgs{
 * 			Name:        pulumi.String("backup-volume"),
 * 			Location:    defaultStoragePool.Location,
 * 			CapacityGib: pulumi.String("100"),
 * 			ShareName:   pulumi.String("backup-volume"),
 * 			StoragePool: defaultStoragePool.Name,
 * 			Protocols: pulumi.StringArray{
 * 				pulumi.String("NFSV3"),
 * 			},
 * 			DeletionPolicy: pulumi.String("FORCE"),
 * 			BackupConfig: &netapp.VolumeBackupConfigArgs{
 * 				BackupVault: defaultBackupVault.ID(),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = netapp.NewBackup(ctx, "test_backup", &netapp.BackupArgs{
 * 			Name:         pulumi.String("test-backup"),
 * 			Location:     defaultBackupVault.Location,
 * 			VaultName:    defaultBackupVault.Name,
 * 			SourceVolume: defaultVolume.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.gcp.compute.ComputeFunctions;
 * import com.pulumi.gcp.compute.inputs.GetNetworkArgs;
 * import com.pulumi.gcp.netapp.StoragePool;
 * import com.pulumi.gcp.netapp.StoragePoolArgs;
 * import com.pulumi.gcp.netapp.BackupVault;
 * import com.pulumi.gcp.netapp.BackupVaultArgs;
 * import com.pulumi.gcp.netapp.Volume;
 * import com.pulumi.gcp.netapp.VolumeArgs;
 * import com.pulumi.gcp.netapp.inputs.VolumeBackupConfigArgs;
 * import com.pulumi.gcp.netapp.Backup;
 * import com.pulumi.gcp.netapp.BackupArgs;
 * 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) {
 *         final var default = ComputeFunctions.getNetwork(GetNetworkArgs.builder()
 *             .name("")
 *             .build());
 *         var defaultStoragePool = new StoragePool("defaultStoragePool", StoragePoolArgs.builder()
 *             .name("backup-pool")
 *             .location("us-central1")
 *             .serviceLevel("PREMIUM")
 *             .capacityGib("2048")
 *             .network(default_.id())
 *             .build());
 *         var defaultBackupVault = new BackupVault("defaultBackupVault", BackupVaultArgs.builder()
 *             .name("backup-vault")
 *             .location(defaultStoragePool.location())
 *             .build());
 *         var defaultVolume = new Volume("defaultVolume", VolumeArgs.builder()
 *             .name("backup-volume")
 *             .location(defaultStoragePool.location())
 *             .capacityGib("100")
 *             .shareName("backup-volume")
 *             .storagePool(defaultStoragePool.name())
 *             .protocols("NFSV3")
 *             .deletionPolicy("FORCE")
 *             .backupConfig(VolumeBackupConfigArgs.builder()
 *                 .backupVault(defaultBackupVault.id())
 *                 .build())
 *             .build());
 *         var testBackup = new Backup("testBackup", BackupArgs.builder()
 *             .name("test-backup")
 *             .location(defaultBackupVault.location())
 *             .vaultName(defaultBackupVault.name())
 *             .sourceVolume(defaultVolume.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   defaultStoragePool:
 *     type: gcp:netapp:StoragePool
 *     name: default
 *     properties:
 *       name: backup-pool
 *       location: us-central1
 *       serviceLevel: PREMIUM
 *       capacityGib: '2048'
 *       network: ${default.id}
 *   defaultVolume:
 *     type: gcp:netapp:Volume
 *     name: default
 *     properties:
 *       name: backup-volume
 *       location: ${defaultStoragePool.location}
 *       capacityGib: '100'
 *       shareName: backup-volume
 *       storagePool: ${defaultStoragePool.name}
 *       protocols:
 *         - NFSV3
 *       deletionPolicy: FORCE
 *       backupConfig:
 *         backupVault: ${defaultBackupVault.id}
 *   defaultBackupVault:
 *     type: gcp:netapp:BackupVault
 *     name: default
 *     properties:
 *       name: backup-vault
 *       location: ${defaultStoragePool.location}
 *   testBackup:
 *     type: gcp:netapp:Backup
 *     name: test_backup
 *     properties:
 *       name: test-backup
 *       location: ${defaultBackupVault.location}
 *       vaultName: ${defaultBackupVault.name}
 *       sourceVolume: ${defaultVolume.id}
 * variables:
 *   default:
 *     fn::invoke:
 *       Function: gcp:compute:getNetwork
 *       Arguments:
 *         name:
 * ```
 * 
 * ## Import
 * backup can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{location}}/backupVaults/{{vault_name}}/backups/{{name}}`
 * * `{{project}}/{{location}}/{{vault_name}}/{{name}}`
 * * `{{location}}/{{vault_name}}/{{name}}`
 * When using the `pulumi import` command, backup can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:netapp/backup:Backup default projects/{{project}}/locations/{{location}}/backupVaults/{{vault_name}}/backups/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:netapp/backup:Backup default {{project}}/{{location}}/{{vault_name}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:netapp/backup:Backup default {{location}}/{{vault_name}}/{{name}}
 * ```
 */
public class Backup internal constructor(
    override val javaResource: com.pulumi.gcp.netapp.Backup,
) : KotlinCustomResource(javaResource, BackupMapper) {
    /**
     * Type of backup, manually created or created by a backup policy. Possible Values : [TYPE_UNSPECIFIED, MANUAL, SCHEDULED]
     */
    public val backupType: Output
        get() = javaResource.backupType().applyValue({ args0 -> args0 })

    /**
     * Backups of a volume build incrementally on top of each other. They form a "backup chain".
     * Total size of all backups in a chain in bytes = baseline backup size + sum(incremental backup size)
     */
    public val chainStorageBytes: Output
        get() = javaResource.chainStorageBytes().applyValue({ args0 -> args0 })

    /**
     * Create time of the backup. A timestamp in RFC3339 UTC "Zulu" format. Examples: "2023-06-22T09:13:01.617Z".
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * A description of the backup with 2048 characters or less. Requests with longer descriptions will be rejected.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
     */
    public val effectiveLabels: Output>
        get() = javaResource.effectiveLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Labels as key value pairs. Example: `{ "owner": "Bob", "department": "finance", "purpose": "testing" }`.
     * **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
     * Please refer to the field `effective_labels` for all of the labels present on the resource.
     */
    public val labels: Output>?
        get() = javaResource.labels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * Location of the backup.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * The resource name of the backup. Needs to be unique per location.
     * - - -
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The combination of labels configured directly on the resource
     * and default labels configured on the provider.
     */
    public val pulumiLabels: Output>
        get() = javaResource.pulumiLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * If specified, backup will be created from the given snapshot. If not specified,
     * there will be a new snapshot taken to initiate the backup creation.
     * Format: `projects/{{projectId}}/locations/{{location}}/volumes/{{volumename}}/snapshots/{{snapshotname}}``
     */
    public val sourceSnapshot: Output?
        get() = javaResource.sourceSnapshot().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * ID of volumes this backup belongs to. Format: `projects/{{projects_id}}/locations/{{location}}/volumes/{{name}}``
     */
    public val sourceVolume: Output?
        get() = javaResource.sourceVolume().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The state of the Backup Vault. Possible Values : [STATE_UNSPECIFIED, CREATING, UPLOADING, READY, DELETING, ERROR, UPDATING]
     */
    public val state: Output
        get() = javaResource.state().applyValue({ args0 -> args0 })

    /**
     * Name of the backup vault to store the backup in.
     */
    public val vaultName: Output
        get() = javaResource.vaultName().applyValue({ args0 -> args0 })

    /**
     * Size of the file system when the backup was created. When creating a new volume from the backup, the volume capacity will have to be at least as big.
     */
    public val volumeUsageBytes: Output
        get() = javaResource.volumeUsageBytes().applyValue({ args0 -> args0 })
}

public object BackupMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.netapp.Backup::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy