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

com.pulumi.azure.sql.kotlin.SqlServer.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.sql.kotlin

import com.pulumi.azure.sql.kotlin.outputs.SqlServerIdentity
import com.pulumi.azure.sql.kotlin.outputs.SqlServerThreatDetectionPolicy
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
import com.pulumi.azure.sql.kotlin.outputs.SqlServerIdentity.Companion.toKotlin as sqlServerIdentityToKotlin
import com.pulumi.azure.sql.kotlin.outputs.SqlServerThreatDetectionPolicy.Companion.toKotlin as sqlServerThreatDetectionPolicyToKotlin

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

    public var args: SqlServerArgs = SqlServerArgs()

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

/**
 * Manages a Microsoft SQL Azure Database Server.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "database-rg",
 *     location: "West Europe",
 * });
 * const exampleAccount = new azure.storage.Account("example", {
 *     name: "examplesa",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     accountTier: "Standard",
 *     accountReplicationType: "LRS",
 * });
 * const exampleSqlServer = new azure.sql.SqlServer("example", {
 *     name: "mssqlserver",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     version: "12.0",
 *     administratorLogin: "mradministrator",
 *     administratorLoginPassword: "thisIsDog11",
 *     tags: {
 *         environment: "production",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="database-rg",
 *     location="West Europe")
 * example_account = azure.storage.Account("example",
 *     name="examplesa",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     account_tier="Standard",
 *     account_replication_type="LRS")
 * example_sql_server = azure.sql.SqlServer("example",
 *     name="mssqlserver",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     version="12.0",
 *     administrator_login="mradministrator",
 *     administrator_login_password="thisIsDog11",
 *     tags={
 *         "environment": "production",
 *     })
 * ```
 * ```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 = "database-rg",
 *         Location = "West Europe",
 *     });
 *     var exampleAccount = new Azure.Storage.Account("example", new()
 *     {
 *         Name = "examplesa",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         AccountTier = "Standard",
 *         AccountReplicationType = "LRS",
 *     });
 *     var exampleSqlServer = new Azure.Sql.SqlServer("example", new()
 *     {
 *         Name = "mssqlserver",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         Version = "12.0",
 *         AdministratorLogin = "mradministrator",
 *         AdministratorLoginPassword = "thisIsDog11",
 *         Tags =
 *         {
 *             { "environment", "production" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/sql"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage"
 * 	"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("database-rg"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = storage.NewAccount(ctx, "example", &storage.AccountArgs{
 * 			Name:                   pulumi.String("examplesa"),
 * 			ResourceGroupName:      example.Name,
 * 			Location:               example.Location,
 * 			AccountTier:            pulumi.String("Standard"),
 * 			AccountReplicationType: pulumi.String("LRS"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = sql.NewSqlServer(ctx, "example", &sql.SqlServerArgs{
 * 			Name:                       pulumi.String("mssqlserver"),
 * 			ResourceGroupName:          example.Name,
 * 			Location:                   example.Location,
 * 			Version:                    pulumi.String("12.0"),
 * 			AdministratorLogin:         pulumi.String("mradministrator"),
 * 			AdministratorLoginPassword: pulumi.String("thisIsDog11"),
 * 			Tags: pulumi.StringMap{
 * 				"environment": pulumi.String("production"),
 * 			},
 * 		})
 * 		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.storage.Account;
 * import com.pulumi.azure.storage.AccountArgs;
 * import com.pulumi.azure.sql.SqlServer;
 * import com.pulumi.azure.sql.SqlServerArgs;
 * 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("database-rg")
 *             .location("West Europe")
 *             .build());
 *         var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
 *             .name("examplesa")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .accountTier("Standard")
 *             .accountReplicationType("LRS")
 *             .build());
 *         var exampleSqlServer = new SqlServer("exampleSqlServer", SqlServerArgs.builder()
 *             .name("mssqlserver")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .version("12.0")
 *             .administratorLogin("mradministrator")
 *             .administratorLoginPassword("thisIsDog11")
 *             .tags(Map.of("environment", "production"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: database-rg
 *       location: West Europe
 *   exampleAccount:
 *     type: azure:storage:Account
 *     name: example
 *     properties:
 *       name: examplesa
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       accountTier: Standard
 *       accountReplicationType: LRS
 *   exampleSqlServer:
 *     type: azure:sql:SqlServer
 *     name: example
 *     properties:
 *       name: mssqlserver
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       version: '12.0'
 *       administratorLogin: mradministrator
 *       administratorLoginPassword: thisIsDog11
 *       tags:
 *         environment: production
 * ```
 * 
 * ## Import
 * SQL Servers can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:sql/sqlServer:SqlServer example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/servers/myserver
 * ```
 */
public class SqlServer internal constructor(
    override val javaResource: com.pulumi.azure.sql.SqlServer,
) : KotlinCustomResource(javaResource, SqlServerMapper) {
    /**
     * The administrator login name for the new server. Changing this forces a new resource to be created.
     */
    public val administratorLogin: Output
        get() = javaResource.administratorLogin().applyValue({ args0 -> args0 })

    /**
     * The password associated with the `administrator_login` user. Needs to comply with Azure's [Password Policy](https://msdn.microsoft.com/library/ms161959.aspx)
     */
    public val administratorLoginPassword: Output
        get() = javaResource.administratorLoginPassword().applyValue({ args0 -> args0 })

    /**
     * The connection policy the server will use. Possible values are `Default`, `Proxy`, and `Redirect`. Defaults to `Default`.
     */
    public val connectionPolicy: Output?
        get() = javaResource.connectionPolicy().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The fully qualified domain name of the Azure SQL Server (e.g. myServerName.database.windows.net)
     */
    public val fullyQualifiedDomainName: Output
        get() = javaResource.fullyQualifiedDomainName().applyValue({ args0 -> args0 })

    /**
     * An `identity` block as defined below.
     */
    public val identity: Output?
        get() = javaResource.identity().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    sqlServerIdentityToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * The name of the Microsoft SQL Server. This needs to be globally unique within Azure. 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 to create the Microsoft SQL Server. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * A mapping of tags to assign to the resource.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * Threat detection policy configuration. The `threat_detection_policy` block supports fields documented below.
     */
    public val threatDetectionPolicy: Output
        get() = javaResource.threatDetectionPolicy().applyValue({ args0 ->
            args0.let({ args0 ->
                sqlServerThreatDetectionPolicyToKotlin(args0)
            })
        })

    /**
     * The version for the new server. Valid values are: 2.0 (for v11 server) and 12.0 (for v12 server). Changing this forces a new resource to be created.
     */
    public val version: Output
        get() = javaResource.version().applyValue({ args0 -> args0 })
}

public object SqlServerMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.sql.SqlServer::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy