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

com.pulumi.azure.mariadb.kotlin.Database.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.mariadb.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

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

    public var args: DatabaseArgs = DatabaseArgs()

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

/**
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "tfex-mariadb-database-RG",
 *     location: "West Europe",
 * });
 * const exampleServer = new azure.mariadb.Server("example", {
 *     name: "mariadb-svr",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     skuName: "B_Gen5_2",
 *     storageMb: 51200,
 *     backupRetentionDays: 7,
 *     geoRedundantBackupEnabled: false,
 *     administratorLogin: "acctestun",
 *     administratorLoginPassword: "H@Sh1CoR3!",
 *     version: "10.2",
 *     sslEnforcementEnabled: true,
 * });
 * const exampleDatabase = new azure.mariadb.Database("example", {
 *     name: "mariadb_database",
 *     resourceGroupName: example.name,
 *     serverName: exampleServer.name,
 *     charset: "utf8mb4",
 *     collation: "utf8mb4_unicode_520_ci",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="tfex-mariadb-database-RG",
 *     location="West Europe")
 * example_server = azure.mariadb.Server("example",
 *     name="mariadb-svr",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     sku_name="B_Gen5_2",
 *     storage_mb=51200,
 *     backup_retention_days=7,
 *     geo_redundant_backup_enabled=False,
 *     administrator_login="acctestun",
 *     administrator_login_password="H@Sh1CoR3!",
 *     version="10.2",
 *     ssl_enforcement_enabled=True)
 * example_database = azure.mariadb.Database("example",
 *     name="mariadb_database",
 *     resource_group_name=example.name,
 *     server_name=example_server.name,
 *     charset="utf8mb4",
 *     collation="utf8mb4_unicode_520_ci")
 * ```
 * ```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 = "tfex-mariadb-database-RG",
 *         Location = "West Europe",
 *     });
 *     var exampleServer = new Azure.MariaDB.Server("example", new()
 *     {
 *         Name = "mariadb-svr",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         SkuName = "B_Gen5_2",
 *         StorageMb = 51200,
 *         BackupRetentionDays = 7,
 *         GeoRedundantBackupEnabled = false,
 *         AdministratorLogin = "acctestun",
 *         AdministratorLoginPassword = "H@Sh1CoR3!",
 *         Version = "10.2",
 *         SslEnforcementEnabled = true,
 *     });
 *     var exampleDatabase = new Azure.MariaDB.Database("example", new()
 *     {
 *         Name = "mariadb_database",
 *         ResourceGroupName = example.Name,
 *         ServerName = exampleServer.Name,
 *         Charset = "utf8mb4",
 *         Collation = "utf8mb4_unicode_520_ci",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/mariadb"
 * 	"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("tfex-mariadb-database-RG"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleServer, err := mariadb.NewServer(ctx, "example", &mariadb.ServerArgs{
 * 			Name:                       pulumi.String("mariadb-svr"),
 * 			Location:                   example.Location,
 * 			ResourceGroupName:          example.Name,
 * 			SkuName:                    pulumi.String("B_Gen5_2"),
 * 			StorageMb:                  pulumi.Int(51200),
 * 			BackupRetentionDays:        pulumi.Int(7),
 * 			GeoRedundantBackupEnabled:  pulumi.Bool(false),
 * 			AdministratorLogin:         pulumi.String("acctestun"),
 * 			AdministratorLoginPassword: pulumi.String("H@Sh1CoR3!"),
 * 			Version:                    pulumi.String("10.2"),
 * 			SslEnforcementEnabled:      pulumi.Bool(true),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = mariadb.NewDatabase(ctx, "example", &mariadb.DatabaseArgs{
 * 			Name:              pulumi.String("mariadb_database"),
 * 			ResourceGroupName: example.Name,
 * 			ServerName:        exampleServer.Name,
 * 			Charset:           pulumi.String("utf8mb4"),
 * 			Collation:         pulumi.String("utf8mb4_unicode_520_ci"),
 * 		})
 * 		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.mariadb.Server;
 * import com.pulumi.azure.mariadb.ServerArgs;
 * import com.pulumi.azure.mariadb.Database;
 * import com.pulumi.azure.mariadb.DatabaseArgs;
 * 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("tfex-mariadb-database-RG")
 *             .location("West Europe")
 *             .build());
 *         var exampleServer = new Server("exampleServer", ServerArgs.builder()
 *             .name("mariadb-svr")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .skuName("B_Gen5_2")
 *             .storageMb(51200)
 *             .backupRetentionDays(7)
 *             .geoRedundantBackupEnabled(false)
 *             .administratorLogin("acctestun")
 *             .administratorLoginPassword("H@Sh1CoR3!")
 *             .version("10.2")
 *             .sslEnforcementEnabled(true)
 *             .build());
 *         var exampleDatabase = new Database("exampleDatabase", DatabaseArgs.builder()
 *             .name("mariadb_database")
 *             .resourceGroupName(example.name())
 *             .serverName(exampleServer.name())
 *             .charset("utf8mb4")
 *             .collation("utf8mb4_unicode_520_ci")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: tfex-mariadb-database-RG
 *       location: West Europe
 *   exampleServer:
 *     type: azure:mariadb:Server
 *     name: example
 *     properties:
 *       name: mariadb-svr
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       skuName: B_Gen5_2
 *       storageMb: 51200
 *       backupRetentionDays: 7
 *       geoRedundantBackupEnabled: false
 *       administratorLogin: acctestun
 *       administratorLoginPassword: H@Sh1CoR3!
 *       version: '10.2'
 *       sslEnforcementEnabled: true
 *   exampleDatabase:
 *     type: azure:mariadb:Database
 *     name: example
 *     properties:
 *       name: mariadb_database
 *       resourceGroupName: ${example.name}
 *       serverName: ${exampleServer.name}
 *       charset: utf8mb4
 *       collation: utf8mb4_unicode_520_ci
 * ```
 * 
 * ## Import
 * MariaDB Database's can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:mariadb/database:Database database1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.DBforMariaDB/servers/server1/databases/database1
 * ```
 */
public class Database internal constructor(
    override val javaResource: com.pulumi.azure.mariadb.Database,
) : KotlinCustomResource(javaResource, DatabaseMapper) {
    /**
     * Specifies the Charset for the MariaDB Database, which needs [to be a valid MariaDB Charset](https://mariadb.com/kb/en/library/setting-character-sets-and-collations). Changing this forces a new resource to be created.
     */
    public val charset: Output
        get() = javaResource.charset().applyValue({ args0 -> args0 })

    /**
     * Specifies the Collation for the MariaDB Database, which needs [to be a valid MariaDB Collation](https://mariadb.com/kb/en/library/setting-character-sets-and-collations). Changing this forces a new resource to be created.
     */
    public val collation: Output
        get() = javaResource.collation().applyValue({ args0 -> args0 })

    /**
     * Specifies the name of the MariaDB Database, which needs [to be a valid MariaDB identifier](https://mariadb.com/kb/en/library/identifier-names/). Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

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

    /**
     * Specifies the name of the MariaDB Server. Changing this forces a new resource to be created.
     */
    public val serverName: Output
        get() = javaResource.serverName().applyValue({ args0 -> args0 })
}

public object DatabaseMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.mariadb.Database::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy