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

com.pulumi.gcp.firestore.kotlin.BackupSchedule.kt Maven / Gradle / Ivy

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

package com.pulumi.gcp.firestore.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.firestore.kotlin.outputs.BackupScheduleDailyRecurrence
import com.pulumi.gcp.firestore.kotlin.outputs.BackupScheduleWeeklyRecurrence
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 com.pulumi.gcp.firestore.kotlin.outputs.BackupScheduleDailyRecurrence.Companion.toKotlin as backupScheduleDailyRecurrenceToKotlin
import com.pulumi.gcp.firestore.kotlin.outputs.BackupScheduleWeeklyRecurrence.Companion.toKotlin as backupScheduleWeeklyRecurrenceToKotlin

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

    public var args: BackupScheduleArgs = BackupScheduleArgs()

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

/**
 * A backup schedule for a Cloud Firestore Database.
 * This resource is owned by the database it is backing up, and is deleted along with the database.
 * The actual backups are not though.
 * To get more information about BackupSchedule, see:
 * * [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.backupSchedules)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/firestore/docs/backups)
 * > **Warning:** This resource creates a Firestore Backup Schedule on a project that already has
 * a Firestore database.
 * This resource is owned by the database it is backing up, and is deleted along
 * with the database. The actual backups are not though.
 * ## Example Usage
 * ### Firestore Backup Schedule Daily
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const database = new gcp.firestore.Database("database", {
 *     project: "my-project-name",
 *     name: "database-id",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     deleteProtectionState: "DELETE_PROTECTION_ENABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const daily_backup = new gcp.firestore.BackupSchedule("daily-backup", {
 *     project: "my-project-name",
 *     database: database.name,
 *     retention: "8467200s",
 *     dailyRecurrence: {},
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * database = gcp.firestore.Database("database",
 *     project="my-project-name",
 *     name="database-id",
 *     location_id="nam5",
 *     type="FIRESTORE_NATIVE",
 *     delete_protection_state="DELETE_PROTECTION_ENABLED",
 *     deletion_policy="DELETE")
 * daily_backup = gcp.firestore.BackupSchedule("daily-backup",
 *     project="my-project-name",
 *     database=database.name,
 *     retention="8467200s",
 *     daily_recurrence={})
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var database = new Gcp.Firestore.Database("database", new()
 *     {
 *         Project = "my-project-name",
 *         Name = "database-id",
 *         LocationId = "nam5",
 *         Type = "FIRESTORE_NATIVE",
 *         DeleteProtectionState = "DELETE_PROTECTION_ENABLED",
 *         DeletionPolicy = "DELETE",
 *     });
 *     var daily_backup = new Gcp.Firestore.BackupSchedule("daily-backup", new()
 *     {
 *         Project = "my-project-name",
 *         Database = database.Name,
 *         Retention = "8467200s",
 *         DailyRecurrence = null,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firestore"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		database, err := firestore.NewDatabase(ctx, "database", &firestore.DatabaseArgs{
 * 			Project:               pulumi.String("my-project-name"),
 * 			Name:                  pulumi.String("database-id"),
 * 			LocationId:            pulumi.String("nam5"),
 * 			Type:                  pulumi.String("FIRESTORE_NATIVE"),
 * 			DeleteProtectionState: pulumi.String("DELETE_PROTECTION_ENABLED"),
 * 			DeletionPolicy:        pulumi.String("DELETE"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = firestore.NewBackupSchedule(ctx, "daily-backup", &firestore.BackupScheduleArgs{
 * 			Project:         pulumi.String("my-project-name"),
 * 			Database:        database.Name,
 * 			Retention:       pulumi.String("8467200s"),
 * 			DailyRecurrence: nil,
 * 		})
 * 		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.firestore.Database;
 * import com.pulumi.gcp.firestore.DatabaseArgs;
 * import com.pulumi.gcp.firestore.BackupSchedule;
 * import com.pulumi.gcp.firestore.BackupScheduleArgs;
 * import com.pulumi.gcp.firestore.inputs.BackupScheduleDailyRecurrenceArgs;
 * 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 database = new Database("database", DatabaseArgs.builder()
 *             .project("my-project-name")
 *             .name("database-id")
 *             .locationId("nam5")
 *             .type("FIRESTORE_NATIVE")
 *             .deleteProtectionState("DELETE_PROTECTION_ENABLED")
 *             .deletionPolicy("DELETE")
 *             .build());
 *         var daily_backup = new BackupSchedule("daily-backup", BackupScheduleArgs.builder()
 *             .project("my-project-name")
 *             .database(database.name())
 *             .retention("8467200s")
 *             .dailyRecurrence()
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   database:
 *     type: gcp:firestore:Database
 *     properties:
 *       project: my-project-name
 *       name: database-id
 *       locationId: nam5
 *       type: FIRESTORE_NATIVE
 *       deleteProtectionState: DELETE_PROTECTION_ENABLED
 *       deletionPolicy: DELETE
 *   daily-backup:
 *     type: gcp:firestore:BackupSchedule
 *     properties:
 *       project: my-project-name
 *       database: ${database.name}
 *       retention: 8467200s
 *       dailyRecurrence: {}
 * ```
 * 
 * ### Firestore Backup Schedule Weekly
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const database = new gcp.firestore.Database("database", {
 *     project: "my-project-name",
 *     name: "database-id",
 *     locationId: "nam5",
 *     type: "FIRESTORE_NATIVE",
 *     deleteProtectionState: "DELETE_PROTECTION_ENABLED",
 *     deletionPolicy: "DELETE",
 * });
 * const weekly_backup = new gcp.firestore.BackupSchedule("weekly-backup", {
 *     project: "my-project-name",
 *     database: database.name,
 *     retention: "8467200s",
 *     weeklyRecurrence: {
 *         day: "SUNDAY",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * database = gcp.firestore.Database("database",
 *     project="my-project-name",
 *     name="database-id",
 *     location_id="nam5",
 *     type="FIRESTORE_NATIVE",
 *     delete_protection_state="DELETE_PROTECTION_ENABLED",
 *     deletion_policy="DELETE")
 * weekly_backup = gcp.firestore.BackupSchedule("weekly-backup",
 *     project="my-project-name",
 *     database=database.name,
 *     retention="8467200s",
 *     weekly_recurrence={
 *         "day": "SUNDAY",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var database = new Gcp.Firestore.Database("database", new()
 *     {
 *         Project = "my-project-name",
 *         Name = "database-id",
 *         LocationId = "nam5",
 *         Type = "FIRESTORE_NATIVE",
 *         DeleteProtectionState = "DELETE_PROTECTION_ENABLED",
 *         DeletionPolicy = "DELETE",
 *     });
 *     var weekly_backup = new Gcp.Firestore.BackupSchedule("weekly-backup", new()
 *     {
 *         Project = "my-project-name",
 *         Database = database.Name,
 *         Retention = "8467200s",
 *         WeeklyRecurrence = new Gcp.Firestore.Inputs.BackupScheduleWeeklyRecurrenceArgs
 *         {
 *             Day = "SUNDAY",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firestore"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		database, err := firestore.NewDatabase(ctx, "database", &firestore.DatabaseArgs{
 * 			Project:               pulumi.String("my-project-name"),
 * 			Name:                  pulumi.String("database-id"),
 * 			LocationId:            pulumi.String("nam5"),
 * 			Type:                  pulumi.String("FIRESTORE_NATIVE"),
 * 			DeleteProtectionState: pulumi.String("DELETE_PROTECTION_ENABLED"),
 * 			DeletionPolicy:        pulumi.String("DELETE"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = firestore.NewBackupSchedule(ctx, "weekly-backup", &firestore.BackupScheduleArgs{
 * 			Project:   pulumi.String("my-project-name"),
 * 			Database:  database.Name,
 * 			Retention: pulumi.String("8467200s"),
 * 			WeeklyRecurrence: &firestore.BackupScheduleWeeklyRecurrenceArgs{
 * 				Day: pulumi.String("SUNDAY"),
 * 			},
 * 		})
 * 		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.firestore.Database;
 * import com.pulumi.gcp.firestore.DatabaseArgs;
 * import com.pulumi.gcp.firestore.BackupSchedule;
 * import com.pulumi.gcp.firestore.BackupScheduleArgs;
 * import com.pulumi.gcp.firestore.inputs.BackupScheduleWeeklyRecurrenceArgs;
 * 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 database = new Database("database", DatabaseArgs.builder()
 *             .project("my-project-name")
 *             .name("database-id")
 *             .locationId("nam5")
 *             .type("FIRESTORE_NATIVE")
 *             .deleteProtectionState("DELETE_PROTECTION_ENABLED")
 *             .deletionPolicy("DELETE")
 *             .build());
 *         var weekly_backup = new BackupSchedule("weekly-backup", BackupScheduleArgs.builder()
 *             .project("my-project-name")
 *             .database(database.name())
 *             .retention("8467200s")
 *             .weeklyRecurrence(BackupScheduleWeeklyRecurrenceArgs.builder()
 *                 .day("SUNDAY")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   database:
 *     type: gcp:firestore:Database
 *     properties:
 *       project: my-project-name
 *       name: database-id
 *       locationId: nam5
 *       type: FIRESTORE_NATIVE
 *       deleteProtectionState: DELETE_PROTECTION_ENABLED
 *       deletionPolicy: DELETE
 *   weekly-backup:
 *     type: gcp:firestore:BackupSchedule
 *     properties:
 *       project: my-project-name
 *       database: ${database.name}
 *       retention: 8467200s
 *       weeklyRecurrence:
 *         day: SUNDAY
 * ```
 * 
 * ## Import
 * BackupSchedule can be imported using any of these accepted formats:
 * * `projects/{{project}}/databases/{{database}}/backupSchedules/{{name}}`
 * * `{{project}}/{{database}}/{{name}}`
 * * `{{database}}/{{name}}`
 * When using the `pulumi import` command, BackupSchedule can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:firestore/backupSchedule:BackupSchedule default projects/{{project}}/databases/{{database}}/backupSchedules/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:firestore/backupSchedule:BackupSchedule default {{project}}/{{database}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:firestore/backupSchedule:BackupSchedule default {{database}}/{{name}}
 * ```
 */
public class BackupSchedule internal constructor(
    override val javaResource: com.pulumi.gcp.firestore.BackupSchedule,
) : KotlinCustomResource(javaResource, BackupScheduleMapper) {
    /**
     * For a schedule that runs daily.
     */
    public val dailyRecurrence: Output?
        get() = javaResource.dailyRecurrence().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> backupScheduleDailyRecurrenceToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The Firestore database id. Defaults to `"(default)"`.
     */
    public val database: Output?
        get() = javaResource.database().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The unique backup schedule identifier across all locations and databases for the given project. Format:
     * `projects/{{project}}/databases/{{database}}/backupSchedules/{{backupSchedule}}`
     */
    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 })

    /**
     * At what relative time in the future, compared to its creation time, the backup should be deleted, e.g. keep backups for 7 days.
     * A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".
     * You can set this to a value up to 14 weeks.
     * - - -
     */
    public val retention: Output
        get() = javaResource.retention().applyValue({ args0 -> args0 })

    /**
     * For a schedule that runs weekly on a specific day.
     * Structure is documented below.
     */
    public val weeklyRecurrence: Output?
        get() = javaResource.weeklyRecurrence().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> backupScheduleWeeklyRecurrenceToKotlin(args0) })
            }).orElse(null)
        })
}

public object BackupScheduleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.firestore.BackupSchedule::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy