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

com.pulumi.azurenative.sql.kotlin.BackupLongTermRetentionPolicy.kt Maven / Gradle / Ivy

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

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

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

    public var args: BackupLongTermRetentionPolicyArgs = BackupLongTermRetentionPolicyArgs()

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

/**
 * A long term retention policy.
 * Azure REST API version: 2017-03-01-preview.
 * ## Example Usage
 * ### Create or update the long term retention policy for the database.
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using AzureNative = Pulumi.AzureNative;
 * return await Deployment.RunAsync(() =>
 * {
 *     var backupLongTermRetentionPolicy = new AzureNative.Sql.BackupLongTermRetentionPolicy("backupLongTermRetentionPolicy", new()
 *     {
 *         DatabaseName = "testDatabase",
 *         MonthlyRetention = "P1Y",
 *         PolicyName = "default",
 *         ResourceGroupName = "resourceGroup",
 *         ServerName = "testserver",
 *         WeekOfYear = 5,
 *         WeeklyRetention = "P1M",
 *         YearlyRetention = "P5Y",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	sql "github.com/pulumi/pulumi-azure-native-sdk/sql/v2"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := sql.NewBackupLongTermRetentionPolicy(ctx, "backupLongTermRetentionPolicy", &sql.BackupLongTermRetentionPolicyArgs{
 * 			DatabaseName:      pulumi.String("testDatabase"),
 * 			MonthlyRetention:  pulumi.String("P1Y"),
 * 			PolicyName:        pulumi.String("default"),
 * 			ResourceGroupName: pulumi.String("resourceGroup"),
 * 			ServerName:        pulumi.String("testserver"),
 * 			WeekOfYear:        pulumi.Int(5),
 * 			WeeklyRetention:   pulumi.String("P1M"),
 * 			YearlyRetention:   pulumi.String("P5Y"),
 * 		})
 * 		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.azurenative.sql.BackupLongTermRetentionPolicy;
 * import com.pulumi.azurenative.sql.BackupLongTermRetentionPolicyArgs;
 * 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 backupLongTermRetentionPolicy = new BackupLongTermRetentionPolicy("backupLongTermRetentionPolicy", BackupLongTermRetentionPolicyArgs.builder()
 *             .databaseName("testDatabase")
 *             .monthlyRetention("P1Y")
 *             .policyName("default")
 *             .resourceGroupName("resourceGroup")
 *             .serverName("testserver")
 *             .weekOfYear(5)
 *             .weeklyRetention("P1M")
 *             .yearlyRetention("P5Y")
 *             .build());
 *     }
 * }
 * ```
 * ## Import
 * An existing resource can be imported using its type token, name, and identifier, e.g.
 * ```sh
 * $ pulumi import azure-native:sql:BackupLongTermRetentionPolicy default /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}
 * ```
 */
public class BackupLongTermRetentionPolicy internal constructor(
    override val javaResource: com.pulumi.azurenative.sql.BackupLongTermRetentionPolicy,
) : KotlinCustomResource(javaResource, BackupLongTermRetentionPolicyMapper) {
    /**
     * The monthly retention policy for an LTR backup in an ISO 8601 format.
     */
    public val monthlyRetention: Output?
        get() = javaResource.monthlyRetention().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Resource name.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Resource type.
     */
    public val type: Output
        get() = javaResource.type().applyValue({ args0 -> args0 })

    /**
     * The week of year to take the yearly backup in an ISO 8601 format.
     */
    public val weekOfYear: Output?
        get() = javaResource.weekOfYear().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The weekly retention policy for an LTR backup in an ISO 8601 format.
     */
    public val weeklyRetention: Output?
        get() = javaResource.weeklyRetention().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The yearly retention policy for an LTR backup in an ISO 8601 format.
     */
    public val yearlyRetention: Output?
        get() = javaResource.yearlyRetention().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object BackupLongTermRetentionPolicyMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azurenative.sql.BackupLongTermRetentionPolicy::class == javaResource::class

    override fun map(javaResource: Resource): BackupLongTermRetentionPolicy =
        BackupLongTermRetentionPolicy(
            javaResource as
                com.pulumi.azurenative.sql.BackupLongTermRetentionPolicy,
        )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy