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

com.pulumi.azure.backup.kotlin.PolicyVMWorkload.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.backup.kotlin

import com.pulumi.azure.backup.kotlin.outputs.PolicyVMWorkloadProtectionPolicy
import com.pulumi.azure.backup.kotlin.outputs.PolicyVMWorkloadSettings
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.List
import com.pulumi.azure.backup.kotlin.outputs.PolicyVMWorkloadProtectionPolicy.Companion.toKotlin as policyVMWorkloadProtectionPolicyToKotlin
import com.pulumi.azure.backup.kotlin.outputs.PolicyVMWorkloadSettings.Companion.toKotlin as policyVMWorkloadSettingsToKotlin

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

    public var args: PolicyVMWorkloadArgs = PolicyVMWorkloadArgs()

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

/**
 * Manages an Azure VM Workload Backup Policy within a Recovery Services vault.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-bpvmw",
 *     location: "West Europe",
 * });
 * const exampleVault = new azure.recoveryservices.Vault("example", {
 *     name: "example-rsv",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     sku: "Standard",
 *     softDeleteEnabled: false,
 * });
 * const examplePolicyVMWorkload = new azure.backup.PolicyVMWorkload("example", {
 *     name: "example-bpvmw",
 *     resourceGroupName: example.name,
 *     recoveryVaultName: exampleVault.name,
 *     workloadType: "SQLDataBase",
 *     settings: {
 *         timeZone: "UTC",
 *         compressionEnabled: false,
 *     },
 *     protectionPolicies: [
 *         {
 *             policyType: "Full",
 *             backup: {
 *                 frequency: "Daily",
 *                 time: "15:00",
 *             },
 *             retentionDaily: {
 *                 count: 8,
 *             },
 *         },
 *         {
 *             policyType: "Log",
 *             backup: {
 *                 frequencyInMinutes: 15,
 *             },
 *             simpleRetention: {
 *                 count: 8,
 *             },
 *         },
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-bpvmw",
 *     location="West Europe")
 * example_vault = azure.recoveryservices.Vault("example",
 *     name="example-rsv",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     sku="Standard",
 *     soft_delete_enabled=False)
 * example_policy_vm_workload = azure.backup.PolicyVMWorkload("example",
 *     name="example-bpvmw",
 *     resource_group_name=example.name,
 *     recovery_vault_name=example_vault.name,
 *     workload_type="SQLDataBase",
 *     settings={
 *         "time_zone": "UTC",
 *         "compression_enabled": False,
 *     },
 *     protection_policies=[
 *         {
 *             "policy_type": "Full",
 *             "backup": {
 *                 "frequency": "Daily",
 *                 "time": "15:00",
 *             },
 *             "retention_daily": {
 *                 "count": 8,
 *             },
 *         },
 *         {
 *             "policy_type": "Log",
 *             "backup": {
 *                 "frequency_in_minutes": 15,
 *             },
 *             "simple_retention": {
 *                 "count": 8,
 *             },
 *         },
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-bpvmw",
 *         Location = "West Europe",
 *     });
 *     var exampleVault = new Azure.RecoveryServices.Vault("example", new()
 *     {
 *         Name = "example-rsv",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         Sku = "Standard",
 *         SoftDeleteEnabled = false,
 *     });
 *     var examplePolicyVMWorkload = new Azure.Backup.PolicyVMWorkload("example", new()
 *     {
 *         Name = "example-bpvmw",
 *         ResourceGroupName = example.Name,
 *         RecoveryVaultName = exampleVault.Name,
 *         WorkloadType = "SQLDataBase",
 *         Settings = new Azure.Backup.Inputs.PolicyVMWorkloadSettingsArgs
 *         {
 *             TimeZone = "UTC",
 *             CompressionEnabled = false,
 *         },
 *         ProtectionPolicies = new[]
 *         {
 *             new Azure.Backup.Inputs.PolicyVMWorkloadProtectionPolicyArgs
 *             {
 *                 PolicyType = "Full",
 *                 Backup = new Azure.Backup.Inputs.PolicyVMWorkloadProtectionPolicyBackupArgs
 *                 {
 *                     Frequency = "Daily",
 *                     Time = "15:00",
 *                 },
 *                 RetentionDaily = new Azure.Backup.Inputs.PolicyVMWorkloadProtectionPolicyRetentionDailyArgs
 *                 {
 *                     Count = 8,
 *                 },
 *             },
 *             new Azure.Backup.Inputs.PolicyVMWorkloadProtectionPolicyArgs
 *             {
 *                 PolicyType = "Log",
 *                 Backup = new Azure.Backup.Inputs.PolicyVMWorkloadProtectionPolicyBackupArgs
 *                 {
 *                     FrequencyInMinutes = 15,
 *                 },
 *                 SimpleRetention = new Azure.Backup.Inputs.PolicyVMWorkloadProtectionPolicySimpleRetentionArgs
 *                 {
 *                     Count = 8,
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/backup"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/recoveryservices"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-bpvmw"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleVault, err := recoveryservices.NewVault(ctx, "example", &recoveryservices.VaultArgs{
 * 			Name:              pulumi.String("example-rsv"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			Sku:               pulumi.String("Standard"),
 * 			SoftDeleteEnabled: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = backup.NewPolicyVMWorkload(ctx, "example", &backup.PolicyVMWorkloadArgs{
 * 			Name:              pulumi.String("example-bpvmw"),
 * 			ResourceGroupName: example.Name,
 * 			RecoveryVaultName: exampleVault.Name,
 * 			WorkloadType:      pulumi.String("SQLDataBase"),
 * 			Settings: &backup.PolicyVMWorkloadSettingsArgs{
 * 				TimeZone:           pulumi.String("UTC"),
 * 				CompressionEnabled: pulumi.Bool(false),
 * 			},
 * 			ProtectionPolicies: backup.PolicyVMWorkloadProtectionPolicyArray{
 * 				&backup.PolicyVMWorkloadProtectionPolicyArgs{
 * 					PolicyType: pulumi.String("Full"),
 * 					Backup: &backup.PolicyVMWorkloadProtectionPolicyBackupArgs{
 * 						Frequency: pulumi.String("Daily"),
 * 						Time:      pulumi.String("15:00"),
 * 					},
 * 					RetentionDaily: &backup.PolicyVMWorkloadProtectionPolicyRetentionDailyArgs{
 * 						Count: pulumi.Int(8),
 * 					},
 * 				},
 * 				&backup.PolicyVMWorkloadProtectionPolicyArgs{
 * 					PolicyType: pulumi.String("Log"),
 * 					Backup: &backup.PolicyVMWorkloadProtectionPolicyBackupArgs{
 * 						FrequencyInMinutes: pulumi.Int(15),
 * 					},
 * 					SimpleRetention: &backup.PolicyVMWorkloadProtectionPolicySimpleRetentionArgs{
 * 						Count: pulumi.Int(8),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.recoveryservices.Vault;
 * import com.pulumi.azure.recoveryservices.VaultArgs;
 * import com.pulumi.azure.backup.PolicyVMWorkload;
 * import com.pulumi.azure.backup.PolicyVMWorkloadArgs;
 * import com.pulumi.azure.backup.inputs.PolicyVMWorkloadSettingsArgs;
 * import com.pulumi.azure.backup.inputs.PolicyVMWorkloadProtectionPolicyArgs;
 * import com.pulumi.azure.backup.inputs.PolicyVMWorkloadProtectionPolicyBackupArgs;
 * import com.pulumi.azure.backup.inputs.PolicyVMWorkloadProtectionPolicyRetentionDailyArgs;
 * import com.pulumi.azure.backup.inputs.PolicyVMWorkloadProtectionPolicySimpleRetentionArgs;
 * 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 ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-bpvmw")
 *             .location("West Europe")
 *             .build());
 *         var exampleVault = new Vault("exampleVault", VaultArgs.builder()
 *             .name("example-rsv")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .sku("Standard")
 *             .softDeleteEnabled(false)
 *             .build());
 *         var examplePolicyVMWorkload = new PolicyVMWorkload("examplePolicyVMWorkload", PolicyVMWorkloadArgs.builder()
 *             .name("example-bpvmw")
 *             .resourceGroupName(example.name())
 *             .recoveryVaultName(exampleVault.name())
 *             .workloadType("SQLDataBase")
 *             .settings(PolicyVMWorkloadSettingsArgs.builder()
 *                 .timeZone("UTC")
 *                 .compressionEnabled(false)
 *                 .build())
 *             .protectionPolicies(
 *                 PolicyVMWorkloadProtectionPolicyArgs.builder()
 *                     .policyType("Full")
 *                     .backup(PolicyVMWorkloadProtectionPolicyBackupArgs.builder()
 *                         .frequency("Daily")
 *                         .time("15:00")
 *                         .build())
 *                     .retentionDaily(PolicyVMWorkloadProtectionPolicyRetentionDailyArgs.builder()
 *                         .count(8)
 *                         .build())
 *                     .build(),
 *                 PolicyVMWorkloadProtectionPolicyArgs.builder()
 *                     .policyType("Log")
 *                     .backup(PolicyVMWorkloadProtectionPolicyBackupArgs.builder()
 *                         .frequencyInMinutes(15)
 *                         .build())
 *                     .simpleRetention(PolicyVMWorkloadProtectionPolicySimpleRetentionArgs.builder()
 *                         .count(8)
 *                         .build())
 *                     .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-bpvmw
 *       location: West Europe
 *   exampleVault:
 *     type: azure:recoveryservices:Vault
 *     name: example
 *     properties:
 *       name: example-rsv
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       sku: Standard
 *       softDeleteEnabled: false
 *   examplePolicyVMWorkload:
 *     type: azure:backup:PolicyVMWorkload
 *     name: example
 *     properties:
 *       name: example-bpvmw
 *       resourceGroupName: ${example.name}
 *       recoveryVaultName: ${exampleVault.name}
 *       workloadType: SQLDataBase
 *       settings:
 *         timeZone: UTC
 *         compressionEnabled: false
 *       protectionPolicies:
 *         - policyType: Full
 *           backup:
 *             frequency: Daily
 *             time: 15:00
 *           retentionDaily:
 *             count: 8
 *         - policyType: Log
 *           backup:
 *             frequencyInMinutes: 15
 *           simpleRetention:
 *             count: 8
 * ```
 * 
 * ## Import
 * Azure VM Workload Backup Policies can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:backup/policyVMWorkload:PolicyVMWorkload policy1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.RecoveryServices/vaults/vault1/backupPolicies/policy1
 * ```
 */
public class PolicyVMWorkload internal constructor(
    override val javaResource: com.pulumi.azure.backup.PolicyVMWorkload,
) : KotlinCustomResource(javaResource, PolicyVMWorkloadMapper) {
    /**
     * The name of the VM Workload Backup Policy. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * One or more `protection_policy` blocks as defined below.
     */
    public val protectionPolicies: Output>
        get() = javaResource.protectionPolicies().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> policyVMWorkloadProtectionPolicyToKotlin(args0) })
            })
        })

    /**
     * The name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
     */
    public val recoveryVaultName: Output
        get() = javaResource.recoveryVaultName().applyValue({ args0 -> args0 })

    /**
     * The name of the resource group in which to create the VM Workload Backup Policy. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * A `settings` block as defined below.
     */
    public val settings: Output
        get() = javaResource.settings().applyValue({ args0 ->
            args0.let({ args0 ->
                policyVMWorkloadSettingsToKotlin(args0)
            })
        })

    /**
     * The VM Workload type for the Backup Policy. Possible values are `SQLDataBase` and `SAPHanaDatabase`. Changing this forces a new resource to be created.
     */
    public val workloadType: Output
        get() = javaResource.workloadType().applyValue({ args0 -> args0 })
}

public object PolicyVMWorkloadMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.backup.PolicyVMWorkload::class == javaResource::class

    override fun map(javaResource: Resource): PolicyVMWorkload = PolicyVMWorkload(
        javaResource as
            com.pulumi.azure.backup.PolicyVMWorkload,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy